Search code examples
iosaudioavaudiosessionopenal

ios - music player stops as soon as I enter my app


I am tasked to finding why this app stops the Music Player on my ipod. Currently, in XCode, i have set breakpoints in the very first line of main(), and still, when i reach that line, the Music Player has already stopped.

I can imagine that any static constructor would have already run, but I've searched for the obvious culprits (any mention of AVAudioSession), and found nothing that had run before main().

Since the codebase is just huge, it would be a pain to blindly search for every constructor in every file, without knowing what I'm looking for. Can you tell me if there is any kind of XCode project property that stops external audio from playing, or anything that I could look for? Thanks

EDIT: I've narrowed it down a lot. First, for some reason, XCode seems to ignore most of my breakpoints which mislead me completely. It was indeed a static initialization of an object, which eventually leads to this call:

newDevice = alcOpenDevice(NULL);

For some reason, I can actually get a breakpoint here. Go figure... So, I have the music playing on this line, but not after I run it. It seems openal's initialization of the device shuts off all external music, for some reason... Trying to understand why, and how can i circumvent it...


Solution

  • Ok, I found out the problem. For some reason, XCode wasn't helping out. So I had set lots of breakpoints everywhere to see what would run before getting to main. This is where XCode failed me, because I knew the code was running, but for some reason, the breakpoints weren't being triggered. Also, for some reason, others did, so I still have that particular mistery to solve.

    Apart from that, the problem was initializing OpenAL just before AVAudioSession got configured with AVAudioSessionCategoryAmbient. After switching those two around, everything worked just fine.

    Thank you all for your help!