Re: Mute System
Re: Mute System
- Subject: Re: Mute System
- From: Keith Duncan <email@hidden>
- Date: Wed, 12 Mar 2008 22:41:23 +0000
what i have to do to control the system Aduio Volume (mute,
increase, decrease).
I use CoreAudio; AppleScript is too inefficient for my uses.
static OSStatus GetDefaultAudioDevice(AudioDeviceID *device) {
OSStatus status;
UInt32 size;
size = sizeof(*device);
status =
AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&size, device);
return status;
}
- (void)setSystemVolume:(NSUInteger)volume {
OSStatus status;
AudioDeviceID device;
status = GetDefaultAudioDevice(&device);
require_noerr(status, ReturnStatus);
UInt32 size;
UInt32 channels[2];
size = sizeof(channels);
status = AudioDeviceGetProperty(device, 0, false,
kAudioDevicePropertyPreferredChannelsForStereo, &size, &channels);
require_noerr(status, ReturnStatus);
UInt32 mute = (volume == 0);
float systemVolume = volume/100.0;
for (NSUInteger index = 0; index < 2; index++) {
size = sizeof(mute);
status = AudioDeviceSetProperty(device, NULL, channels[index],
false, kAudioDevicePropertyMute, size, &mute);
require_noerr(status, ReturnStatus);
size = sizeof(systemVolume);
status = AudioDeviceSetProperty(device, NULL, channels[index],
false, kAudioDevicePropertyVolumeScalar, size, &systemVolume);
require_noerr(status, ReturnStatus);
}
ReturnStatus:
return;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Mute System (From: Herr Thomas Bartelmess <email@hidden>) |