From 0e6c4e539a427e100564f018939be5c70bdb800c Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 10 Jul 2013 22:31:03 +1000 Subject: [PATCH] Display error as to why playback failed to start. Playback would otherwise fail silently, with the user wondering why. Fixes #11656 --- mythtv/libs/libmythtv/mythplayer.cpp | 15 +++++++++++++-- mythtv/libs/libmythtv/mythplayer.h | 7 ++++--- mythtv/libs/libmythtv/tv_play.cpp | 9 +++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp index 087f07d2b02..b4b75b739a9 100644 --- a/mythtv/libs/libmythtv/mythplayer.cpp +++ b/mythtv/libs/libmythtv/mythplayer.cpp @@ -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; } @@ -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"); @@ -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; @@ -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; @@ -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; } @@ -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); @@ -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); diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h index 19f14c5a985..ce373fdba48 100644 --- a/mythtv/libs/libmythtv/mythplayer.h +++ b/mythtv/libs/libmythtv/mythplayer.h @@ -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; @@ -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; diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp index a7d8e3afd8e..86f5170b6f5 100644 --- a/mythtv/libs/libmythtv/tv_play.cpp +++ b/mythtv/libs/libmythtv/tv_play.cpp @@ -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) {