Ticket #2434: 2434-v3.patch

File 2434-v3.patch, 7.3 KB (added by danielk, 17 years ago)

Cosmetic changes to 2434-v2.patch

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    401401    PauseDecoder();
    402402
    403403    //cout << "stopping other threads" << endl;
     404    internalPauseLock.lock();
    404405    PauseVideo(waitvideo);
     406    internalPauseLock.unlock();
     407
    405408    if (audioOutput)
    406409    {
    407410        audio_paused = true;
     
    428431            QString("Play(%1, normal %2, unpause audio %3)")
    429432            .arg(speed,5,'f',1).arg(normal).arg(unpauseaudio));
    430433
     434    internalPauseLock.lock();
    431435    UnpauseVideo();
     436    internalPauseLock.unlock();
     437
    432438    if (audioOutput && unpauseaudio)
    433439        audio_paused = false;
    434440    if (ringBuffer)
     
    446452    return (actuallypaused &&
    447453            (ringBuffer == NULL || ringBuffer->isPaused()) &&
    448454            (audioOutput == NULL || audioOutput->GetPause()) &&
    449             GetVideoPause());
     455            IsVideoActuallyPaused());
    450456}
    451457
    452458void NuppelVideoPlayer::PauseVideo(bool wait)
    453459{
     460    QMutexLocker locker(&pauseUnpauseLock);
    454461    video_actually_paused = false;
    455462    pausevideo = true;
    456463
    457     if (wait && !video_actually_paused)
     464    for (uint i = 0; wait && !video_actually_paused; i++)
    458465    {
    459         while (!videoThreadPaused.wait(1000))
    460         {
    461             if (eof)
    462                 return;
     466        videoThreadPaused.wait(&pauseUnpauseLock, 250);
     467
     468        if (video_actually_paused || eof)
     469            break;
     470
     471        if ((i % 10) == 9)
    463472            VERBOSE(VB_IMPORTANT, "Waited too long for video out to pause");
    464         }
    465473    }
    466474}
    467475
    468 void NuppelVideoPlayer::UnpauseVideo(void)
     476void NuppelVideoPlayer::UnpauseVideo(bool wait)
    469477{
     478    QMutexLocker locker(&pauseUnpauseLock);
    470479    pausevideo = false;
     480
     481    for (uint i = 0; wait && video_actually_paused; i++)
     482    {
     483        videoThreadUnpaused.wait(&pauseUnpauseLock, 250);
     484
     485        if (!video_actually_paused || eof)
     486            break;
     487
     488        if ((i % 10) == 9)
     489            VERBOSE(VB_IMPORTANT, "Waited too long for video out to unpause");
     490    }
    471491}
    472492
     493void NuppelVideoPlayer::SetVideoActuallyPaused(bool val)
     494{
     495    QMutexLocker locker(&pauseUnpauseLock);
     496    video_actually_paused = val;
     497
     498    if (val)
     499        videoThreadPaused.wakeAll();
     500    else
     501        videoThreadUnpaused.wakeAll();
     502}
     503
     504bool NuppelVideoPlayer::IsVideoActuallyPaused(void) const
     505{
     506    QMutexLocker locker(&pauseUnpauseLock);
     507    return video_actually_paused;
     508}
     509
    473510void NuppelVideoPlayer::SetPrebuffering(bool prebuffer)
    474511{
    475512    prebuffering_lock.lock();
     
    23002337        resetvideo = false;
    23012338    }
    23022339
    2303     video_actually_paused = true;
    2304     videoThreadPaused.wakeAll();
     2340    SetVideoActuallyPaused(true);
    23052341
    23062342    if (videoOutput->IsErrored())
    23072343    {
     
    24082444
    24092445void NuppelVideoPlayer::DisplayNormalFrame(void)
    24102446{
    2411     video_actually_paused = false;
     2447    SetVideoActuallyPaused(false);
    24122448    resetvideo = false;
    24132449
    24142450    if (!ringBuffer->InDVDMenuOrStillFrame() ||
     
    26922728        }
    26932729
    26942730        resetvideo = false;
    2695         video_actually_paused = pausevideo;
     2731        SetVideoActuallyPaused(pausevideo);
    26962732
    26972733        if (pausevideo)
    26982734        {
    2699             videoThreadPaused.wakeAll();
    27002735            videofiltersLock.lock();
    27012736            videoOutput->ProcessFrame(NULL, osd, videoFilters, pipplayer);
    27022737            videofiltersLock.unlock();
     
    33323367
    33333368            if (rewindtime >= 1)
    33343369            {
    3335                 PauseVideo();
     3370                QMutexLocker locker(&internalPauseLock);
    33363371
     3372                PauseVideo(true);
    33373373                DoRewind();
    3338 
    3339                 UnpauseVideo();
    3340                 while (GetVideoPause())
    3341                     usleep(1000);
     3374                UnpauseVideo(true);
    33423375            }
    33433376            rewindtime = 0;
    33443377        }
     
    33493382
    33503383            if (fftime >= 5)
    33513384            {
    3352                 PauseVideo();
     3385                QMutexLocker locker(&internalPauseLock);
    33533386
     3387                PauseVideo(true);
     3388
    33543389                if (fftime >= 5)
    33553390                    DoFastForward();
    33563391
    33573392                if (eof)
    33583393                    continue;
    33593394
    3360                 UnpauseVideo();
    3361                 while (GetVideoPause())
    3362                     usleep(1000);
     3395                UnpauseVideo(true);
    33633396            }
    33643397
    33653398            fftime = 0;
     
    33673400
    33683401        if (need_change_dvd_track)
    33693402        {
    3370             PauseVideo();
     3403            QMutexLocker locker(&internalPauseLock);
    33713404
     3405            PauseVideo(true);
    33723406            DoChangeDVDTrack();
     3407            UnpauseVideo(true);
    33733408
    3374             UnpauseVideo();
    3375             while (GetVideoPause())
    3376                 usleep(1000);
    3377 
    33783409            need_change_dvd_track = 0;
    33793410        }
    33803411
    33813412        if (skipcommercials != 0 && ffrew_skip == 1)
    33823413        {
    3383             PauseVideo();
     3414            QMutexLocker locker(&internalPauseLock);
    33843415
     3416            PauseVideo(true);
    33853417            DoSkipCommercials(skipcommercials);
    3386             UnpauseVideo();
    3387             while (GetVideoPause())
    3388                 usleep(1000);
     3418            UnpauseVideo(true);
    33893419
    33903420            skipcommercials = 0;
    33913421            continue;
     
    34183448            }
    34193449            else
    34203450            {
    3421                 PauseVideo();
     3451                QMutexLocker locker(&internalPauseLock);
     3452
     3453                PauseVideo(true);
    34223454                JumpToFrame(deleteIter.key());
    3423                 UnpauseVideo();
    3424                 while (GetVideoPause())
    3425                     usleep(1000);
     3455                UnpauseVideo(true);
    34263456            }
    34273457        }
    34283458    }
     
    57655795                        .arg(commBreakIter.key() -
    57665796                        (int)(commrewindamount * video_frame_rate)));
    57675797
    5768                     PauseVideo();
     5798                    internalPauseLock.lock();
     5799
     5800                    PauseVideo(true);
    57695801                    JumpToFrame(commBreakIter.key() -
    57705802                        (int)(commrewindamount * video_frame_rate));
    5771                     UnpauseVideo();
    5772                     while (GetVideoPause())
    5773                         usleep(1000);
     5803                    UnpauseVideo(true);
    57745804
     5805                    internalPauseLock.unlock();
     5806
    57755807                    GetFrame(1, true);
    57765808                }
    57775809                else
  • libs/libmythtv/NuppelVideoPlayer.h

     
    418418
    419419    // Private pausing stuff
    420420    void PauseVideo(bool wait = true);
    421     void UnpauseVideo(void);
    422     bool GetVideoPause(void) const { return video_actually_paused; }
     421    void UnpauseVideo(bool wait = false);
     422    void SetVideoActuallyPaused(bool val);
     423    bool IsVideoActuallyPaused(void) const;
    423424
    424425    // Private decoder stuff
    425426    void  SetDecoder(DecoderBase *dec);
     
    523524    // State
    524525    QWaitCondition decoderThreadPaused;
    525526    QWaitCondition videoThreadPaused;
    526     QMutex   vidExitLock;
     527    QWaitCondition videoThreadUnpaused;
     528    mutable QMutex vidExitLock;
     529    mutable QMutex pauseUnpauseLock;
     530    mutable QMutex internalPauseLock;
    527531    bool     eof;             ///< At end of file/ringbuffer
    528532    bool     m_double_framerate;///< Output fps is double Video (input) rate
    529533    bool     m_can_double;    ///< VideoOutput capable of doubling frame rate