[mythtv] Ticket 9201 - Why is Ticket locked? I've the same problem!

Kevin Buhr buhr at asaurus.net
Mon Dec 13 17:04:21 UTC 2010


Jochen Kühner <jochen.kuehner at gmx.de> writes:
>
> Why is the Ticket 9201 locked?
>
> Is no additional Information needed, I?ve the same problem!

Hi, Jochen,

You might want to try the attached patch. I'd be interested to know if
it fixes your problem (and maybe tickets 9177 and 9353 and others).

I was having numerous problems while switching channels, too, with jump
buffer errors, crashes, and so on. Eventually, I was able to reliably
duplicate it by switching between two particular channels to cause a
crash, and I found the following problem.

In mythplayer.cpp, it seems the player thread is allowed to keep running
during the SetDecoder() call. This is dangerous, both because the old
decoder is being torn down and the new decoder is not yet ready for
prime time. For example, ffmpeg can be destructing or still constructing
context information that the decoder thread is trying to read (result:
my duplicatible crash when an ffmpeg AVFormatContext->iformat pointer
was NULL).

I added a PauseDecoder() call at the beginning of SetDecoder(), and this
seemed to fix the crash problem without introducing any undesirable
behavior. I haven't seen a jump buffer error since, where I used to see
them fairly often. I also needed to remove the "&& !eof" in
PauseDecoder() to handle all cases. If there is an "eof" condition, the
new PauseDecoder() call in SetDecoder() *still* needs the decoder thread
to pause before it switches decoders, and I couldn't figure out why the
"&& !eof" check would be desirable in any other circumstances.

Anyway, the patch is attached. It's against a Mythbuntu autobuild
(0.24.0~trunk26882-0ubuntu0~mythbuntu2), which is what I've been testing
for a month or so. It appears to apply cleanly against the current Git
HEAD, but I haven't tested it.

diff -ru mythtv-0.24.0~trunk26882.vanilla/libs/libmythtv/mythplayer.cpp mythtv-0.24.0~trunk26882/libs/libmythtv/mythplayer.cpp
--- mythtv-0.24.0~trunk26882.vanilla/libs/libmythtv/mythplayer.cpp	2010-10-18 18:12:40.000000000 -0500
+++ mythtv-0.24.0~trunk26882/libs/libmythtv/mythplayer.cpp	2010-11-06 16:36:02.000000000 -0500
@@ -2684,7 +2684,7 @@
 
     int tries = 0;
     pauseDecoder = true;
-    while (decoderThread && !killdecoder && !eof && (tries++ < 100) &&
+    while (decoderThread && !killdecoder && (tries++ < 100) &&
           !decoderThreadPause.wait(&decoderPauseLock, 100))
     {
         VERBOSE(VB_IMPORTANT, LOC_WARN + "Waited 100ms for decoder to pause");
@@ -4439,11 +4439,14 @@
 
 /** \fn MythPlayer::SetDecoder(DecoderBase*)
  *  \brief Sets the stream decoder, deleting any existing recorder.
+ *
+ *    Note that this has the side effect of pausing the decoder thread.
  */
 void MythPlayer::SetDecoder(DecoderBase *dec)
 {
     QMutexLocker locker(&decoder_change_lock);
 
+    PauseDecoder();
     if (!decoder)
         decoder = dec;
     else





More information about the mythtv-dev mailing list