[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/asobj/NetStreamFfmpeg.cp...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/NetStreamFfmpeg.cp... |
Date: |
Thu, 22 May 2008 11:30:18 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/05/22 11:30:17
Modified files:
. : ChangeLog
server/asobj : NetStreamFfmpeg.cpp NetStreamFfmpeg.h
Log message:
* server/asobj/NetStreamFfmpeg.{cpp,h}: have the decoder thread
only exit if explicitly requested; on EOF just wait on the
condition, will be waked up on destruction or seek.
Fixes the seek in NetStream-SquareTest.swf (head)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6675&r2=1.6676
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.132&r2=1.133
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.h?cvsroot=gnash&r1=1.66&r2=1.67
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6675
retrieving revision 1.6676
diff -u -b -r1.6675 -r1.6676
--- ChangeLog 22 May 2008 09:52:16 -0000 1.6675
+++ ChangeLog 22 May 2008 11:30:16 -0000 1.6676
@@ -1,5 +1,11 @@
2008-05-22 Sandro Santilli <address@hidden>
+ * server/asobj/NetStreamFfmpeg.{cpp,h}: have the decoder thread
+ only exit if explicitly requested; on EOF just wait on the
+ condition, will be waked up on destruction or seek.
+
+2008-05-22 Sandro Santilli <address@hidden>
+
* server/asobj/NetStreamFfmpeg.cpp: reduce code complexity.
2008-05-21 Bastiaan Jacques <address@hidden>
Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -b -r1.132 -r1.133
--- server/asobj/NetStreamFfmpeg.cpp 22 May 2008 09:52:17 -0000 1.132
+++ server/asobj/NetStreamFfmpeg.cpp 22 May 2008 11:30:17 -0000 1.133
@@ -48,7 +48,7 @@
#endif
/// Define this to add debugging prints for locking
-//#define GNASH_DEBUG_THREADS
+#define GNASH_DEBUG_THREADS
// Define the following macro to have status notification handling debugged
//#define GNASH_DEBUG_STATUS
@@ -78,6 +78,7 @@
_decodeThread(NULL),
_decodeThreadBarrier(2), // main and decoder threads
+ _qFillerKillRequest(false),
m_last_video_timestamp(0),
m_last_audio_timestamp(0),
@@ -127,22 +128,9 @@
void NetStreamFfmpeg::close()
{
+ GNASH_REPORT_FUNCTION;
- if (decodingStatus() != DEC_STOPPED && decodingStatus() != DEC_NONE)
- {
- // request decoder thread termination
- decodingStatus(DEC_STOPPED);
-
- // resume the decoder, if waiting
- _qFillerResume.notify_all();
-
- // wait till thread is complete before main continues
- if ( _decodeThread ) _decodeThread->join();
- // else could be decoder didn't start yet...
-
- delete _decodeThread;
-
- }
+ killDecodeThread();
// When closing gnash before playback is finished, the soundhandler
// seems to be removed before netstream is destroyed.
@@ -664,8 +652,8 @@
ns->m_unqueued_data = NULL;
- // Loop while we're playing or buffering
- while (ns->decodingStatus() != DEC_STOPPED)
+ // Loop until killed
+ while ( ! ns->decodeThreadKillRequested() ) // locks _qMutex
{
unsigned long int sleepTime = 1000;
@@ -678,6 +666,13 @@
log_debug("qMutex: lock obtained in av_streamer");
#endif
+ if ( ns->decodingStatus() == DEC_STOPPED )
+ {
+ log_debug("Dec stopped (eof), waiting on qNeedRefill
condition");
+ ns->_qFillerResume.wait(lock);
+ continue; // will release the lock for a moment
+ }
+
#ifdef GNASH_DEBUG_THREADS
log_debug("Decoding iteration. bufferTime=%lu, bufferLen=%lu,
videoFrames=%lu, audioFrames=%lu",
ns->bufferTime(), ns->bufferLength(),
ns->m_qvideo.size(), ns->m_qaudio.size());
@@ -752,13 +747,14 @@
NetStreamFfmpeg* ns = static_cast<NetStreamFfmpeg*>(owner);
- if (ns->playbackStatus() == PLAY_PAUSED)
+ PlaybackState pbStatus = ns->playbackStatus();
+ if (pbStatus != PLAY_PLAYING)
{
log_debug("playback status is paused, won't consume audio
frames");
return false;
}
- while (len > 0 && ! ns->m_qaudio.empty())
+ while (len > 0)
{
#ifdef GNASH_DEBUG_THREADS
log_debug("qMutex: waiting for lock in audio_streamer");
@@ -768,6 +764,14 @@
log_debug("qMutex: lock obtained in audio_streamer");
#endif
+ if ( ns->m_qaudio.empty() )
+ {
+#ifdef GNASH_DEBUG_THREADS
+ log_debug("qMutex: releasing lock in audio_streamer");
+#endif
+ break;
+ }
+
media::raw_mediadata_t* samples = ns->m_qaudio.front();
int n = std::min<int>(samples->m_size, len);
@@ -801,7 +805,8 @@
if (frame == NULL)
{
- assert ( _netCon->loadCompleted() );
+ //assert ( _netCon->loadCompleted() );
+ //assert ( m_parser->parsingCompleted() );
decodingStatus(DEC_STOPPED);
return true;
}
@@ -1156,6 +1161,11 @@
void
NetStreamFfmpeg::seek(boost::uint32_t pos)
{
+ GNASH_REPORT_FUNCTION;
+
+ // We'll mess with the queues here
+ boost::mutex::scoped_lock lock(_qMutex);
+
long newpos = 0;
double timebase = 0;
@@ -1242,6 +1252,14 @@
m_qvideo.clear();
m_qaudio.clear();
+ decodingStatus(DEC_DECODING); // or ::refreshVideoFrame will send a
STOPPED again
+ if ( playbackStatus() == PLAY_STOPPED )
+ {
+ // restart playback (if not paused)
+ playbackStatus(PLAY_PLAYING);
+ }
+ _qFillerResume.notify_all(); // wake it decoder is sleeping
+
}
void
@@ -1487,6 +1505,40 @@
return _decoding_state;
}
+void
+NetStreamFfmpeg::killDecodeThread()
+{
+ GNASH_REPORT_FUNCTION;
+
+ {
+#ifdef GNASH_DEBUG_THREADS
+ log_debug("qMutex: waiting for lock in killDecodeThread");
+#endif
+ boost::mutex::scoped_lock lock(_qMutex);
+#ifdef GNASH_DEBUG_THREADS
+ log_debug("qMutex: lock obtained in killDecodeThread");
+#endif
+
+ _qFillerKillRequest = true;
+ _qFillerResume.notify_all(); // wake it up if waiting..
+ }
+
+ // might as well be never started
+ if ( _decodeThread )
+ {
+ _decodeThread->join();
+ }
+
+ delete _decodeThread;
+ _decodeThread = NULL;
+}
+
+bool
+NetStreamFfmpeg::decodeThreadKillRequested()
+{
+ boost::mutex::scoped_lock lock(_qMutex);
+ return _qFillerKillRequest;
+}
} // gnash namespcae
Index: server/asobj/NetStreamFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- server/asobj/NetStreamFfmpeg.h 21 May 2008 16:48:15 -0000 1.66
+++ server/asobj/NetStreamFfmpeg.h 22 May 2008 11:30:17 -0000 1.67
@@ -253,6 +253,25 @@
// Barrier to synchronize thread and thread starter
boost::barrier _decodeThreadBarrier;
+ /// Kill decoder thread, if any
+ //
+ /// POSTCONDITIONS:
+ /// _decodeThread is NULL
+ /// decoder thread is not running
+ ///
+ /// Uses the _qMutex
+ ///
+ void killDecodeThread();
+
+ /// Return true if kill of decoder thread
+ /// was requested
+ //
+ bool decodeThreadKillRequested();
+
+ /// Protected by _qMutex
+ bool _qFillerKillRequest;
+
+
// The timestamp of the last decoded video frame, in seconds.
volatile boost::uint32_t m_last_video_timestamp;