In my iOS Application , i am using AudioQueue for Audio recording and playback, basically i have OSX Version running and porting it on iOS.
I realize in iOS I need to configure / set the AV Session and i have done following till now,
-(void)initAudioSession{
//get your app's audioSession singleton object
AVAudioSession* session = [AVAudioSession sharedInstance];
//error handling
BOOL success;
NSError* error;
//set the audioSession category.
//Needs to be Record or PlayAndRecord to use audioRouteOverride:
success = [session setCategory:AVAudioSessionCategoryPlayAndRecord
error:&error];
if (!success) NSLog(@"AVAudioSession error setting category:%@",error);
//set the audioSession override
success = [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker
error:&error];
if (!success) NSLog(@"AVAudioSession error overrideOutputAudioPort:%@",error);
//activate the audio session
success = [session setActive:YES error:&error];
if (!success) NSLog(@"AVAudioSession error activating: %@",error);
else NSLog(@"audioSession active");
}
Now what is happening is, Speaker AudioQueue callback is never getting called, i checked many answers, comments on so , google etc... and looks to be correct , the way i did is
- Create AudioQueue for input and output : Configuration Linear PCM , 16000 Sampling rate
- Allocate buffer
- Setup queue with valid callback,
- Start Queue,
It seems to be fine, i can able to hear Output on other end ( i.e. Input AudioQueue is working ) but output AudioQueue ( i.e. AudioQueueOutputCallback is never getting called).
I am suspecting i need to set the Proper AVSessionCatogery that i am trying with all possible option but didn't able to hear anything in the speaker,
I Compare my Implementation with Apple example Speakhere running AudioQueue on the main thread.
Even if i don't start Input AudioQueue ( mic ) then also i same behavior. and its difficult to have Speakhere behavior i.e. stop record and play
Thanks for looking at it, expecting your comments/help. Will be able to share code snippet.