문제

I'm having a problem with OpenAL that only seems to occur with iPod hardware, and the odd thing is that it was working fine, and now it's not.

I'm setting up the audio session:

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error: nil];
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, 
sizeof(UInt32), &audioRouteOverride);

AudioSessionSetActive(YES);

And initializing OpenAL:

device = alcOpenDevice(NULL);
if (!device) {
    NSLog(@"Could not open default OpenAL device.");
    return NO;
}

context = alcCreateContext(device, 0);
if (!context) {
    NSLog(@"Failed to create OpenAL context for default device.");
    return NO;
}

BOOL success = alcMakeContextCurrent(context);  // fails here
if (!success) {
    NSLog(@"Failed to set current OpenAL context.");
    return NO;

The output is:

AudioStreamBasicDescription:  2 ch,  44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
2010-10-27 10:51:09.261 FinchTestProject[239:307] Failed to set current OpenAL context.

So alcMakeContextCurrent function is returning false, and I'm not sure why. Audio is not really my expertise, and I can't find much information on this, so any help you guys can give me would be appreciated.

Thanks!

EDIT: I've found if I reverse the order of initialization- that is if I initialize OpenAL and then the AudioSession, it works... although this is the order I had it in before and it wasn't working, so something funny is definitely going on; also, it still doesn't work with older versions of iOS

도움이 되었습니까?

해결책

Reverse order of initialization seems to work ok, OpenAL then AudioSession

다른 팁

Just a wild guess:

The 1st generation iPod touch doesn't have a speaker. So perhaps you cannot override the audio route to a non-existent speaker.

Edit: Oh, and only the latest (4th gen) iPod touch has a microphone built in. All other generations require that the headphones (with microphone) be plugged in to record. Maybe that's why it stopped working all of sudden, the headphones were removed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top