Re: HALOutputUnit (Pt 2)
Re: HALOutputUnit (Pt 2)
- Subject: Re: HALOutputUnit (Pt 2)
- From: Bob Stuller <email@hidden>
- Date: Wed, 25 Feb 2004 21:20:46 -0500
Bill, Greetings!
At 12:14 PM -0800 2/25/04, William Stewart wrote:
The other thing to note after these steps, is that if you have a
mismatch between the device's available channels (lets say it has 10)
and what you want (lets say 2) - you can use the channel map property
to describe which channels of the device you want your data to go
to/from. This is true both for the input and output cases (and was
covered in my email and will be covered in the technote)... If you
don't set a channel map, then you basically go to/from the first 2
channels of the device (in the example above)
I do this (error-handling removed for clarity):
Boolean writable = false;
status = AudioUnitGetPropertyInfo(mHALOutInstance,
kAudioOutputUnitProperty_ChannelMap,
kAudioUnitScope_Output,
kDeviceInputElement,
&propertySize, &writable);
SignalIf_(writable == false);
long nChannels = propertySize / sizeof(SInt32);
long* channelMapPtr = (long*)malloc(propertySize);
UInt32 scratch = propertySize;
status = ::AudioUnitGetProperty(mHALOutInstance,
kAudioOutputUnitProperty_ChannelMap,
kAudioUnitScope_Output,
kDeviceInputElement,
channelMapPtr,
&scratch);
channelMapPtr[0] = 0;
for (long i = 1; i < nChannels; i++)
{
channelMapPtr[i] = -1;
}
status = AudioUnitSetProperty(mHALOutInstance,
kAudioOutputUnitProperty_ChannelMap,
kAudioUnitScope_Output,
kDeviceInputElement, channelMapPtr, sizeof(UInt32));
The question: Do I also do right if I conform the format that I am
setting on the AUHAL's (<<<= note conforming terminology!) output
scope (of the input bus/element)? That is, I do this & it works:
mInputDesc.description.mSampleRate = current.mSampleRate; //
input scope's SR, thanx, Aaron!
if (mInputDesc.description.mChannelsPerFrame != 1)
{
mInputDesc.description.mChannelsPerFrame = 1;
UInt32 sampleBytes = mInputDesc.description.mBitsPerChannel / 8;
mInputDesc.description.mBytesPerPacket = sampleBytes;
mInputDesc.description.mBytesPerFrame = sampleBytes;
}
Having done the channel map, is this redundant? Will it be
prohibited behavior some day?
The value of the flags should be zero thus:
AudioUnitRenderActionFlags flags = 0;
AudioUnitRender (unit, &flags, ×tamp, 1,
numFrames, bufferlist);
You have been warned :)
Question: I just pass the same pointer that the callback gets as a
parameter. Should I be sending in a pointer to zero? Will
AudioUnitRender ever use this pointer to give feedback on its
activities?
Thanks to all the CA for the great help that I got whilst getting this going.
Peace,
Bob
--
It's Great to be Green!
http://www.greenpartyus.org/
_______________________________________________
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.