Ed Marty
Ed Marty

Reputation: 39690

How can I blend audio from OpenAL with iPod music?

I'm using an audio engine I'm not too familiar with. It's an engine that came from an Apple example project (SoundEngine.cpp). It uses OpenAL to play sound effects and music, and nowhere do I see it initializing an audio session with AVAudioSessionCategorySoloAmbient or kAudioSessionCategory_SoloAmbientSound or any other categories.

What I want to do is allow the user's music to continue to play in the background, but I don't see anywhere where I can insert the line to set the category.

Essentially, the initialization code is:

mDevice = alcOpenDevice(NULL);
mContext = alcCreateContext(mDevice, NULL);
alcMakeContextCurrent(mContext);

and the third line is where the user's music fades out. There's nowhere that it even references audio sessions in the entire file. Any ideas?


Apparently, you can't. At least, not with the OS version I'm targeting. Not sure about later OS versions.

Upvotes: 0

Views: 828

Answers (1)

intepid
intepid

Reputation: 2222

Before your OpenAL setup, you need to init your audio session and set the appropriate flags:

AudioSessionInitialize(NULL, NULL, _callback, _userdata);

UInt32 category = kAudioSessionCategory_AmbientSound;

AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category);

You can find out more here, including info about handling interruptions.

Upvotes: 1

Related Questions