• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
resetting session category behaviour under 3.x and 4.0
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

resetting session category behaviour under 3.x and 4.0


  • Subject: resetting session category behaviour under 3.x and 4.0
  • From: Wil Macaulay <email@hidden>
  • Date: Sat, 4 Sep 2010 23:36:21 -0400

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
 _______________________________________________
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

  • Prev by Date: Re: sample rate conversion
  • Next by Date: Re: resetting session category behaviour under 3.x and 4.0 - solved
  • Previous by thread: RE: sample rate conversion
  • Next by thread: Re: resetting session category behaviour under 3.x and 4.0 - solved
  • Index(es):
    • Date
    • Thread