Ticket #6974: playtoend-jms.patch

File playtoend-jms.patch, 11.1 KB (added by Jim Stichnoth, 7 years ago)
  • mythtv/libs/libmythtv/decoderbase.cpp

    diff --git a/mythtv/libs/libmythtv/decoderbase.cpp b/mythtv/libs/libmythtv/decoderbase.cpp
    index 77947a4..5398d64 100644
    a b DecoderBase::DecoderBase(MythPlayer *parent, const ProgramInfo &pginfo) 
    3131      lastKey(0), keyframedist(-1), indexOffset(0),
    3232      trackTotalDuration(false),
    3333
    34       ateof(false), exitafterdecoded(false), transcoding(false),
     34      ateof(kEofStateNone), exitafterdecoded(false), transcoding(false),
    3535
    3636      hasFullPositionMap(false), recordingHasPositionMap(false),
    3737      posmapStarted(false), positionMapType(MARK_UNSET),
    void DecoderBase::Reset(bool reset_video_data, bool seek_reset, bool reset_file) 
    9292    if (reset_file)
    9393    {
    9494        waitingForChange = false;
    95         SetEof(false);
     95        SetEof(kEofStateNone);
    9696    }
    9797}
    9898
  • mythtv/libs/libmythtv/decoderbase.h

    diff --git a/mythtv/libs/libmythtv/decoderbase.h b/mythtv/libs/libmythtv/decoderbase.h
    index 2620c0c..7b7a568 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 
    289298    // indicates whether this is the case.
    290299    bool trackTotalDuration;
    291300
    292     bool ateof;
     301    EofState ateof;
    293302    bool exitafterdecoded;
    294303    bool transcoding;
    295304
  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 56eeb53..d43fc67 100644
    a b bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    20782078        return false;
    20792079
    20802080    if (!(min_buffers ? (videoOutput->ValidVideoFrames() >= min_buffers) :
     2081                        (GetEof() != kEofStateNone) ||
    20812082                        (videoOutput->hasHWAcceleration() ?
    20822083                            videoOutput->EnoughPrebufferedFrames() :
    20832084                            videoOutput->EnoughDecodedFrames())))
    void MythPlayer::SwitchToProgram(void) 
    24902491    {
    24912492        OpenDummy();
    24922493        ResetPlaying();
    2493         SetEof(false);
     2494        SetEof(kEofStateNone);
    24942495        delete pginfo;
    24952496        return;
    24962497    }
    void MythPlayer::SwitchToProgram(void) 
    25122513            QString("(card type: %1).")
    25132514            .arg(player_ctx->tvchain->GetCardType(newid)));
    25142515        LOG(VB_GENERAL, LOG_ERR, player_ctx->tvchain->toString());
    2515         SetEof(true);
     2516        SetEof(kEofStateImmediate);
    25162517        SetErrored(tr("Error opening switch program buffer"));
    25172518        delete pginfo;
    25182519        return;
    25192520    }
    25202521
    2521     if (GetEof())
     2522    if (GetEof() != kEofStateNone)
    25222523    {
    25232524        discontinuity = true;
    25242525        ResetCaptions();
    void MythPlayer::SwitchToProgram(void) 
    25572558    if (IsErrored())
    25582559    {
    25592560        LOG(VB_GENERAL, LOG_ERR, LOC + "SwitchToProgram failed.");
    2560         SetEof(true);
     2561        SetEof(kEofStateDelayed);
    25612562        return;
    25622563    }
    25632564
    2564     SetEof(false);
     2565    SetEof(kEofStateNone);
    25652566
    25662567    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    25672568    if (decoder)
    void MythPlayer::FileChangedCallback(void) 
    25882589        player_ctx->buffer->Reset(false, true);
    25892590    else
    25902591        player_ctx->buffer->Reset(false, true, true);
    2591     SetEof(false);
     2592    SetEof(kEofStateNone);
    25922593    Play();
    25932594
    25942595    player_ctx->SetPlayerChangingBuffers(false);
    void MythPlayer::JumpToProgram(void) 
    26292630    {
    26302631        OpenDummy();
    26312632        ResetPlaying();
    2632         SetEof(false);
     2633        SetEof(kEofStateNone);
    26332634        delete pginfo;
    26342635        inJumpToProgramPause = false;
    26352636        return;
    void MythPlayer::JumpToProgram(void) 
    26542655            QString("(card type: %1).")
    26552656                .arg(player_ctx->tvchain->GetCardType(newid)));
    26562657        LOG(VB_GENERAL, LOG_ERR, player_ctx->tvchain->toString());
    2657         SetEof(true);
     2658        SetEof(kEofStateImmediate);
    26582659        SetErrored(tr("Error opening jump program file buffer"));
    26592660        delete pginfo;
    26602661        inJumpToProgramPause = false;
    void MythPlayer::JumpToProgram(void) 
    26802681        return;
    26812682    }
    26822683
    2683     SetEof(false);
     2684    SetEof(kEofStateNone);
    26842685
    26852686    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    26862687    player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
    void MythPlayer::EventLoop(void) 
    28312832        player_ctx->tvchain->JumpToNext(true, 1);
    28322833        JumpToProgram();
    28332834    }
    2834     else if ((!allpaused || GetEof()) && player_ctx->tvchain &&
     2835    else if ((!allpaused || (GetEof() != kEofStateNone)) && player_ctx->tvchain &&
    28352836             (decoder && !decoder->GetWaitForChange()))
    28362837    {
    28372838        // Switch to the next program in livetv
    void MythPlayer::EventLoop(void) 
    28912892    }
    28922893
    28932894    // Handle end of file
    2894     if ((GetEof() && !allpaused) ||
     2895    EofState _eof = GetEof();
     2896    if (((_eof != kEofStateNone) && !allpaused) ||
    28952897        (!GetEditMode() && framesPlayed >= deleteMap.GetLastFrame()))
    28962898    {
    28972899#ifdef USING_MHEG
    void MythPlayer::EventLoop(void) 
    29082910            return;
    29092911        }
    29102912
    2911         Pause();
    2912         SetPlaying(false);
    2913         return;
     2913        if (_eof != kEofStateDelayed)
     2914        {
     2915            Pause();
     2916            SetPlaying(false);
     2917            return;
     2918        }
     2919        LOG(VB_PLAYBACK, LOG_INFO, QString("waiting for no video frames %1").arg(videoOutput->ValidVideoFrames()));
     2920        if (videoOutput && videoOutput->ValidVideoFrames() < 3)
     2921        {
     2922            Pause();
     2923            SetPlaying(false);
     2924            return;
     2925        }
    29142926    }
    29152927
    29162928    // Handle rewind
    void MythPlayer::EventLoop(void) 
    29282940        if (fftime > 0)
    29292941        {
    29302942            DoFastForward(fftime, kInaccuracyDefault);
    2931             if (GetEof())
     2943            if (GetEof() != kEofStateNone)
    29322944               return;
    29332945        }
    29342946    }
    void MythPlayer::EventLoop(void) 
    29933005            if (!(endExitPrompt == 1 && !player_ctx->IsPIP() &&
    29943006                  player_ctx->GetState() == kState_WatchingPreRecorded))
    29953007            {
    2996                 SetEof(true);
     3008                SetEof(kEofStateDelayed);
    29973009            }
    29983010        }
    29993011        else
    void MythPlayer::DecoderPauseCheck(void) 
    31003112}
    31013113
    31023114//// FIXME - move the eof ownership back into MythPlayer
    3103 bool MythPlayer::GetEof(void)
     3115EofState MythPlayer::GetEof(void)
    31043116{
    31053117    if (is_current_thread(playerThread))
    3106         return decoder ? decoder->GetEof() : true;
     3118        return decoder ? decoder->GetEof() : kEofStateImmediate;
    31073119
    31083120    if (!decoder_change_lock.tryLock(50))
    3109         return false;
     3121        return kEofStateNone;
    31103122
    3111     bool eof = decoder ? decoder->GetEof() : true;
     3123    EofState eof = decoder ? decoder->GetEof() : kEofStateImmediate;
    31123124    decoder_change_lock.unlock();
    31133125    return eof;
    31143126}
    31153127
    3116 void MythPlayer::SetEof(bool eof)
     3128void MythPlayer::SetEof(EofState eof)
    31173129{
    31183130    if (is_current_thread(playerThread))
    31193131    {
    void MythPlayer::DecoderLoop(bool pause) 
    31753187            decoder_change_lock.unlock();
    31763188        }
    31773189
    3178         bool obey_eof = GetEof() &&
    3179                         !(GetEof() && player_ctx->tvchain && !allpaused);
     3190        bool obey_eof = (GetEof() != kEofStateNone) &&
     3191                        !((GetEof() != kEofStateNone) && player_ctx->tvchain && !allpaused);
    31803192        if (isDummy || ((decoderPaused || ffrew_skip == 0 || obey_eof) &&
    31813193            !decodeOneFrame))
    31823194        {
    bool MythPlayer::TranscodeGetNextFrame( 
    45104522    if (!decoder->GetFrame(kDecodeAV))
    45114523        return false;
    45124524
    4513     if (GetEof())
     4525    if (GetEof() != kEofStateNone)
    45144526        return false;
    45154527
    45164528    if (honorCutList && !deleteMap.IsEmpty())
    bool MythPlayer::TranscodeGetNextFrame( 
    45354547            did_ff = 1;
    45364548        }
    45374549    }
    4538     if (GetEof())
     4550    if (GetEof() != kEofStateNone)
    45394551      return false;
    45404552    is_key = decoder->IsLastFrameKey();
    45414553
    bool MythPlayer::SetStream(const QString &stream) 
    49985010        player_ctx->buffer->GetType() == ICRingBuffer::kRingBufferType)
    49995011    {
    50005012        // Restore livetv
    5001         SetEof(true);
     5013        SetEof(kEofStateDelayed);
    50025014        player_ctx->tvchain->JumpToNext(false, 1);
    50035015        player_ctx->tvchain->JumpToNext(true, 1);
    50045016    }
    void MythPlayer::JumpToStream(const QString &stream) 
    50285040    if (!player_ctx->buffer->IsOpen())
    50295041    {
    50305042        LOG(VB_GENERAL, LOG_ERR, LOC + "JumpToStream buffer OpenFile failed");
    5031         SetEof(true);
     5043        SetEof(kEofStateImmediate);
    50325044        SetErrored(QObject::tr("Error opening remote stream buffer"));
    50335045        return;
    50345046    }
    void MythPlayer::JumpToStream(const QString &stream) 
    50415053    if (OpenFile(120) < 0) // 120 retries ~= 60 seconds
    50425054    {
    50435055        LOG(VB_GENERAL, LOG_ERR, LOC + "JumpToStream OpenFile failed.");
    5044         SetEof(true);
     5056        SetEof(kEofStateImmediate);
    50455057        SetErrored(QObject::tr("Error opening remote stream"));
    50465058        return;
    50475059    }
    void MythPlayer::JumpToStream(const QString &stream) 
    50575069        .arg(player_ctx->buffer->GetRealFileSize()).arg(decoder->GetRawBitrate())
    50585070        .arg(totalLength).arg(totalFrames).arg(decoder->GetFPS()) );
    50595071
    5060     SetEof(false);
     5072    SetEof(kEofStateNone);
    50615073
    50625074    // the bitrate is reset by player_ctx->buffer->OpenFile()...
    50635075    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 bf27f48..4037c71 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; }