Hog mode questions
Hog mode questions
- Subject: Hog mode questions
- From: Kurt Revis <email@hidden>
- Date: Thu, 22 Nov 2001 08:26:54 -0800
Something that's unclear to me in the audio hardware API...
kAudioDevicePropertyHogMode = 'oink',
// An pid_t indicating the process ID that currently owns
// hog mode for the device or a -1 indicating that no process
// currently owns it. While a process owns hog mode for a device,
// no other process on the system can perform IO with the given
// device. When calling AudioDeviceSetProperty to acquire hog mode
// for a device, the value on input means nothing, but on output
// will contain the process ID of the owner of hog which should be
// the ID for the current process if the call is successful.
// The HAL uses the process IDs acquired from getpid().
So if the value that I pass in means nothing and is ignored, how would I
go about releasing hog mode after my process had acquired it? I would
expected that I could pass in -1 to give up the hog, or something.
Also: I thought I'd just try it and see... but I can't seem to acquire
hog mode at all. I am doing something like this:
{
OSStatus status;
AudioTimeStamp time;
UInt32 size;
pid_t owningPID;
AudioDeviceGetCurrentTime(deviceID, &time);
size = sizeof(owningPID);
owningPID = 0; // No need to set it to our PID, that is understood
status = AudioDeviceSetProperty(deviceID, &time, 0, false,
kAudioDevicePropertyHogMode, size, &owningPID);
// returns 0xe00002c7 == -536870201
}
The OSStatus returned by AudioDeviceSetProperty() is always -536870201,
which is a really weird looking error code. It's not in MacErrors.h, of
course, and it's not in AudioHardware.h either.
(I am using the default output device--the built-in outs on a G4
desktop. The device is running, and no other apps are playing any sound
while I'm trying this.)
Anybody have any ideas? I looked for examples of how to do this, but it
appears that hog mode is too new to have made it into the documentation
or any of the sample code.
Thanks!
--
Kurt Revis
email@hidden