Skip to content

Commit

Permalink
Add some extra NULL pointer protection in the main decoder loop.
Browse files Browse the repository at this point in the history
Based on a patch from Kevin Buhr
  • Loading branch information
Mark Kendall committed Dec 14, 2010
1 parent 6b622d2 commit f31bd0c
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -2727,7 +2727,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");
Expand Down Expand Up @@ -2816,19 +2816,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);
Expand Down Expand Up @@ -4478,6 +4488,7 @@ bool MythPlayer::SetVideoByComponentTag(int tag)
void MythPlayer::SetDecoder(DecoderBase *dec)
{
QMutexLocker locker(&decoder_change_lock);
PauseDecoder();

if (!decoder)
decoder = dec;
Expand Down

0 comments on commit f31bd0c

Please sign in to comment.