Ticket #6974: mythtv-play-to-end.20120306.patch

File mythtv-play-to-end.20120306.patch, 10.4 KB (added by Mark Spieth, 12 years ago)

updated reasonably current patch for play to end

  • mythtv/libs/libmythtv/decoderbase.cpp

    play media to end when eof detected
    
    From: Mark Spieth <mspieth@digivation.com.au>
    
    
    ---
     mythtv/libs/libmythtv/decoderbase.cpp       |    4 +-
     mythtv/libs/libmythtv/decoderbase.h         |   15 +++++--
     mythtv/libs/libmythtv/mythplayer.cpp        |   61 ++++++++++++++++-----------
     mythtv/libs/libmythtv/mythplayer.h          |    4 +-
     mythtv/programs/mythtranscode/transcode.cpp |    1 
     5 files changed, 53 insertions(+), 32 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/decoderbase.cpp b/mythtv/libs/libmythtv/decoderbase.cpp
    index 3286be9..caa1216 100644
    a b DecoderBase::DecoderBase(MythPlayer *parent, const ProgramInfo &pginfo) 
    3030      framesPlayed(0), framesRead(0), totalDuration(0),
    3131      lastKey(0), keyframedist(-1), indexOffset(0),
    3232
    33       ateof(false), exitafterdecoded(false), transcoding(false),
     33      ateof(kEofStateNone), exitafterdecoded(false), transcoding(false),
    3434
    3535      hasFullPositionMap(false), recordingHasPositionMap(false),
    3636      posmapStarted(false), positionMapType(MARK_UNSET),
    void DecoderBase::Reset(bool reset_video_data, bool seek_reset, bool reset_file) 
    9090    if (reset_file)
    9191    {
    9292        waitingForChange = false;
    93         SetEof(false);
     93        SetEof(kEofStateNone);
    9494    }
    9595}
    9696
  • mythtv/libs/libmythtv/decoderbase.h

    diff --git a/mythtv/libs/libmythtv/decoderbase.h b/mythtv/libs/libmythtv/decoderbase.h
    index a9925d4..678094e 100644
    a b typedef enum DecodeTypes 
    4747    kDecodeAV      = 0x03,
    4848} DecodeType;
    4949
     50// Eof States
     51typedef enum
     52{
     53    kEofStateNone,
     54    kEofStateDelayed,
     55    kEofStateImmediate
     56} EofState;
     57
    5058class StreamInfo
    5159{
    5260  public:
    class DecoderBase 
    97105                         char testbuf[kDecoderProbeBufferSize],
    98106                         int testbufsize = kDecoderProbeBufferSize) = 0;
    99107
    100     virtual void SetEof(bool eof)  { ateof = eof;  }
    101     bool         GetEof(void) const { return ateof; }
     108    virtual void SetEof(EofState eof)  { ateof = eof;  }
     109    virtual void SetEof(bool eof)  { ateof = eof?kEofStateDelayed:kEofStateNone;  }
     110    EofState     GetEof(void)      { return ateof; }
    102111
    103112    void setExactSeeks(bool exact) { exactseeks = exact; }
    104113    bool getExactSeeks(void) const { return exactseeks;  }
    class DecoderBase 
    244253    int keyframedist;
    245254    long long indexOffset;
    246255
    247     bool ateof;
     256    EofState ateof;
    248257    bool exitafterdecoded;
    249258    bool transcoding;
    250259
  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index bffc141..167694e 100644
    a b bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    20332033        return false;
    20342034
    20352035    if (!(min_buffers ? (videoOutput->ValidVideoFrames() >= min_buffers) :
     2036                        (GetEof() != kEofStateNone) ||
    20362037                        (videoOutput->hasHWAcceleration() ?
    20372038                            videoOutput->EnoughPrebufferedFrames() :
    20382039                            videoOutput->EnoughDecodedFrames())))
    void MythPlayer::SwitchToProgram(void) 
    24132414    {
    24142415        OpenDummy();
    24152416        ResetPlaying();
    2416         SetEof(false);
     2417        SetEof(kEofStateNone);
    24172418        delete pginfo;
    24182419        return;
    24192420    }
    void MythPlayer::SwitchToProgram(void) 
    24272428            QString("(card type: %1).")
    24282429                .arg(player_ctx->tvchain->GetCardType(newid)));
    24292430        LOG(VB_GENERAL, LOG_ERR, player_ctx->tvchain->toString());
    2430         SetEof(true);
     2431        SetEof(kEofStateImmediate);
    24312432        SetErrored(QObject::tr("Error opening switch program buffer"));
    24322433        delete pginfo;
    24332434        return;
    24342435    }
    24352436
    2436     if (GetEof())
     2437    if (GetEof() != kEofStateNone)
    24372438        ResetCaptions();
    24382439
    24392440    LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("newid: %1 decoderEof: %2")
    void MythPlayer::SwitchToProgram(void) 
    24522453    if (IsErrored())
    24532454    {
    24542455        LOG(VB_GENERAL, LOG_ERR, LOC + "SwitchToProgram failed.");
    2455         SetEof(true);
     2456        SetEof(kEofStateDelayed);
    24562457        return;
    24572458    }
    24582459
    2459     SetEof(false);
     2460    SetEof(kEofStateNone);
    24602461
    24612462    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    24622463    if (decoder)
    void MythPlayer::FileChangedCallback(void) 
    24802481        player_ctx->buffer->Reset(false, true);
    24812482    else
    24822483        player_ctx->buffer->Reset(false, true, true);
    2483     SetEof(false);
     2484    SetEof(kEofStateNone);
    24842485    Play();
    24852486
    24862487    player_ctx->SetPlayerChangingBuffers(false);
    void MythPlayer::JumpToProgram(void) 
    25182519    {
    25192520        OpenDummy();
    25202521        ResetPlaying();
    2521         SetEof(false);
     2522        SetEof(kEofStateNone);
    25222523        delete pginfo;
    25232524        return;
    25242525    }
    void MythPlayer::JumpToProgram(void) 
    25342535            QString("(card type: %1).")
    25352536                .arg(player_ctx->tvchain->GetCardType(newid)));
    25362537        LOG(VB_GENERAL, LOG_ERR, player_ctx->tvchain->toString());
    2537         SetEof(true);
     2538        SetEof(kEofStateImmediate);
    25382539        SetErrored(QObject::tr("Error opening jump program file buffer"));
    25392540        delete pginfo;
    25402541        return;
    void MythPlayer::JumpToProgram(void) 
    25522553        return;
    25532554    }
    25542555
    2555     SetEof(false);
     2556    SetEof(kEofStateNone);
    25562557
    25572558    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    25582559    player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
    void MythPlayer::EventLoop(void) 
    27032704        player_ctx->tvchain->JumpToNext(true, 1);
    27042705        JumpToProgram();
    27052706    }
    2706     else if ((!allpaused || GetEof()) && player_ctx->tvchain &&
     2707    else if ((!allpaused || (GetEof() != kEofStateNone)) && player_ctx->tvchain &&
    27072708             (decoder && !decoder->GetWaitForChange()))
    27082709    {
    27092710        // Switch to the next program in livetv
    void MythPlayer::EventLoop(void) 
    27532754    }
    27542755
    27552756    // Handle end of file
    2756     if (GetEof())
     2757    EofState _eof = GetEof();
     2758    if (_eof != kEofStateNone)
    27572759    {
    27582760        if (player_ctx->tvchain)
    27592761        {
    void MythPlayer::EventLoop(void) 
    27662768        }
    27672769        else if (!allpaused)
    27682770        {
    2769             SetPlaying(false);
    2770             return;
     2771            if (_eof == kEofStateImmediate)
     2772            {
     2773                SetPlaying(false);
     2774                return;
     2775            }
     2776            LOG(VB_PLAYBACK, LOG_INFO, QString("waiting for no video frames %1").arg(videoOutput->ValidVideoFrames()));
     2777            if (videoOutput && videoOutput->ValidVideoFrames() < 3)
     2778            {
     2779                SetPlaying(false);
     2780                return;
     2781            }
    27712782        }
    27722783    }
    27732784
    void MythPlayer::EventLoop(void) 
    27862797        if (fftime > 0)
    27872798        {
    27882799            DoFastForward(fftime);
    2789             if (GetEof())
     2800            if (GetEof() != kEofStateNone)
    27902801               return;
    27912802        }
    27922803    }
    void MythPlayer::EventLoop(void) 
    28472858            if (!(endExitPrompt == 1 && !player_ctx->IsPIP() &&
    28482859                  player_ctx->GetState() == kState_WatchingPreRecorded))
    28492860            {
    2850                 SetEof(true);
     2861                SetEof(kEofStateDelayed);
    28512862            }
    28522863        }
    28532864        else
    void MythPlayer::DecoderPauseCheck(void) 
    29542965}
    29552966
    29562967//// FIXME - move the eof ownership back into MythPlayer
    2957 bool MythPlayer::GetEof(void)
     2968EofState MythPlayer::GetEof(void)
    29582969{
    29592970    if (is_current_thread(playerThread))
    2960         return decoder ? decoder->GetEof() : true;
     2971        return decoder ? decoder->GetEof() : kEofStateImmediate;
    29612972
    29622973    if (!decoder_change_lock.tryLock(50))
    2963         return false;
    2964 
    2965     bool eof = decoder ? decoder->GetEof() : true;
     2974        return kEofStateNone;
     2975       
     2976    EofState eof = decoder ? decoder->GetEof() : kEofStateImmediate;
    29662977    decoder_change_lock.unlock();
    29672978    return eof;
    29682979}
    29692980
    2970 void MythPlayer::SetEof(bool eof)
     2981void MythPlayer::SetEof(EofState eof)
    29712982{
    29722983    if (is_current_thread(playerThread))
    29732984    {
    void MythPlayer::DecoderLoop(bool pause) 
    30293040            decoder_change_lock.unlock();
    30303041        }
    30313042
    3032         bool obey_eof = GetEof() &&
    3033                         !(GetEof() && player_ctx->tvchain && !allpaused);
     3043        bool obey_eof = (GetEof() != kEofStateNone) &&
     3044                        !((GetEof() != kEofStateNone) && player_ctx->tvchain && !allpaused);
    30343045        if (isDummy || ((decoderPaused || ffrew_skip == 0 || obey_eof) &&
    30353046            !decodeOneFrame))
    30363047        {
    bool MythPlayer::TranscodeGetNextFrame( 
    43744385    if (!decoder->GetFrame(kDecodeAV))
    43754386        return false;
    43764387
    4377     if (GetEof())
     4388    if (GetEof() != kEofStateNone)
    43784389        return false;
    43794390
    43804391    if (honorCutList && !deleteMap.IsEmpty())
    bool MythPlayer::TranscodeGetNextFrame( 
    44004411            did_ff = 1;
    44014412        }
    44024413    }
    4403     if (GetEof())
     4414    if (GetEof() != kEofStateNone)
    44044415      return false;
    44054416    is_key = decoder->IsLastFrameKey();
    44064417
  • mythtv/libs/libmythtv/mythplayer.h

    diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
    index a1aec32..42cfe52 100644
    a b class MTV_PUBLIC MythPlayer 
    144144    void SetLength(int len)                   { totalLength = len; }
    145145    void SetFramesPlayed(uint64_t played);
    146146    void SetVideoFilters(const QString &override);
    147     void SetEof(bool eof);
     147    void SetEof(EofState eof);
    148148    void SetPIPActive(bool is_active)         { pip_active = is_active; }
    149149    void SetPIPVisible(bool is_visible)       { pip_visible = is_visible; }
    150150
    class MTV_PUBLIC MythPlayer 
    200200    bool    IsPaused(void) const              { return allpaused;      }
    201201    bool    GetRawAudioState(void) const;
    202202    bool    GetLimitKeyRepeat(void) const     { return limitKeyRepeat; }
    203     bool    GetEof(void);
     203    EofState GetEof(void);
    204204    bool    IsErrored(void) const;
    205205    bool    IsPlaying(uint wait_ms = 0, bool wait_for = true) const;
    206206    bool    AtNormalSpeed(void) const         { return next_normal_speed; }
  • mythtv/programs/mythtranscode/transcode.cpp

    diff --git a/mythtv/programs/mythtranscode/transcode.cpp b/mythtv/programs/mythtranscode/transcode.cpp
    index 7d8bb9d..70d6f75 100644
    a b class AudioReencodeBuffer : public AudioOutput 
    8484        eff_audiorate = (dsprate / 100);
    8585    }
    8686
     87    virtual void SetTimedBlocking(bool block) { (void)block; }
    8788    virtual void Reset(void)
    8889    {
    8990        audiobuffer_len = 0;