Permalink
Browse files

Add some extra NULL pointer protection in the main decoder loop.

Based on a patch from Kevin Buhr
  • Loading branch information...
Mark Kendall
Mark Kendall committed Dec 14, 2010
1 parent fc09367 commit 208e2f58682b374cdfe18c154e69cbc537e7e81d
Showing with 21 additions and 10 deletions.
  1. +21 −10 mythtv/libs/libmythtv/mythplayer.cpp
@@ -2713,7 +2713,7 @@ bool MythPlayer::PauseDecoder(void)
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");
@@ -2802,19 +2802,29 @@ void MythPlayer::DecoderLoop(bool pause)
if (forcePositionMapSync)
{
- forcePositionMapSync = false;
- decoder->SyncPositionMap();
+ decoder_change_lock.lock();
+ if (decoder)
+ {
+ forcePositionMapSync = false;
+ decoder->SyncPositionMap();
+ }
+ decoder_change_lock.unlock();
}
if (decoderSeek >= 0)
{
- decoderSeekLock.lock();
- if (((uint64_t)decoderSeek < framesPlayed) && decoder)
- decoder->DoRewind(decoderSeek);
- else if (decoder)
- decoder->DoFastForward(decoderSeek);
- decoderSeek = -1;
- decoderSeekLock.unlock();
+ decoder_change_lock.lock();
+ if (decoder)
+ {
+ decoderSeekLock.lock();
+ if (((uint64_t)decoderSeek < framesPlayed) && decoder)
+ decoder->DoRewind(decoderSeek);
+ else if (decoder)
+ decoder->DoFastForward(decoderSeek);
+ decoderSeek = -1;
+ decoderSeekLock.unlock();
+ }
+ decoder_change_lock.unlock();
}
bool obey_eof = eof && !(eof && player_ctx->tvchain && !allpaused);
@@ -4476,6 +4486,7 @@ bool MythPlayer::SetVideoByComponentTag(int tag)
void MythPlayer::SetDecoder(DecoderBase *dec)
{
QMutexLocker locker(&decoder_change_lock);
+ PauseDecoder();
if (!decoder)
decoder = dec;

0 comments on commit 208e2f5

Please sign in to comment.