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

File mythtv-play-to-end.20121231.patch, 11.2 KB (added by Mark Spieth, 7 years ago)

current patch to ease integration

  • mythtv/libs/libmythtv/decoderbase.cpp

    commit 50ca6e464e1a239c113b738cc6dd72c1c2a11689
    Author: Mark Spieth <mspieth@digivation.com.au>
    Date:   Wed Jan 5 10:51:51 2011 +1100
    
        play media to end when eof detected
    
    diff --git a/mythtv/libs/libmythtv/decoderbase.cpp b/mythtv/libs/libmythtv/decoderbase.cpp
    index 0f5c2e6..a397c59 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) 
    9191    if (reset_file)
    9292    {
    9393        waitingForChange = false;
    94         SetEof(false);
     94        SetEof(kEofStateNone);
    9595    }
    9696}
    9797
  • mythtv/libs/libmythtv/decoderbase.h

    diff --git a/mythtv/libs/libmythtv/decoderbase.h b/mythtv/libs/libmythtv/decoderbase.h
    index 7fb5f43..84a2c53 100644
    a b typedef enum AudioTrackType 
    5959} AudioTrackType;
    6060QString toString(AudioTrackType type);
    6161
     62// Eof States
     63typedef enum
     64{
     65    kEofStateNone,
     66    kEofStateDelayed,
     67    kEofStateImmediate
     68} EofState;
     69
    6270class StreamInfo
    6371{
    6472  public:
    class DecoderBase 
    115123                         char testbuf[kDecoderProbeBufferSize],
    116124                         int testbufsize = kDecoderProbeBufferSize) = 0;
    117125
    118     virtual void SetEof(bool eof)  { ateof = eof;  }
    119     bool         GetEof(void) const { return ateof; }
     126    virtual void SetEof(EofState eof)  { ateof = eof;  }
     127    virtual void SetEof(bool eof)  { ateof = eof?kEofStateDelayed:kEofStateNone;  }
     128    EofState     GetEof(void)      { return ateof; }
    120129
    121130    void SetSeekSnap(uint64_t snap)  { seeksnap = snap; }
    122131    uint64_t GetSeekSnap(void) const { return seeksnap;  }
    class DecoderBase 
    263272    int keyframedist;
    264273    long long indexOffset;
    265274
    266     bool ateof;
     275    EofState ateof;
    267276    bool exitafterdecoded;
    268277    bool transcoding;
    269278
  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 9f972fe..6b85715 100644
    a b bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    20772077        return false;
    20782078
    20792079    if (!(min_buffers ? (videoOutput->ValidVideoFrames() >= min_buffers) :
     2080                        (GetEof() != kEofStateNone) ||
    20802081                        (videoOutput->hasHWAcceleration() ?
    20812082                            videoOutput->EnoughPrebufferedFrames() :
    20822083                            videoOutput->EnoughDecodedFrames())))
    void MythPlayer::SwitchToProgram(void) 
    24792480    {
    24802481        OpenDummy();
    24812482        ResetPlaying();
    2482         SetEof(false);
     2483        SetEof(kEofStateNone);
    24832484        delete pginfo;
    24842485        return;
    24852486    }
    void MythPlayer::SwitchToProgram(void) 
    25012502            QString("(card type: %1).")
    25022503            .arg(player_ctx->tvchain->GetCardType(newid)));
    25032504        LOG(VB_GENERAL, LOG_ERR, player_ctx->tvchain->toString());
    2504         SetEof(true);
     2505        SetEof(kEofStateImmediate);
    25052506        SetErrored(tr("Error opening switch program buffer"));
    25062507        delete pginfo;
    25072508        return;
    25082509    }
    25092510
    2510     if (GetEof())
     2511    if (GetEof() != kEofStateNone)
    25112512    {
    25122513        discontinuity = true;
    25132514        ResetCaptions();
    void MythPlayer::SwitchToProgram(void) 
    25462547    if (IsErrored())
    25472548    {
    25482549        LOG(VB_GENERAL, LOG_ERR, LOC + "SwitchToProgram failed.");
    2549         SetEof(true);
     2550        SetEof(kEofStateDelayed);
    25502551        return;
    25512552    }
    25522553
    2553     SetEof(false);
     2554    SetEof(kEofStateNone);
    25542555
    25552556    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    25562557    if (decoder)
    void MythPlayer::FileChangedCallback(void) 
    25772578        player_ctx->buffer->Reset(false, true);
    25782579    else
    25792580        player_ctx->buffer->Reset(false, true, true);
    2580     SetEof(false);
     2581    SetEof(kEofStateNone);
    25812582    Play();
    25822583
    25832584    player_ctx->SetPlayerChangingBuffers(false);
    void MythPlayer::JumpToProgram(void) 
    26182619    {
    26192620        OpenDummy();
    26202621        ResetPlaying();
    2621         SetEof(false);
     2622        SetEof(kEofStateNone);
    26222623        delete pginfo;
    26232624        inJumpToProgramPause = false;
    26242625        return;
    void MythPlayer::JumpToProgram(void) 
    26432644            QString("(card type: %1).")
    26442645                .arg(player_ctx->tvchain->GetCardType(newid)));
    26452646        LOG(VB_GENERAL, LOG_ERR, player_ctx->tvchain->toString());
    2646         SetEof(true);
     2647        SetEof(kEofStateImmediate);
    26472648        SetErrored(tr("Error opening jump program file buffer"));
    26482649        delete pginfo;
    26492650        inJumpToProgramPause = false;
    void MythPlayer::JumpToProgram(void) 
    26692670        return;
    26702671    }
    26712672
    2672     SetEof(false);
     2673    SetEof(kEofStateNone);
    26732674
    26742675    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    26752676    player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
    void MythPlayer::EventLoop(void) 
    28202821        player_ctx->tvchain->JumpToNext(true, 1);
    28212822        JumpToProgram();
    28222823    }
    2823     else if ((!allpaused || GetEof()) && player_ctx->tvchain &&
     2824    else if ((!allpaused || (GetEof() != kEofStateNone)) && player_ctx->tvchain &&
    28242825             (decoder && !decoder->GetWaitForChange()))
    28252826    {
    28262827        // Switch to the next program in livetv
    void MythPlayer::EventLoop(void) 
    28802881    }
    28812882
    28822883    // Handle end of file
    2883     if (GetEof() && !allpaused)
     2884    EofState _eof = GetEof();
     2885    if ((_eof != kEofStateNone) && !allpaused)
    28842886    {
    28852887#ifdef USING_MHEG
    28862888        if (interactiveTV && interactiveTV->StreamStarted(false))
    void MythPlayer::EventLoop(void) 
    28962898            return;
    28972899        }
    28982900
    2899         SetPlaying(false);
    2900         return;
     2901        if (_eof == kEofStateImmediate)
     2902        {
     2903            SetPlaying(false);
     2904            return;
     2905        }
     2906        LOG(VB_PLAYBACK, LOG_INFO, QString("waiting for no video frames %1").arg(videoOutput->ValidVideoFrames()));
     2907        if (videoOutput && videoOutput->ValidVideoFrames() < 3)
     2908        {
     2909            SetPlaying(false);
     2910            return;
     2911        }
    29012912    }
    29022913
    29032914    // Handle rewind
    void MythPlayer::EventLoop(void) 
    29152926        if (fftime > 0)
    29162927        {
    29172928            DoFastForward(fftime, kInaccuracyDefault);
    2918             if (GetEof())
     2929            if (GetEof() != kEofStateNone)
    29192930               return;
    29202931        }
    29212932    }
    void MythPlayer::EventLoop(void) 
    29772988            if (!(endExitPrompt == 1 && !player_ctx->IsPIP() &&
    29782989                  player_ctx->GetState() == kState_WatchingPreRecorded))
    29792990            {
    2980                 SetEof(true);
     2991                SetEof(kEofStateDelayed);
    29812992            }
    29822993        }
    29832994        else
    void MythPlayer::DecoderPauseCheck(void) 
    30843095}
    30853096
    30863097//// FIXME - move the eof ownership back into MythPlayer
    3087 bool MythPlayer::GetEof(void)
     3098EofState MythPlayer::GetEof(void)
    30883099{
    30893100    if (is_current_thread(playerThread))
    3090         return decoder ? decoder->GetEof() : true;
     3101        return decoder ? decoder->GetEof() : kEofStateImmediate;
    30913102
    30923103    if (!decoder_change_lock.tryLock(50))
    3093         return false;
    3094 
    3095     bool eof = decoder ? decoder->GetEof() : true;
     3104        return kEofStateNone;
     3105       
     3106    EofState eof = decoder ? decoder->GetEof() : kEofStateImmediate;
    30963107    decoder_change_lock.unlock();
    30973108    return eof;
    30983109}
    30993110
    3100 void MythPlayer::SetEof(bool eof)
     3111void MythPlayer::SetEof(EofState eof)
    31013112{
    31023113    if (is_current_thread(playerThread))
    31033114    {
    void MythPlayer::DecoderLoop(bool pause) 
    31593170            decoder_change_lock.unlock();
    31603171        }
    31613172
    3162         bool obey_eof = GetEof() &&
    3163                         !(GetEof() && player_ctx->tvchain && !allpaused);
     3173        bool obey_eof = (GetEof() != kEofStateNone) &&
     3174                        !((GetEof() != kEofStateNone) && player_ctx->tvchain && !allpaused);
    31643175        if (isDummy || ((decoderPaused || ffrew_skip == 0 || obey_eof) &&
    31653176            !decodeOneFrame))
    31663177        {
    bool MythPlayer::TranscodeGetNextFrame( 
    44754486    if (!decoder->GetFrame(kDecodeAV))
    44764487        return false;
    44774488
    4478     if (GetEof())
     4489    if (GetEof() != kEofStateNone)
    44794490        return false;
    44804491
    44814492    if (honorCutList && !deleteMap.IsEmpty())
    bool MythPlayer::TranscodeGetNextFrame( 
    45014512            did_ff = 1;
    45024513        }
    45034514    }
    4504     if (GetEof())
     4515    if (GetEof() != kEofStateNone)
    45054516      return false;
    45064517    is_key = decoder->IsLastFrameKey();
    45074518
    bool MythPlayer::SetStream(const QString &stream) 
    49264937        player_ctx->buffer->GetType() == ICRingBuffer::kRingBufferType)
    49274938    {
    49284939        // Restore livetv
    4929         SetEof(true);
     4940        SetEof(kEofStateDelayed);
    49304941        player_ctx->tvchain->JumpToNext(false, 1);
    49314942        player_ctx->tvchain->JumpToNext(true, 1);
    49324943    }
    void MythPlayer::JumpToStream(const QString &stream) 
    49564967    if (!player_ctx->buffer->IsOpen())
    49574968    {
    49584969        LOG(VB_GENERAL, LOG_ERR, LOC + "JumpToStream buffer OpenFile failed");
    4959         SetEof(true);
     4970        SetEof(kEofStateImmediate);
    49604971        SetErrored(QObject::tr("Error opening remote stream buffer"));
    49614972        return;
    49624973    }
    void MythPlayer::JumpToStream(const QString &stream) 
    49694980    if (OpenFile(120) < 0) // 120 retries ~= 60 seconds
    49704981    {
    49714982        LOG(VB_GENERAL, LOG_ERR, LOC + "JumpToStream OpenFile failed.");
    4972         SetEof(true);
     4983        SetEof(kEofStateImmediate);
    49734984        SetErrored(QObject::tr("Error opening remote stream"));
    49744985        return;
    49754986    }
    void MythPlayer::JumpToStream(const QString &stream) 
    49854996        .arg(player_ctx->buffer->GetRealFileSize()).arg(decoder->GetRawBitrate())
    49864997        .arg(totalLength).arg(totalFrames).arg(decoder->GetFPS()) );
    49874998
    4988     SetEof(false);
     4999    SetEof(kEofStateNone);
    49895000
    49905001    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    49915002    player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
  • mythtv/libs/libmythtv/mythplayer.h

    diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
    index 695ff18..2728b10 100644
    a b class MTV_PUBLIC MythPlayer 
    142142    void SetLength(int len)                   { totalLength = len; }
    143143    void SetFramesPlayed(uint64_t played);
    144144    void SetVideoFilters(const QString &override);
    145     void SetEof(bool eof);
     145    void SetEof(EofState eof);
    146146    void SetPIPActive(bool is_active)         { pip_active = is_active; }
    147147    void SetPIPVisible(bool is_visible)       { pip_visible = is_visible; }
    148148
    class MTV_PUBLIC MythPlayer 
    198198    bool    IsPaused(void) const              { return allpaused;      }
    199199    bool    GetRawAudioState(void) const;
    200200    bool    GetLimitKeyRepeat(void) const     { return limitKeyRepeat; }
    201     bool    GetEof(void);
     201    EofState GetEof(void);
    202202    bool    IsErrored(void) const;
    203203    bool    IsPlaying(uint wait_ms = 0, bool wait_for = true) const;
    204204    bool    AtNormalSpeed(void) const         { return next_normal_speed; }