[Redbutton-devel] SF.net SVN: redbutton:[545] redbutton-browser/trunk/MHEGStreamPlayer.c
Brought to you by:
skilvington
|
From: <ski...@us...> - 2011-03-20 20:34:57
|
Revision: 545
http://redbutton.svn.sourceforge.net/redbutton/?rev=545&view=rev
Author: skilvington
Date: 2011-03-20 20:34:51 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
avoid trying to do freopen when fread has the lock on the FILE
Modified Paths:
--------------
redbutton-browser/trunk/MHEGStreamPlayer.c
Modified: redbutton-browser/trunk/MHEGStreamPlayer.c
===================================================================
--- redbutton-browser/trunk/MHEGStreamPlayer.c 2011-03-20 20:01:17 UTC (rev 544)
+++ redbutton-browser/trunk/MHEGStreamPlayer.c 2011-03-20 20:34:51 UTC (rev 545)
@@ -414,12 +414,20 @@
/*
* we want to set the EOF flag on the transport stream,
- * so if the decoder thread is blocked in fread it will wake up
+ * so if the decoder thread is blocked in fread in mpegts_demux_frame it can escape and check p->stop
* otherwise the pthread_join call below will never return
*/
-//TODO: probably need to lock changes to p->ts->ts
if(p->ts != NULL)
+ {
+ /* wake up the fread, fread will now start returning 0, but feof() will still return 0 */
+ close(fileno(p->ts->ts));
+ /*
+ * now fread no longer has the stdio lock on the p->ts->ts FILE, do a freopen on it
+ * reading /dev/null will set EOF, so feof() will return non-0
+ * and the decoder thread will break out of mpegts_demux_frame
+ */
p->ts->ts = freopen("/dev/null", "r", p->ts->ts);
+ }
/* wait for the threads to finish */
pthread_join(p->decode_tid, NULL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|