Ticket #2434: mythplayback2.diff

File mythplayback2.diff, 3.3 KB (added by tomimo@…, 13 years ago)

Fixes a still existing race condition with Unpause/pause & lirc remote control

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    147147      // Window stuff
    148148      parentWidget(NULL), embedid(0), embx(-1), emby(-1), embw(-1), embh(-1),
    149149      // State
     150      pause_signal(false),
    150151      eof(false),                   m_double_framerate(false),
    151152      m_can_double(false),          paused(false),
    152153      pausevideo(false),            actuallypaused(false),
     
    461462    video_actually_paused = false;
    462463    pausevideo = true;
    463464
    464     for (uint i = 0; wait && !video_actually_paused; i++)
    465     {
    466         videoThreadPaused.wait(&pauseUnpauseLock, 250);
     465    VERBOSE(VB_IMPORTANT, QString("PauseVideo() Called wait=%1").arg(wait));
    467466
    468         if (video_actually_paused || eof)
     467    if (wait && !video_actually_paused) {
     468        uint i=0;
     469        while (!pause_signal && videoThreadPause.wait(&pauseUnpauseLock, 250)) {
     470
     471            if (video_actually_paused || eof) {
     472                pause_signal=false;
    469473            break;
     474            }
    470475
    471476        if ((i % 10) == 9)
    472             VERBOSE(VB_IMPORTANT, "Waited too long for video out to pause");
     477                VERBOSE(VB_IMPORTANT, QString("Waited too long for video out to pause %1").arg(i));
    473478    }
    474479}
     480    pause_signal=false;
     481}
    475482
    476483void NuppelVideoPlayer::UnpauseVideo(bool wait)
    477484{
     485    VERBOSE(VB_IMPORTANT, QString("UnpauseVideo() Called wait=%1").arg(wait));
     486
    478487    QMutexLocker locker(&pauseUnpauseLock);
    479488    pausevideo = false;
    480489
    481     for (uint i = 0; wait && video_actually_paused; i++)
    482     {
    483         videoThreadUnpaused.wait(&pauseUnpauseLock, 250);
     490    if (wait && video_actually_paused) {
     491      uint i=0;
     492      while (!pause_signal && videoThreadPause.wait(&pauseUnpauseLock, 250)) {
    484493
    485         if (!video_actually_paused || eof)
     494        if (!video_actually_paused || eof) {
     495          pause_signal=false;
    486496            break;
     497        }
     498        ++i;
    487499
    488500        if ((i % 10) == 9)
    489501            VERBOSE(VB_IMPORTANT, "Waited too long for video out to unpause");
    490502    }
    491503}
     504    pause_signal=false;
     505}
    492506
    493507void NuppelVideoPlayer::SetVideoActuallyPaused(bool val)
    494508{
    495509    QMutexLocker locker(&pauseUnpauseLock);
    496510    video_actually_paused = val;
    497 
    498     if (val)
    499         videoThreadPaused.wakeAll();
    500     else
    501         videoThreadUnpaused.wakeAll();
     511    pause_signal=true;
     512    videoThreadPause.wakeAll();
    502513}
    503514
     515
    504516bool NuppelVideoPlayer::IsVideoActuallyPaused(void) const
    505517{
    506518    QMutexLocker locker(&pauseUnpauseLock);
  • libs/libmythtv/NuppelVideoPlayer.h

     
    525525
    526526    // State
    527527    QWaitCondition decoderThreadPaused;
    528     QWaitCondition videoThreadPaused;
    529     QWaitCondition videoThreadUnpaused;
     528    QWaitCondition videoThreadPause;
    530529    mutable QMutex vidExitLock;
    531530    mutable QMutex pauseUnpauseLock;
    532531    mutable QMutex internalPauseLock;
     532    bool     pause_signal;
    533533    bool     eof;             ///< At end of file/ringbuffer
    534534    bool     m_double_framerate;///< Output fps is double Video (input) rate
    535535    bool     m_can_double;    ///< VideoOutput capable of doubling frame rate