Manage running applications on Mac OS X through Objective-C

Please tell objective-c code snippets and useful links about how I can control all output audio signals in OS X?

I think it should be something like a proxy level somewhere in the logical layers of OS X.

Thank!

+2
source share
1 answer

It is somewhat sad that there is no simple API for this. Fortunately, this is not too complicated, just verbose.

First get the system output device:

UInt32 size;
AudioDeviceID outputDevice;
OSStatus result = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOuputDevice, &size, &outputDevice);

Then set the volume:

Float32 theVolume;
result = AudioDeviceSetProperty(theDevice, NULL, 0, /* master channel */ false, kAudioDevicePropertyVolumeScalar, sizeof(Float32), &theVolume);

Obviously, I skipped error checking, which is mandatory.

, 0 ( ). (, ), : 1 2.

+4

All Articles