summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Kendall <mkendall@mythtv.org>2010-12-14 05:45:44 (GMT)
committer Mark Kendall <mkendall@mythtv.org>2010-12-14 06:47:02 (GMT)
commit208e2f58682b374cdfe18c154e69cbc537e7e81d (patch)
treec546c8bc070d4dcff8537967fa4cb1eacf9c6f88
parentfc09367273037a2ffe437048b87fbc4a9a689b53 (diff)
Add some extra NULL pointer protection in the main decoder loop.
Based on a patch from Kevin Buhr
-rw-r--r--mythtv/libs/libmythtv/mythplayer.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
index 35eae5d..4fe3bf2 100644
--- a/mythtv/libs/libmythtv/mythplayer.cpp
+++ b/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;