Skip to content

Commit

Permalink
MythPlayer: add back code to handle seamless LiveTV program transitions
Browse files Browse the repository at this point in the history
This reverts changesets dafabdc, 4d9afb4 and 13722d7 which removed the code
that handles seamless program transitions in LiveTV.
  • Loading branch information
tralph committed Mar 18, 2012
1 parent 43b55c9 commit 759fea8
Showing 1 changed file with 49 additions and 18 deletions.
67 changes: 49 additions & 18 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -2442,9 +2442,10 @@ void MythPlayer::SwitchToProgram(void)
return;

LOG(VB_PLAYBACK, LOG_INFO, LOC + "SwitchToProgram - start");
bool d1 = false, d2 = false;
bool discontinuity = false, newtype = false;
int newid = -1;
ProgramInfo *pginfo = player_ctx->tvchain->GetSwitchProgram(d1, d2, newid);
ProgramInfo *pginfo = player_ctx->tvchain->GetSwitchProgram(
discontinuity, newtype, newid);
if (!pginfo)
return;

Expand All @@ -2470,7 +2471,7 @@ void MythPlayer::SwitchToProgram(void)
{
LOG(VB_GENERAL, LOG_ERR, LOC + "SwitchToProgram's OpenFile failed " +
QString("(card type: %1).")
.arg(player_ctx->tvchain->GetCardType(newid)));
.arg(player_ctx->tvchain->GetCardType(newid)));
LOG(VB_GENERAL, LOG_ERR, player_ctx->tvchain->toString());
SetEof(true);
SetErrored(QObject::tr("Error opening switch program buffer"));
Expand All @@ -2479,19 +2480,39 @@ void MythPlayer::SwitchToProgram(void)
}

if (GetEof())
{
discontinuity = true;
ResetCaptions();
}

LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("newid: %1 decoderEof: %2")
.arg(newid).arg(GetEof()));

player_ctx->tvchain->SetProgram(*pginfo);
if (decoder)
decoder->SetProgramInfo(*pginfo);
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("SwitchToProgram(void) "
"discont: %1 newtype: %2 newid: %3 decoderEof: %4")
.arg(discontinuity).arg(newtype).arg(newid).arg(GetEof()));

player_ctx->buffer->Reset(true);
if (OpenFile() < 0)
SetErrored(QObject::tr("Error opening switch program file"));
if (discontinuity || newtype)
{
player_ctx->tvchain->SetProgram(*pginfo);
if (decoder)
decoder->SetProgramInfo(*pginfo);

player_ctx->buffer->Reset(true);
if (newtype)
{
if (OpenFile() < 0)
SetErrored(QObject::tr("Error opening switch program file"));
}
else
ResetPlaying();
}
else
{
player_ctx->SetPlayerChangingBuffers(true);
if (decoder)
{
decoder->SetReadAdjust(player_ctx->buffer->SetAdjustFilesize());
decoder->SetWaitForChange();
}
}
delete pginfo;

if (IsErrored())
Expand All @@ -2508,8 +2529,11 @@ void MythPlayer::SwitchToProgram(void)
player_ctx->buffer->UpdateRawBitrate(decoder->GetRawBitrate());
player_ctx->buffer->Unpause();

CheckTVChain();
forcePositionMapSync = true;
if (discontinuity || newtype)
{
CheckTVChain();
forcePositionMapSync = true;
}

Play();
LOG(VB_PLAYBACK, LOG_INFO, LOC + "SwitchToProgram - end");
Expand Down Expand Up @@ -2543,10 +2567,11 @@ void MythPlayer::FileChangedCallback(void)
void MythPlayer::JumpToProgram(void)
{
LOG(VB_PLAYBACK, LOG_INFO, LOC + "JumpToProgram - start");
bool d1 = false, d2 = false;
bool discontinuity = false, newtype = false;
int newid = -1;
long long nextpos = player_ctx->tvchain->GetJumpPos();
ProgramInfo *pginfo = player_ctx->tvchain->GetSwitchProgram(d1, d2, newid);
ProgramInfo *pginfo = player_ctx->tvchain->GetSwitchProgram(
discontinuity, newtype, newid);
if (!pginfo)
return;

Expand Down Expand Up @@ -2589,8 +2614,14 @@ void MythPlayer::JumpToProgram(void)
return;
}

if (OpenFile() < 0)
SetErrored(QObject::tr("Error opening jump program file"));
bool wasDummy = isDummy;
if (newtype || wasDummy)
{
if (OpenFile() < 0)
SetErrored(QObject::tr("Error opening jump program file"));
}
else
ResetPlaying();

if (IsErrored() || !decoder)
{
Expand Down

0 comments on commit 759fea8

Please sign in to comment.