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

Re: Getting Failure from kAudioDevicePropertyBufferFrameSize


  • Subject: Re: Getting Failure from kAudioDevicePropertyBufferFrameSize
  • From: kamaldeep tumkur <email@hidden>
  • Date: Thu, 17 Nov 2011 02:14:54 -0800



On Wed, Nov 16, 2011 at 11:58 AM, Seth Willits <email@hidden> wrote:
On Nov 16, 2011, at 7:52 AM, Kevin Vanwulpen wrote:

Are you on 10.6 or 10.7 ?

Yesterday I ran into the same and found on 10.7 for an input-only device I had to provide it input scope for kAudioDevicePropertyBufferFrameSize.

Global scope worked for the same device on 10.6 for me(same setup, just different boot partition 10.6 vs 10.7) 

I didn't try an output-only device to see if that requires output scope as this was something isolated I needed to do on my Mac and not production code.


The user is on 10.7.2. Are you suggesting the device I'm setting kAudioOutputUnitProperty_CurrentDevice to might be Input (or output) only? Or that the audio output unit is set to be input only and has output disabled?

The output unit is set to both I and O (the comment in the code which describes it being Disabled is a mistake).

And, the device I'm hooking the output unit up to is actually the Soundflower virtual device, which is both an Input and Output device, so unless somehow its output was disabled, it should be both enabled. — How would I check if it's output is disabled and that's the problem?

Maybe since I only care about the buffer frame size for the output I should be using kAudioUnitScope_Output instead of global?

I'm pretty new to Core Audio; I did just grab the rough cut of the new book that's coming out so hopefully I'll know what's going on not too long from now. ;)




On Nov 15, 2011, at 11:57 PM, kamaldeep tumkur wrote:

Have you tried querying using the AudioObjectPropertyAddress structure?
http://developer.apple.com/library/mac/#technotes/tn2223/_index.html


I haven't, but I don't think AudioUnitGet/SetProperty were included in that deprecation?



Your AudioUnitGetProperty call worked for me on 10.6.8.

So did the below snippet.

Addr.mSelector = kAudioDevicePropertyBufferFrameSize;
Addr.mScope = kAudioDevicePropertyScopeInput;
Addr.mElement = kAudioObjectPropertyElementMaster;

OSStatus Stat = AudioObjectGetPropertyDataSize((AudioObjectID) *audDevice, &Addr, 0, NULL, &streamSize);
if (Stat)
      return -1;
 
OSStatus Stat = AudioObjectGetPropertyData(*audDevice, &Addr, 0, NULL, &streamSize, &numAudioFrames);


Guess I am not very clear about using  AudioUnitGetProperty for an AudioDevice property as opposed to an AudioUnit property. Also since AudioObjectGetPropertyData takes in an AudioObjectID (and AudioDeviceID is typedef'ed as AudioObjectID), I assumed it was worth trying it.
Maybe a CoreAudio developer can enlighten on this.


 
--
Seth Willits





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




 _______________________________________________
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


 _______________________________________________
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

References: 
 >Getting Failure from kAudioDevicePropertyBufferFrameSize (From: Seth Willits <email@hidden>)
 >Re: Getting Failure from kAudioDevicePropertyBufferFrameSize (From: kamaldeep tumkur <email@hidden>)
 >Re: Getting Failure from kAudioDevicePropertyBufferFrameSize (From: Kevin Vanwulpen <email@hidden>)
 >Re: Getting Failure from kAudioDevicePropertyBufferFrameSize (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Getting Failure from kAudioDevicePropertyBufferFrameSize
  • Next by Date: Re: Varispeed ios
  • Previous by thread: Re: Getting Failure from kAudioDevicePropertyBufferFrameSize
  • Next by thread: Re: Getting Failure from kAudioDevicePropertyBufferFrameSize
  • Index(es):
    • Date
    • Thread