CoreAudio: make sure audio stops playing when the device is muted.

The audio session's category was set to Playback, which implies that
audio is still audible even after setting the device to silent mode or
locking the screen. This shouldn't be the default behavior.
We now set it to Ambient, which preserves mixing with other apps
but makes sure sound is turned off when it should.

Task-number: QTBUG-39036
Change-Id: Ic36668d73f3179dc38b41023e380e15f8c8517e0
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Yoann Lopes
2014-05-21 13:40:42 +02:00
parent a7d10a265a
commit 2bc7a39a0d

View File

@@ -216,8 +216,9 @@ CoreAudioSessionManager::CoreAudioSessionManager() :
{
m_sessionObserver = [[CoreAudioSessionObserver alloc] initWithAudioSessionManager:this];
setActive(true);
//set default category to just Playback and only switch if we need more permissions
setCategory(CoreAudioSessionManager::Playback, CoreAudioSessionManager::MixWithOthers);
// Set default category to Ambient (implies MixWithOthers). This makes sure audio stops playing
// if the screen is locked or if the Silent switch is toggled.
setCategory(CoreAudioSessionManager::Ambient, CoreAudioSessionManager::None);
}
CoreAudioSessionManager::~CoreAudioSessionManager()