Skip to content

Commit

Permalink
Display error as to why playback failed to start.
Browse files Browse the repository at this point in the history
Playback would otherwise fail silently, with the user wondering why.

Fixes #11656
  • Loading branch information
jyavenard committed Jul 10, 2013
1 parent 93a83da commit 0e6c4e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
15 changes: 13 additions & 2 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -575,7 +575,7 @@ void MythPlayer::ReinitVideo(void)
if (!videoOutput->IsPreferredRenderer(video_disp_dim))
{
LOG(VB_PLAYBACK, LOG_INFO, LOC + "Need to switch video renderer.");
SetErrored(tr("Need to switch video renderer."));
SetErrored(tr("Need to switch video renderer"));
errorType |= kError_Switch_Renderer;
return;
}
Expand Down Expand Up @@ -934,6 +934,7 @@ int MythPlayer::OpenFile(uint retries)
.arg(testreadsize)
.arg(player_ctx->buffer->GetFilename()));
delete[] testbuf;
SetErrored(tr("Could not read first %1 bytes").arg(testreadsize));
return -1;
}
LOG(VB_GENERAL, LOG_WARNING, LOC + "OpenFile() waiting on data");
Expand All @@ -953,6 +954,7 @@ int MythPlayer::OpenFile(uint retries)
LOG(VB_GENERAL, LOG_ERR, LOC +
QString("Couldn't find an A/V decoder for: '%1'")
.arg(player_ctx->buffer->GetFilename()));
SetErrored(tr("Could not find an A/V decoder"));

delete[] testbuf;
return -1;
Expand All @@ -961,6 +963,7 @@ int MythPlayer::OpenFile(uint retries)
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Could not initialize A/V decoder.");
SetDecoder(NULL);
SetErrored(tr("Could not initialize A/V decoder"));

delete[] testbuf;
return -1;
Expand All @@ -985,6 +988,7 @@ int MythPlayer::OpenFile(uint retries)
{
LOG(VB_GENERAL, LOG_ERR, QString("Couldn't open decoder for: %1")
.arg(player_ctx->buffer->GetFilename()));
SetErrored(tr("Could not open decoder"));
return -1;
}

Expand Down Expand Up @@ -5226,7 +5230,7 @@ bool MythPlayer::PosMapFromEnc(uint64_t start,
return true;
}

void MythPlayer::SetErrored(const QString &reason) const
void MythPlayer::SetErrored(const QString &reason)
{
QMutexLocker locker(&errorLock);

Expand All @@ -5244,6 +5248,13 @@ void MythPlayer::SetErrored(const QString &reason) const
}
}

void MythPlayer::ResetErrored(void)
{
QMutexLocker locker(&errorLock);

errorMsg = QString();
}

bool MythPlayer::IsErrored(void) const
{
QMutexLocker locker(&errorLock);
Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -551,7 +551,8 @@ class MTV_PUBLIC MythPlayer
// Private Sets
void SetPlayingInfo(const ProgramInfo &pginfo);
void SetPlaying(bool is_playing);
void SetErrored(const QString &reason) const;
void SetErrored(const QString &reason);
void ResetErrored(void);

// Private Gets
int GetStatusbarPos(void) const;
Expand Down Expand Up @@ -659,8 +660,8 @@ class MTV_PUBLIC MythPlayer
bool hasFullPositionMap;
mutable bool limitKeyRepeat;
mutable QMutex errorLock;
mutable QString errorMsg; ///< Reason why NVP exited with a error
mutable int errorType;
QString errorMsg; ///< Reason why NVP exited with a error
int errorType;

// Chapter stuff
int jumpchapter;
Expand Down
9 changes: 9 additions & 0 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -2408,6 +2408,15 @@ void TV::HandleStateChange(PlayerContext *mctx, PlayerContext *ctx)
{
SET_LAST();
SetErrored(ctx);
if (ctx && ctx->IsPlayerErrored())
{
ShowNotificationError(ctx->player->GetError(),
_Location,
buffer->GetFilename());
// We're going to display this error as notification
// no need to display it later as popup
ctx->player->ResetErrored();
}
}
else if (mctx != ctx)
{
Expand Down

0 comments on commit 0e6c4e5

Please sign in to comment.