• 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
Getting Failure from kAudioDevicePropertyBufferFrameSize
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting Failure from kAudioDevicePropertyBufferFrameSize


  • Subject: Getting Failure from kAudioDevicePropertyBufferFrameSize
  • From: Seth Willits <email@hidden>
  • Date: Tue, 15 Nov 2011 14:30:28 -0800



I'm opening the AudioOutputUnit and setting that up to write the audio out to a file. So one of the steps in that process (the last one below), is to get the number of frames in the audio buffers, using  a simple AudioUnitGetProperty, but for one particularly user of my code, doing so fails with the error kAudioUnitErr_InvalidProperty.

Any idea why? 

Is there another way I should be figuring out how big to make the AudioBufferList?




Code mostly in its entirety just incase it's something I did along the way:


// Open the AudioOutputUnit
description.componentType = kAudioUnitType_Output;
description.componentSubType = kAudioUnitSubType_HALOutput;
description.componentManufacturer = kAudioUnitManufacturer_Apple;
description.componentFlags = 0;
description.componentFlagsMask = 0;
if ((component = FindNextComponent(NULL, &description))) {
err = OpenAComponent(component, &mAudioOutputUnit);
...
}


// Enable input on the AUHAL
param = 1;
err = AudioUnitSetProperty(mAudioOutputUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &param, sizeof(UInt32));


// Disable Output on the AUHAL
param = 0;
err = AudioUnitSetProperty(mAudioOutputUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &param, sizeof(UInt32));


// Set the current device to the default input unit.
err = AudioUnitSetProperty(mAudioOutputUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &mInputDeviceID, sizeof(AudioDeviceID));


// Get the audio format of the input device
param = sizeof(AudioStreamBasicDescription);
err = AudioUnitGetProperty(mAudioOutputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &mDeviceFormat, &param);


// Set the format the AudioOutputUnit will output data in
...
err = AudioUnitSetProperty(mAudioOutputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &mOutputFormat, sizeof(AudioStreamBasicDescription));


// Get the number of frames in the IO buffer(s)
param = sizeof(UInt32);
err = AudioUnitGetProperty(mAudioOutputUnit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, &numFramesInBuffer, &param);

/********* FAILS WITH kAudioUnitErr_InvalidProperty *****/





I'm asking for the number of frames in the buffers because I use that to calculate how big the buffers that I allocate should be. (number of bytes per frame * number of frames in buffer). That comes straight out of the Apple sample code:
http://developer.apple.com/library/mac/#samplecode/RecordAudioToFile/Listings/DCAudioFileRecorder_cpp.html




--
Seth Willits



 _______________________________________________
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

  • Follow-Ups:
    • Re: Getting Failure from kAudioDevicePropertyBufferFrameSize
      • From: kamaldeep tumkur <email@hidden>
  • Prev by Date: Re: App using kext based on AudioReflectorDriver consumes more CPU with internal speakers
  • Next by Date: Re: kAudioHardwarePropertyDevices and USB weirdness
  • Previous by thread: AUSampler documentation dearth?
  • Next by thread: Re: Getting Failure from kAudioDevicePropertyBufferFrameSize
  • Index(es):
    • Date
    • Thread