Allow playing iPod music in the background of SDL applications.

You can always change your audio session category afterwards if you want custom behavior.
This commit is contained in:
Sam Lantinga 2012-11-01 19:08:12 -07:00
parent 9549fda7e0
commit 68ee3bad84
2 changed files with 11 additions and 1 deletions

View file

@ -538,8 +538,16 @@ COREAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->DetectDevices = COREAUDIO_DetectDevices;
#else
impl->OnlyHasDefaultOutputDevice = 1;
/* Set category to ambient sound so that other music continues playing.
You can change this at runtime in your own code if you need different
behavior. If this is common, we can add an SDL hint for this.
*/
AudioSessionInitialize(NULL, NULL, NULL, nil);
UInt32 category = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(UInt32), &category);
#endif
impl->ProvidesOwnCallbackThread = 1;
return 1; /* this audio target is available. */

View file

@ -35,6 +35,8 @@
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050
#include <AudioUnit/AUNTComponent.h>
#endif
#else
#include <AudioToolbox/AudioToolbox.h>
#endif
#include <AudioUnit/AudioUnit.h>