Re: resetting session category behaviour under 3.x and 4.0 - solved
Re: resetting session category behaviour under 3.x and 4.0 - solved
- Subject: Re: resetting session category behaviour under 3.x and 4.0 - solved
- From: Wil Macaulay <email@hidden>
- Date: Sun, 5 Sep 2010 13:04:12 -0400
It seems that before 4.0, I was able to create the augraph and enable
i/o on the microphone first, and then set the session category, and it
would work. Now it seems it is necessary to set an appropriate
session category first, before enabling the mic. It also seems to
have solved another issue with my code.
Thanks for being a rubber duck!
http://en.wikipedia.org/wiki/Rubber_duck_debugging
wil
On Sat, Sep 4, 2010 at 11:36 PM, Wil Macaulay <email@hidden> wrote:
> My application mostly does audio playback, with occasional recording
> from either headset or
> built-in microphone. I'm using remoteIO for input and output. I
> initialize the audio session as follows
>
> -(void)setupAudioSession{
> Float64 hardwareSampleRate = 44100.0;
> Float32 bufferDuration = 0.023220;
> OSErr error = AudioSessionInitialize(NULL, NULL, NULL, self);
> if (error) {
> DebugOut3(@"error in AudioSessionInitialize: %d
> %4.4s\n",(int)error,(char *)&error);
> }
>
> UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
> error = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
> sizeof(sessionCategory), &sessionCategory);
> if (error) {
> DebugOut3(@"error in AudioCategory: %d %4.4s\n",(int)error,(char *)&error);
> }
>
>
> error = AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareSampleRate,
> sizeof(hardwareSampleRate), &hardwareSampleRate);
> if (error) {
> NSLog(@"--%@: error: %d %4.4s\n",@"SampleRate",(int)error,(char *)&error);
> }
>
> error = AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration,
> sizeof(bufferDuration), &bufferDuration);
> if (error) {
> NSLog(@"--%@: error: %d
> %4.4s\n",@"IOBufferDuration",(int)error,(char *)&error);
> }
>
> error = AudioSessionSetActive(true);
> if (error) {
> DebugOut3(@"error: SetActive: %d %4.4s\n",(int)error,(char *)&error);
> }
>
> #ifdef __DEBUG__
> [self dumpAudioSessionInfo];
> #endif
> }
>
> Just before I record, I set the audio session category again (note
> that it makes no
> difference whether I use the Obj-C or C interfaces):
>
> -(void)setRecordAudioSession{
> AVAudioSession *session = [AVAudioSession sharedInstance];
> NSError *error = nil;
>
> [session setActive:NO error:&error];
> if (error){
> NSLog(@"error setting audio session active %@",error);
> }
>
> [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
> if (error){
> NSLog(@"error setting audio category %@",error);
> }
>
> [session setActive:YES error:&error];
> if (error){
> NSLog(@"error setting audio session active %@",error);
> }
> #ifdef __DEBUG__
> [self dumpAudioSessionInfo];
> #endif
> }
>
> Under 3.1 and 3.2, this works. My property change listener f properly
> shows the route change to headsetInOut, and my render proc and input
> proc both get invoked. All is good.
>
> Under 4.0, however, although the route changes properly and my
> renderproc gets invoked, my input proc never gets called. It all works
> if I
> set the category to AVAudioSessionCategoryPlayAndRecord at startup,
> but as soon as I ever reset it to AVAudioSessionCategoryPlayback it
> stops working.
>
> Am I missing something, is changing the session category in the middle
> of an app unsupported, or is this a bug in 4.0?
> thanks
> wil
> --
> Products and services: http://flagpig.com
> Blog: http://flagpig.tumblr.com
>
--
Products and services: http://flagpig.com
Blog: http://flagpig.tumblr.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden