Permalink
Browse files

MythMusic: Attempt to keep playing on error

Previously if the music player encountered an error it would stop playing. Now
it will try to continue playing the next track in the playlist. If it fails to
play 5 tracks in a row then it will still stop though since it's likely there
is some serious problem like an NFS server can't be reached.

This also cleans up the error reporting and changes it to use the new
notification popups.

Fixes #11681.
  • Loading branch information...
Paul Harrison
Paul Harrison committed Aug 10, 2013
1 parent 3dafda5 commit 3df51ae045b0fed505f756236d3f40e92287df7e
@@ -1203,21 +1203,6 @@ void MusicCommon::customEvent(QEvent *event)
// TODO only need to update the playlist times here
updatePlaylistStats();
}
else if (event->type() == OutputEvent::Error)
{
OutputEvent *aoe = dynamic_cast<OutputEvent *>(event);
if (!aoe)
return;
statusString = tr("Output error.");
LOG(VB_GENERAL, LOG_ERR, QString("%1 %2").arg(statusString)
.arg(*aoe->errorMessage()));
ShowOkPopup(tr("MythMusic has encountered the following error:\n%1")
.arg(*aoe->errorMessage()));
stopAll();
}
else if (event->type() == OutputEvent::Stopped)
{
statusString = tr("Stream stopped.");
@@ -1242,39 +1227,6 @@ void MusicCommon::customEvent(QEvent *event)
stopVisualizer();
}
else if (event->type() == DecoderEvent::Error)
{
stopAll();
statusString = tr("Decoder error.");
DecoderEvent *dxe = dynamic_cast<DecoderEvent *>(event);
if (!dxe)
return;
LOG(VB_GENERAL, LOG_ERR, QString("%1 %2").arg(statusString)
.arg(*dxe->errorMessage()));
ShowOkPopup(tr("MythMusic has encountered the following error:\n%1")
.arg(*dxe->errorMessage()));
}
else if (event->type() == DecoderHandlerEvent::Error)
{
stopAll();
statusString = tr("Decoder Handler error.");
DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event);
if (!dhe)
return;
LOG(VB_GENERAL, LOG_ERR, QString("Decoder Handler Error - %1")
.arg(*dhe->getMessage()));
ShowOkPopup(QString("MythMusic has encountered the following error:\n%1")
.arg(*dhe->getMessage()));
}
else if (event->type() == DialogCompletionEvent::kEventType)
{
DialogCompletionEvent *dce = static_cast<DialogCompletionEvent*>(event);
@@ -79,6 +79,8 @@ MusicPlayer::MusicPlayer(QObject *parent)
m_playSpeed = 1.0;
m_errorCount = 0;
QString playmode = gCoreContext->GetSetting("PlayMode", "none");
if (playmode.toLower() == "random")
setShuffleMode(SHUFFLE_RANDOM);
@@ -539,6 +541,7 @@ void MusicPlayer::customEvent(QEvent *event)
// handle decoderHandler events
if (event->type() == DecoderHandlerEvent::Ready)
{
m_errorCount = 0;
decoderHandlerReady();
}
else if (event->type() == DecoderHandlerEvent::Meta)
@@ -710,54 +713,76 @@ void MusicPlayer::customEvent(QEvent *event)
}
}
if (m_isAutoplay)
if (event->type() == OutputEvent::Error)
{
if (event->type() == OutputEvent::Error)
{
OutputEvent *aoe = dynamic_cast<OutputEvent*>(event);
OutputEvent *aoe = dynamic_cast<OutputEvent *>(event);
if (!aoe)
return;
if (!aoe)
return;
LOG(VB_GENERAL, LOG_ERR, QString("Output Error - %1")
.arg(*aoe->errorMessage()));
LOG(VB_GENERAL, LOG_ERR, QString("Audio Output Error: %1").arg(*aoe->errorMessage()));
ShowOkPopup(QString("MythMusic has encountered the following error:\n%1")
.arg(*aoe->errorMessage()));
stop(true);
}
else if (event->type() == DecoderEvent::Error)
MythNotification n(tr("Audio Output Error"), tr("MythMusic"), *aoe->errorMessage());
n.SetDuration(10);
GetNotificationCenter()->Queue(n);
m_errorCount++;
if (m_errorCount <= 5)
nextAuto();
else
{
m_errorCount = 0;
stop(true);
}
}
else if (event->type() == DecoderEvent::Error)
{
DecoderEvent *dxe = dynamic_cast<DecoderEvent *>(event);
QApplication::sendPostedEvents();
if (!dxe)
return;
DecoderEvent *dxe = dynamic_cast<DecoderEvent*>(event);
LOG(VB_GENERAL, LOG_ERR, QString("Decoder Error: %2").arg(*dxe->errorMessage()));
if (!dxe)
return;
MythNotification n(tr("Decoder Error"), tr("MythMusic"), *dxe->errorMessage());
n.SetDuration(10);
GetNotificationCenter()->Queue(n);
LOG(VB_GENERAL, LOG_ERR, QString("Decoder Error - %1")
.arg(*dxe->errorMessage()));
ShowOkPopup(QString("MythMusic has encountered the following error:\n%1")
.arg(*dxe->errorMessage()));
}
else if (event->type() == DecoderHandlerEvent::Error)
m_errorCount++;
if (m_errorCount <= 5)
nextAuto();
else
{
DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event);
if (!dhe)
return;
m_errorCount = 0;
stop(true);
}
}
else if (event->type() == DecoderHandlerEvent::Error)
{
DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event);
LOG(VB_GENERAL, LOG_ERR, QString("Output Error - %1")
.arg(*dhe->getMessage()));
if (!dhe)
return;
ShowOkPopup(QString("MythMusic has encountered the following error:\n%1")
.arg(*dhe->getMessage()));
LOG(VB_GENERAL, LOG_ERR, QString("Decoder Handler Error - %1").arg(*dhe->getMessage()));
MythNotification n(tr("Decoder Handler Error"), tr("MythMusic"), *dhe->getMessage());
n.SetDuration(10);
GetNotificationCenter()->Queue(n);
m_errorCount++;
if (m_errorCount <= 5)
nextAuto();
else
{
m_errorCount = 0;
stop(true);
}
}
if (event->type() == OutputEvent::Info)
else if (event->type() == OutputEvent::Info)
{
OutputEvent *oe = dynamic_cast<OutputEvent*>(event);
@@ -232,6 +232,8 @@ class MusicPlayer : public QObject, public MythObservable
int m_lastTrackStart;
int m_bufferAvailable;
int m_bufferSize;
int m_errorCount;
};
Q_DECLARE_METATYPE(MusicPlayer::RepeatMode);

0 comments on commit 3df51ae

Please sign in to comment.