Permalink
Browse files

MythMusic: Check the audio output was opened without error before usi…

…ng it.

Fixes #9403.
  • Loading branch information...
1 parent 6e3b759 commit 750bdf1392b52108e6f0104ee98c9bf2f34df438 Paul Harrison committed Jul 27, 2011
Showing with 29 additions and 4 deletions.
  1. +28 −3 mythplugins/mythmusic/mythmusic/musicplayer.cpp
  2. +1 −1 mythplugins/mythmusic/mythmusic/musicplayer.h
@@ -271,7 +271,10 @@ void MusicPlayer::play(void)
if (!m_output)
- openOutputDevice();
+ {
+ if (!openOutputDevice())
+ return;
+ }
if (!getDecoderHandler())
setupDecoderHandler();
@@ -297,7 +300,7 @@ void MusicPlayer::stopDecoder(void)
m_currentMetadata = NULL;
}
-void MusicPlayer::openOutputDevice(void)
+bool MusicPlayer::openOutputDevice(void)
{
QString adevice, pdevice;
@@ -309,12 +312,32 @@ void MusicPlayer::openOutputDevice(void)
pdevice = gCoreContext->GetNumSetting("PassThruDeviceOverride", false) ?
gCoreContext->GetSetting("PassThruOutputDevice") : "auto";
- // TODO: Error checking that device is opened correctly!
m_output = AudioOutput::OpenAudio(
adevice, pdevice, FORMAT_S16, 2, 0, 44100,
AUDIOOUTPUT_MUSIC, true, false,
gCoreContext->GetNumSetting("MusicDefaultUpmix", 0) + 1);
+ if (!m_output)
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("MusicPlayer: Cannot open audio output device: %1").arg(adevice));
+
+ return false;
+ }
+
+ if (!m_output->GetError().isEmpty())
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("MusicPlayer: Cannot open audio output device: %1").arg(adevice));
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("Error was: %1").arg(m_output->GetError()));
+
+ delete m_output;
+ m_output = NULL;
+
+ return false;
+ }
+
m_output->setBufferSize(256 * 1024);
m_output->addListener(this);
@@ -333,6 +356,8 @@ void MusicPlayer::openOutputDevice(void)
{
m_output->addListener(*it);
}
+
+ return true;
}
void MusicPlayer::next(void)
@@ -167,7 +167,7 @@ class MusicPlayer : public QObject, public MythObservable
private:
void stopDecoder(void);
- void openOutputDevice(void);
+ bool openOutputDevice(void);
QString getFilenameFromID(int id);
void updateLastplay(void);
void sendVolumeChangedEvent(void);

0 comments on commit 750bdf1

Please sign in to comment.