views:

556

answers:

6

I'm working on a couple different iphone apps that both record and play sounds concurrently. Think multitrack mixing... play one sound a save it then listen to that sound while recording the next sound to another file. My mechanism for this has been to start up two different audio queues, one for recording, and one for playing.

This was working A-OK until the release of OS 3.0... Since then, however, the following happens:

If I start the recording queue first, it supposedly starts fine, but the call to AudioQueueStart for the playback queue returns kAudioQueueErr_CannotStart.

If I start the playback queue first, it also supposedly starts fine, but the call to AudioQueueStart for the record queue returns the same error, kAudioQueueErr_CannotStart.

Anyone have any luck debugging this error? Seems like maybe the two queues are stomping on each other's memory or something? The official description is: "The audio queue has encountered a problem and cannot start." Not super helpful...

Jeremy

A: 

Maybe I'm wrong, however I have a feeling that only one (active?) audio queue can exist at a time.

You may need switch your output audio queue to an audio unit (Remote IO).
And AudioQueues are kind of lame for playback, so an audio unit couldn't hurt.

This guy managed to do it, and talks about it in this blog post.

Rhythmic Fistman
+3  A: 

It's kind of a cliche answer, but did you use the audio session API to set your audio category to "play and record"? You have to do this in order to reserve the microphone for your app's use. There were a bunch of changes to audio session in 3.0 (to create the obj-c convenience class AVAudioSession, and to define some new categories), so it's possible that changes there might be messing you up.

BTW, if you're not on the coreaudio-api list (lists.apple.com), you should be. The community and the Apple engineers there are really helpful.

invalidname
To be more specific:UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord; AudioSessionSetProperty ( kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), worked for me.
Paulius Liekis
A: 

Hi,

I also met same problem, any suggestions how to fix it. Thanks in advance :-)

taotao
A: 

Hi. Very actual problem. I need to make from iphone something like sound amplifier. I mean, need to record and play sounds in the realtime. Help me plz. Thanx a lot.

Artem
A: 

Anyone found solution of this issue. Please help if anyone found solution I am also found the same kind of problem.

Thanks in advance. :)

Surendra
A: 

Hi All,

This means we only need to create one session at a time and need to switch the input of user in out put using Audio Input output.

Surendra