Re: Problems playing audio on a G5
Re: Problems playing audio on a G5
- Subject: Re: Problems playing audio on a G5
- From: Jeff Moore <email@hidden>
- Date: Mon, 2 Feb 2004 14:13:34 -0800
On Feb 2, 2004, at 1:37 PM, Dominic Mazzoni wrote:
Thanks, that could definitely be the solution!
Could you clarify a few things, though:
* I am able to reproduce this behavior immediately after a restart,
when
no apps other than the Finder are open. Any idea as to what
process might have started the IOProc? Is it the Finder, or a
system process? Is this consistent with what you would expect?
Yes. The format of the device is saved and restored across boot by the
HAL (a new feature of the Panther HAL). So, until you change it out of
that format, it will be stuck that way.
* I understand that in order to change the format of the device, I
need to take hog mode. This makes sense.
* I'm not sure what you mean by "turning mixing back on" - is this
one of the audio device properties? What are the reasons for or
against turning on mixing? Or does switching to floating-point
linear PCM automatically turn on mixing?
One turns mixing on and off using kAudioDevicePropertySupportsMixing.
* Once I've changed the device properties, can I release hog mode?
Or would it be better to keep it for best performance?
I'd release it once you are done with it. Hog mode is really there for
the non-mixable formats and for devices that require that they only be
used by one process at a time. There really won't be much in the way of
performance to gain, since most other apps will switch to some other
device to do their IO when they realize that you are hogging the one
they want to use.
Here's the order of operations I would use:
1) Acquire hog mode for the device.
2) Iterate through all the streams of the device and use
kAudioStreamPropertyPhysicalFormat to set them back to the linear PCM
format you prefer. Note at this point mixing will still be turned off.
3) Turn mixing back on for the whole device using
kAudioDevicePropertySupportsMixing.
Again, I realize that this is a bit of a hassle. I have a bug to make
it easier. It's kind of funny that someone asked about the enum
constant, kAudioFormatFlagIsNonMixable, in CoreAudio/CoreAudioTypes.h.
That constant escaped early from some of the work I've been doing in
this area.
Thanks very much,
Dominic
Jeff Moore wrote:
Once a device in in a non-mixable format, it will get hogged by the
first process to start an IOProc on it. So, you can only change it to
a non-mixable again by first taking hog mode and then changing the
format first to a linear PCM and then turning mixing back on.
I have a bug about making this a bit more straight forward.
On Jan 30, 2004, at 8:58 PM, Dominic Mazzoni wrote:
I'm having trouble getting audio output to work on a Power Mac G5.
The problem seems to be that by default the built-in audio device
is in digital mode - see these screenshots of the Audio MIDI
Setup application:
http://spaghetticode.org/G5/
When I query the stream format from a C program, here's what I get:
mFormatID = cac3
mFormatFlags = 0x1e
mChannelsPerFrame = 2
mBytesPerPacket = 6144
mFramesPerPacket = 1536
mBytesPerFrame = 0
mChannelsPerFrame = 2
mBitsPerChannel = 16
mReserved = 0
This appears to be some sort of compressed format.
What I would like is to be able to write to a stream in some sort
of Linear PCM mode.
However, setting the stream format using AudioDeviceSetProperty
with a selector of kAudioDevicePropertyStreamFormat fails! Even
if I use one of the stream formats that is returned as one of the
device's supported formats, it still fails.
I'm particularly surprised that it fails because iTunes appears
to (temporarily?) set the device into linear PCM mode, so I know
it must be possible from a userlevel application. Can anyone think
of anything I might be doing wrong?
I also tried to create an AudioConverter to go between floating-point
samples and cac3 and that also failed.
Depending on exactly how I make the call, I either get '!dat'
or '?fmt' as the error message, from either AudioDeviceSetProperty
or AudioConverterNew.
I'm stuck - anyone know what to try from here?
FYI, the code I'm working with is the CoreAudio port of PortAudio
(v18-patch from CVS), which seems to work on just about every
other Mac I've seen. See www.portaudio.com for details.
Thanks,
Dominic
--
Jeff Moore
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.