iOS: Issue when starting GKVoiceChat

0

I am encountering an issue with GKVoiceChat. The whole Audio setup is executed w/o errors, and I can successfully create the GKVoiceChat object with the GKMatch object. As soon as I start the voice chat using the "start" method on my voice chat object, the console prints

AURemoteIO::Initialize failed: 'init' (enable 3, outf< 1 ch,  16000 Hz, 'lpcm' (0x0000002C) 16-bit little-endian signed integer, deinterleaved> inf< 1 ch,  16000 Hz, 'lpcm' (0x0000000C) 16-bit little-endian signed integer>)

Google does not reveal anything useful on this error. Has anyone encountered this before and knows what is going wrong here? Behaves the same on an iPhone 4 and iPad 2.

Edit: Additional finding: I am also setting the AmbientSound property to respect the mute switch for other audio (music, sounds), and this seems to be the cause of the issue. When initializing audio service, I am also running this code:

SInt32 ambient = kAudioSessionCategory_SoloAmbientSound;
if (AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (ambient), &ambient)) {
    NSLog(@"Error setting ambient property");
}

When I comment this out, voice chat runs just fine. However then the mute switch is not respected any longer.

How can I have both?

Thanks, habitoti

iphone
ios
sdk
asked on Stack Overflow Jun 4, 2011 by habitoti • edited Jun 4, 2011 by habitoti

1 Answer

0

Right from documentation - iOS has 6 audio session categories out of that 3 affects the behavior of Slient switch:

AVAudioSessionCategoryAmbient or the equivalent kAudioSessionCategory_AmbientSound— Using this category, your audio is silenced by the Ring/Silent switch and when the screen locks. Used when we want our app audio with built-in app audio

AVAudioSessionCategorySoloAmbient or the equivalent kAudioSessionCategory_SoloAmbientSound—Use this category for an application whose audio you want silenced when the user switches the Ring/Silent switch to the “silent” position and when the screen locks. This is the default category

AVAudioSessionCategoryPlayback or the equivalent kAudioSessionCategory_MediaPlayback—Use this category for an application whose audio playback is of primary importance. Your audio plays even with the screen locked and with the Ring/Silent switch set to silent.

answered on Stack Overflow Apr 25, 2012 by indiantroy

User contributions licensed under CC BY-SA 3.0