• 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: Doug Wyatt <email@hidden>
  • Date: Mon, 23 Feb 2004 14:36:45 -0800

On Feb 23, 2004, at 14:21, Bob Stuller wrote:
> Doug, Greetings!
>
> At 2:00 PM -0800 2/23/04, Doug Wyatt wrote:
>> On Feb 23, 2004, at 12:49, Bob Stuller wrote:
>>>> What exactly is the stream format you are setting?
>>>
>>> I ask for the best match to this format:
>>> inputDesc.description.mSampleRate = foundRate; // 16000.0 if the
>>> device supports it.
>>> inputDesc.description.mFormatID = kAudioFormatLinearPCM;
>>> inputDesc.description.mFormatFlags = kLinearPCMFormatFlagIsBigEndian
>>> | kLinearPCMFormatFlagIsSignedInteger
>>> | kLinearPCMFormatFlagIsPacked
>>> | kLinearPCMFormatFlagIsNonInterleaved;
>>> inputDesc.description.mChannelsPerFrame = 1;
>>> inputDesc.description.mBitsPerChannel = 16;
>>> propertySize = sizeof(AudioStreamBasicDescription);
>>> status = AudioDeviceGetProperty(deviceIDs[i], 0, true,
>>> kAudioDevicePropertyStreamFormatMatch,
>>> &propertySize, &inputDesc.description);
>>>
>>> I get, typically:
>>> inputDesc.description.mSampleRate == 16000.0
>>> inputDesc.description.mFormatID == kAudioFormatLinearPCM
>>> inputDesc.description.mFormatFlags == kLinearPCMFormatFlagIsBigEndian
>>> | kAudioFormatFlagIsFloat
>>> | kLinearPCMFormatFlagIsPacked
>>> inputDesc.description.mChannelsPerFrame == 2
>>> inputDesc.description.mBitsPerChannel == 32
>>> which is what I pass in.
>>
>> I wonder if the kLinearPCMFormatFlagIsNonInterleaved is confusing the
>> HAL. Or if it's ignoring it. I could ask Jeff but first I'll ask you:
>>
>> What are inputDesc's mBytesPerPacket, mFramesPerPacket, and
>> mBytesPerFrame? Without the noninterleaved flag set, they should be
>> 4, 1, 4, respectively. With it set, and mChannelsPerFrame of 2, they
>> should be 8, 1, 8.
>
> The flag is not set & they are 8, 1, 8. That is in the 'matched'
> format. If I getProperty on the format from the device it's the same
> while, if I getProperty on the HALAU's format, the flag is set & those
> fields are 4, 1, 4.
>
> Hmmm... I'm going to skip setting the format of the device, just set
> the HALAU &, if that barfs, try it with the interleaved bit or'ed in
> there... Okay, both situations return
> 'kAudioDeviceUnsupportedFormatError'.

Hi Bob,

Aha!

I missed this in your earlier message. I should have noticed that you
were getting back a HAL error and not an AudioUnit error. AUHAL
delegates HAL properties to the HAL proper, and only interprets the
AudioUnit properties itself.

You want to be calling:

AudioUnitSetProperty(mHALOutInstance, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
kDeviceInputElement,
&mInputDesc.description,
sizeof(AudioStreamBasicDescription));

You can choose either interleaved or non-interleaved depending on
what's most convenient based on what you're doing with the incoming
data.

You can go back to attempting to set the device format if you like, --
in case you do happen to be working with an odd device that will
support a 16K sample rate, that will save you from doing a conversion
from the default sample rate (most likely 44.1) down to 16K.

Cheers,
Doug

--
Doug Wyatt
Core Audio, Apple
_______________________________________________
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.

  • Follow-Ups:
    • Re: HALOutputUnit (Pt 2)
      • From: Bob Stuller <email@hidden>
References: 
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Doug Wyatt <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Doug Wyatt <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)

  • Prev by Date: Re: HALOutputUnit (Pt 2)
  • Next by Date: Re: Is there any clock drift compensation mechanism in the HAL?
  • Previous by thread: Re: HALOutputUnit (Pt 2)
  • Next by thread: Re: HALOutputUnit (Pt 2)
  • Index(es):
    • Date
    • Thread