• 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: HALOutputUnit (Pt 2)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HALOutputUnit (Pt 2)


  • Subject: Re: HALOutputUnit (Pt 2)
  • From: Aaron Eppolito <email@hidden>
  • Date: Thu, 26 Feb 2004 09:13:19 -0800

I left out a workaround for an existing bug. If you have a device that
has only INPUT (which includes some USB drivers for devices that show
up as two logical devices; one with only input and one with only output
[the emi 2|6 for example]) you need to insert the following:

// check output
UInt32 size = sizeof(int);
result = AudioUnitGetProperty(unit, kAudioOutputUnitProperty_HasIO,
kAudioUnitScope_Output, 0, &enable, &size);
THROW_RESULT("Couldn't check output");
if(enable == FALSE) {
// disable output if we don't have any output
result = AudioUnitSetProperty(unit,
kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &enable,
sizeof(enable));
THROW_RESULT("Couldn't disable output");
}

I'm not doing the exact code above because I have other reasons that I
disable the output, but the above should work. The bottom line is that
you need to check if a device has output, and if not, you need to
disable the output or else it will crash. You'll need to insert this
after step 4 (but before 11).

-Aaron

On Feb 26, 2004, at 4:50 AM, Craig Bakalian wrote:

> Hi,
> The only problem with code below is that it will crash if the default
> microphone
> is a USB microphone. Unless someone can tell me otherwise. Why does
> the code
> below crash with a _CurrentDevice on a USB microphone?
>
> On Feb 26, 2004, at 1:00 AM, email@hidden
> wrote:
>
>> Okay, here's a list of ALL the steps I take.
>> 1 - set the device sample rate:
>> AudioDeviceSetProperty(deviceID, 0, 0, true,
>> kAudioDevicePropertyNominalSampleRate, size, &rate)
>> 2 - open either a "graph and AUHAL node" or just a "AUHAL Audio Unit"
>> 3 - enable input:
>> AudioUnitSetProperty(unit, kAudioOutputUnitProperty_EnableIO,
>> kAudioUnitScope_Input, 1, ...)
>> 4 - set device:
>> AudioUnitSetProperty(unit, kAudioOutputUnitProperty_CurrentDevice,
>> kAudioUnitScope_Global, 1, deviceID, size);
>> 5 - get the inputScope inputBus ASBD:
>> AudioUnitGetProperty(unit, kAudioUnitProperty_StreamFormat,
>> kAudioUnitScope_Input, 1, &inASBD, &size);
>> 6 - get the outputScope inputBus ASBD: (you could also just create one
>> to be what you want)
>> AudioUnitGetProperty(unit, kAudioUnitProperty_StreamFormat,
>> kAudioUnitScope_Output, 1, &outASBD, &size);
>> 7 - adjust the outputScope inputBus ASBD to match the sample rate of
>> the input:
>> outASBD.mSampleRate = inASBD.mSampleRate;
>> 8 - set the outputScope inputBus ASBD:
>> AudioUnitSetProperty(unit, kAudioUnitProperty_StreamFormat,
>> kAudioUnitScope_Output, 1, &outASBD, size);
>> 9 - hook up the input callback:
>> AURenderCallbackStruct callback; callback.inputProc = foo;
>> callback.inputProcRefCon = this;
>> AudioUnitSetProperty(unit, kAudioUnitProperty_SetInputCallback,
>> global?, 1, callback, size);
>> 10 - alloc buffers
>> 11 - initialize AudioUnit or AUGraph (depending on if you used a graph
>> or not)
>> 12 - start graph or unit
>> 13 - in your callback, call:
>> AudioUnitRender(unit, 0, timestamp, 1, frames, bufferlist);
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: HALOutputUnit (Pt 2) (From: Craig Bakalian <email@hidden>)

  • Prev by Date: Re: HALOutputUnit (Pt 2)
  • Next by Date: Re: Changing the latency from within the render callback.
  • Previous by thread: Re: HALOutputUnit (Pt 2)
  • Next by thread: Changing the latency from within the render callback.
  • Index(es):
    • Date
    • Thread