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 05:45:44 (GMT)
commitf31bd0c843f668bbccbc2de963abf7bd1448d921 (patch)
tree3f52dfd31e8fea862458c5d954926daf7a813474
parent6b622d21989a20572ee3e2d3f741735bc9063cd6 (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 1705794..e750a09 100644
--- a/mythtv/libs/libmythtv/mythplayer.cpp
+++ b/mythtv/libs/libmythtv/mythplayer.cpp
@@ -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");
@@ -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);
@@ -4478,6 +4488,7 @@ bool MythPlayer::SetVideoByComponentTag(int tag)
void MythPlayer::SetDecoder(DecoderBase *dec)
{
QMutexLocker locker(&decoder_change_lock);
+ PauseDecoder();
if (!decoder)
decoder = dec;