Ticket #9823: 0038-mythplayer-Avoid-stutters-between-programs-and-when-.patch

File 0038-mythplayer-Avoid-stutters-between-programs-and-when-.patch, 6.5 KB (added by Lawrence Rust <lvr@…>, 13 years ago)
  • mythtv/libs/libmythtv/mythplayer.cpp

    From 206f9ae13ac20084210d296aed427aafdc4e1a3c Mon Sep 17 00:00:00 2001
    From: Lawrence Rust <lvr@softsystem.co.uk>
    Date: Fri, 27 May 2011 20:15:15 +0200
    Subject: [PATCH 38/42] mythplayer: Avoid stutters between programs and when changing channel.
    
    This reverts part of commit 08a8a65535638de185e68f76898c118161d4bf88
    (Force reload of context and stream properties when switching between LiveTV)
    and reorders some code to reduce interference with RingBuffer prefetching
    and decoding.
    
    I can't reproduce (on DVB-S) the problems that commit 08a8a655 is supposed to
    fix and the disruption to program switching it causes is very annoying.
    
    Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
    ---
     mythtv/libs/libmythtv/mythplayer.cpp |   82 ++++++++++++++--------------------
     1 files changed, 33 insertions(+), 49 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index e3219db..3233b96 100644
    a b void MythPlayer::SwitchToProgram(void) 
    21862186    VERBOSE(VB_PLAYBACK, LOC + "SwitchToProgram - start");
    21872187    bool discontinuity = false, newtype = false;
    21882188    int newid = -1;
    2189     ProgramInfo *pginfo = player_ctx->tvchain->GetSwitchProgram(
    2190         discontinuity, newtype, newid);
     2189    QSharedPointer<ProgramInfo> pginfo(player_ctx->tvchain->GetSwitchProgram(
     2190        discontinuity, newtype, newid));
    21912191    if (!pginfo)
    21922192        return;
    2193     newtype = true; // force reloading of context and stream properties
    21942193
    21952194    bool newIsDummy = player_ctx->tvchain->GetCardType(newid) == "DUMMY";
    21962195
    21972196    SetPlayingInfo(*pginfo);
    2198     Pause();
    2199     ChangeSpeed();
    22002197
    22012198    if (newIsDummy)
    22022199    {
    22032200        OpenDummy();
    22042201        ResetPlaying();
    22052202        SetEof(false);
    2206         delete pginfo;
    22072203        return;
    22082204    }
    22092205
    void MythPlayer::SwitchToProgram(void) 
    22182214        VERBOSE(VB_IMPORTANT, QString("\n") + player_ctx->tvchain->toString());
    22192215        SetEof(true);
    22202216        SetErrored(QObject::tr("Error opening switch program buffer"));
    2221         delete pginfo;
    22222217        return;
    22232218    }
    22242219
    22252220    if (GetEof())
    2226     {
    22272221        discontinuity = true;
    2228         ResetCaptions();
    2229     }
    22302222
    22312223    VERBOSE(VB_PLAYBACK, LOC + QString("SwitchToProgram(void) "
    22322224            "discont: %1 newtype: %2 newid: %3 decoderEof: %4")
    void MythPlayer::SwitchToProgram(void) 
    22342226
    22352227    if (discontinuity || newtype)
    22362228    {
    2237         player_ctx->tvchain->SetProgram(*pginfo);
    2238         if (decoder)
    2239             decoder->SetProgramInfo(*pginfo);
     2229        Pause();
     2230        ChangeSpeed();
     2231        ResetCaptions();
    22402232
     2233        player_ctx->tvchain->SetProgram(*pginfo);
    22412234        player_ctx->buffer->Reset(true);
     2235
    22422236        if (newtype)
    22432237        {
    22442238            if (OpenFile() < 0)
    void MythPlayer::SwitchToProgram(void) 
    22462240        }
    22472241        else
    22482242            ResetPlaying();
     2243
     2244        if (IsErrored())
     2245        {
     2246            VERBOSE(VB_IMPORTANT, LOC_ERR + "SwitchToProgram failed.");
     2247            SetEof(true);
     2248            return;
     2249        }
     2250
     2251        SetEof(false);
     2252
     2253        if (decoder)
     2254        {
     2255            // the bitrate is reset by player_ctx->buffer->OpenFile()...
     2256            player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
     2257            decoder->SetProgramInfo(*pginfo);
     2258        }
     2259
     2260        CheckTVChain();
     2261        forcePositionMapSync = true;
     2262        Play();
    22492263    }
    22502264    else
    22512265    {
    22522266        player_ctx->SetPlayerChangingBuffers(true);
    22532267        if (decoder)
    22542268        {
     2269            // the bitrate is reset by player_ctx->buffer->OpenFile()...
     2270            player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
    22552271            decoder->SetReadAdjust(player_ctx->buffer->SetAdjustFilesize());
    22562272            decoder->SetWaitForChange();
    22572273        }
    22582274    }
    2259     delete pginfo;
    2260 
    2261     if (IsErrored())
    2262     {
    2263         VERBOSE(VB_IMPORTANT, LOC_ERR + "SwitchToProgram failed.");
    2264         SetEof(true);
    2265         return;
    2266     }
    2267 
    2268     SetEof(false);
    2269 
    2270     // the bitrate is reset by player_ctx->buffer->OpenFile()...
    2271     if (decoder)
    2272         player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
    2273     player_ctx->buffer->Unpause();
    2274 
    2275     if (discontinuity || newtype)
    2276     {
    2277         CheckTVChain();
    2278         forcePositionMapSync = true;
    2279     }
    22802275
    2281     Play();
    22822276    VERBOSE(VB_PLAYBACK, LOC + "SwitchToProgram - end");
    22832277}
    22842278
    void MythPlayer::FileChangedCallback(void) 
    22862280{
    22872281    VERBOSE(VB_PLAYBACK, LOC + "FileChangedCallback");
    22882282
    2289     Pause();
    22902283    ChangeSpeed();
    2291     if (dynamic_cast<AvFormatDecoder *>(decoder))
    2292         player_ctx->buffer->Reset(false, true);
    2293     else
    2294         player_ctx->buffer->Reset(false, true, true);
    2295     SetEof(false);
    2296     Play();
     2284    player_ctx->buffer->Reset(false, false, true);
    22972285
    22982286    player_ctx->SetPlayerChangingBuffers(false);
    22992287
    void MythPlayer::JumpToProgram(void) 
    23132301    bool discontinuity = false, newtype = false;
    23142302    int newid = -1;
    23152303    long long nextpos = player_ctx->tvchain->GetJumpPos();
    2316     ProgramInfo *pginfo = player_ctx->tvchain->GetSwitchProgram(
    2317         discontinuity, newtype, newid);
     2304    QSharedPointer<ProgramInfo> pginfo(player_ctx->tvchain->GetSwitchProgram(
     2305        discontinuity, newtype, newid));
    23182306    if (!pginfo)
    23192307        return;
    23202308    newtype = true; // force reloading of context and stream properties
    void MythPlayer::JumpToProgram(void) 
    23332321        OpenDummy();
    23342322        ResetPlaying();
    23352323        SetEof(false);
    2336         delete pginfo;
    23372324        return;
    23382325    }
    23392326
    2340     SendMythSystemPlayEvent("PLAY_CHANGED", pginfo);
     2327    SendMythSystemPlayEvent("PLAY_CHANGED", pginfo.data());
    23412328
    23422329    player_ctx->buffer->OpenFile(
    23432330        pginfo->GetPlaybackURL(), RingBuffer::kLiveTVOpenTimeout);
    void MythPlayer::JumpToProgram(void) 
    23502337        VERBOSE(VB_IMPORTANT, QString("\n") + player_ctx->tvchain->toString());
    23512338        SetEof(true);
    23522339        SetErrored(QObject::tr("Error opening jump program file buffer"));
    2353         delete pginfo;
    23542340        return;
    23552341    }
    23562342
    void MythPlayer::JumpToProgram(void) 
    23682354        VERBOSE(VB_IMPORTANT, LOC_ERR + "JumpToProgram failed.");
    23692355        if (!IsErrored())
    23702356            SetErrored(QObject::tr("Error reopening video decoder"));
    2371         delete pginfo;
    23722357        return;
    23732358    }
    23742359
    void MythPlayer::JumpToProgram(void) 
    23792364    player_ctx->buffer->IgnoreLiveEOF(false);
    23802365
    23812366    decoder->SetProgramInfo(*pginfo);
    2382     delete pginfo;
    23832367
    23842368    CheckTVChain();
    23852369    forcePositionMapSync = true;