Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MythPlayer: Fix decoder locking.

This should complete the overall decoder locking changes.

- when changing the decoder, pause before obtaining the
decoder_change_lock. Also add some logging to assess any delays in
livetv channel changes.

- lock access to the decoder in the main decoder loop. In all cases, use
tryLock and continue to the next loop iteration if it fails. Given that
the decoder_change_lock is now only used when by SetDecoder, the extra
locking should have no performance impact.

Cherry picked from df1df86
  • Loading branch information...
commit ccd73be08e8d76c44ac126a82b0a88ff91783ec7 1 parent ccc89dd
Mark Kendall authored
View
8 mythtv/libs/libmythtv/mythdvdplayer.cpp
@@ -66,9 +66,13 @@ bool MythDVDPlayer::PrebufferEnoughFrames(bool pause_audio, int min_buffers)
bool MythDVDPlayer::DecoderGetFrameFFREW(void)
{
- if (decoder)
- decoder->UpdateDVDFramesPlayed();
return MythPlayer::DecoderGetFrameFFREW();
+ if (decoder_change_lock.tryLock(1))
+ {
+ if (decoder)
+ decoder->UpdateDVDFramesPlayed();
+ decoder_change_lock.unlock();
+ }
}
bool MythDVDPlayer::DecoderGetFrameREW(void)
View
38 mythtv/libs/libmythtv/mythplayer.cpp
@@ -2779,14 +2779,16 @@ void MythPlayer::DecoderLoop(bool pause)
{
DecoderPauseCheck();
- decoder_change_lock.lock();
+ if (!decoder_change_lock.tryLock(1))
+ continue;
if (decoder)
noVideoTracks = !decoder->GetTrackCount(kTrackTypeVideo);
decoder_change_lock.unlock();
if (forcePositionMapSync)
{
- decoder_change_lock.lock();
+ if (!decoder_change_lock.tryLock(1))
+ continue;
if (decoder)
{
forcePositionMapSync = false;
@@ -2797,7 +2799,8 @@ void MythPlayer::DecoderLoop(bool pause)
if (decoderSeek >= 0)
{
- decoder_change_lock.lock();
+ if (!decoder_change_lock.tryLock(1))
+ continue;
if (decoder)
{
decoderSeekLock.lock();
@@ -2892,17 +2895,19 @@ bool MythPlayer::DecoderGetFrame(DecodeType decodetype, bool unsafe)
videobuf_retries = 0;
}
- if (killdecoder)
+ if (!decoder_change_lock.tryLock(5))
return false;
- if (!decoder)
+ if (killdecoder || !decoder || IsErrored())
{
- VERBOSE(VB_IMPORTANT, LOC + "DecoderGetFrame() called with NULL decoder.");
+ decoder_change_lock.unlock();
return false;
}
- else if (ffrew_skip == 1 || decodeOneFrame)
+
+ if (ffrew_skip == 1 || decodeOneFrame)
ret = decoder->GetFrame(decodetype);
else if (ffrew_skip != 0)
ret = DecoderGetFrameFFREW();
+ decoder_change_lock.unlock();
return ret;
}
@@ -4493,16 +4498,21 @@ bool MythPlayer::SetVideoByComponentTag(int tag)
*/
void MythPlayer::SetDecoder(DecoderBase *dec)
{
- QMutexLocker locker(&decoder_change_lock);
PauseDecoder();
- if (!decoder)
- decoder = dec;
- else
{
- DecoderBase *d = decoder;
- decoder = dec;
- delete d;
+ while (!decoder_change_lock.tryLock(10))
+ VERBOSE(VB_IMPORTANT, LOC + QString("Waited 10ms for decoder lock"));
+
+ if (!decoder)
+ decoder = dec;
+ else
+ {
+ DecoderBase *d = decoder;
+ decoder = dec;
+ delete d;
+ }
+ decoder_change_lock.unlock();
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.