#include "CoreAudioAEStream.h"
#include "CoreAudioAESound.h"
+#include "CoreAudioHardware.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#include "settings/GUISettings.h"
#include "settings/Settings.h"
m_streamsPlaying (false ),
m_isSuspended (false ),
m_softSuspend (false ),
- m_softSuspendTimer (0 )
+ m_softSuspendTimer (0 ),
+ m_currentAudioDevice (0 )
{
HAL = new CCoreAudioAEHAL;
}
(*itt)->Initialize();
streamLock.Leave();
}
+
+ if (m_Initialized)
+ {
+ m_currentAudioDevice = CCoreAudioHardware::FindAudioDevice(m_outputDevice);
+ }
return m_Initialized;
}
IAEStream* CCoreAudioAE::MakeStream(enum AEDataFormat dataFormat,
unsigned int sampleRate, unsigned int encodedSamplerate, CAEChannelInfo channelLayout, unsigned int options)
{
+ bool defaultDeviceChanged = false;
// if we are suspended we don't
// want anyone to mess with us
if (m_isSuspended && !m_softSuspend)
m_streams.push_back(stream);
streamLock.Leave();
+ // check if default device has changed - in that case we need to reinit
+ // TODO hook into osx callbacks for getting notifiaction on device
+ // changes and then queue a change of the default device
+ // to a point where engine is idle.
+ std::string outputDevice = g_guiSettings.GetString("audiooutput.audiodevice");
+ if (outputDevice.compare("CoreAudio:default") == 0)
+ {
+ AudioDeviceID currentId = CCoreAudioHardware::FindAudioDevice("default");
+ if (currentId != m_currentAudioDevice)
+ defaultDeviceChanged = true;
+ }
+
if ((options & AESTREAM_PAUSED) == 0)
Stop();
if (m_Initialized && ( m_lastStreamFormat != dataFormat ||
m_lastChLayoutCount != channelLayout.Count() ||
m_lastSampleRate != sampleRate ||
- COREAUDIO_IS_RAW(dataFormat)))
+ COREAUDIO_IS_RAW(dataFormat) ||
+ defaultDeviceChanged))
{
CSingleLock engineLock(m_engineLock);
Stop();