aboutsummaryrefslogtreecommitdiffstats
path: root/system_alert_volume.c
diff options
context:
space:
mode:
authorTeddy Wing2022-10-25 01:33:03 +0200
committerTeddy Wing2022-10-25 01:33:03 +0200
commit72f2271a0a02b857e4654bd742dcedbfdd1a2d10 (patch)
tree1eaa97afd32035f14b77a41561d536332bb51fd1 /system_alert_volume.c
parentcdf455726b34de60604f3ad7f94ca255b50e358d (diff)
downloadSSVLSystemAlertVolume-72f2271a0a02b857e4654bd742dcedbfdd1a2d10.tar.bz2
Rename "system_alert_volume.c" to "SSVLSystemAlertVolume.c"
Align with the new identifier naming.
Diffstat (limited to 'system_alert_volume.c')
-rw-r--r--system_alert_volume.c62
1 files changed, 0 insertions, 62 deletions
diff --git a/system_alert_volume.c b/system_alert_volume.c
deleted file mode 100644
index a795568..0000000
--- a/system_alert_volume.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <AudioToolbox/AudioToolbox.h>
-
-const AudioServicesPropertyID SSVLAudioServicesPropertySystemAlertVolume = 'ssvl';
-
-OSStatus SSVLGetSystemVolume(Float32 *volume) {
- UInt32 volume_size = sizeof(*volume);
-
- OSStatus result = AudioServicesGetProperty(
- kAudioServicesPropertySystemAlertVolume,
- 0,
- NULL,
- &volume_size,
- volume
- );
-
- // TODO: Sound PrefPane: If result != noErr, return 0.5?
-
- if (*volume != 0) {
- *volume = log(*volume) + 1.0;
- }
- else {
- *volume = 0;
- }
-
- return result;
-}
-
-OSStatus SSVLSetSystemVolume(Float32 volume) {
- volume = exp(volume - 1.0);
-
- return AudioServicesSetProperty(
- kAudioServicesPropertySystemAlertVolume,
- 0,
- NULL,
- sizeof(volume),
- &volume
- );
-}
-
-int main() {
- OSStatus result;
-
- Float32 volume;
-
- result = system_volume_get(&volume);
- if (result != noErr) {
- printf("Error getting system volume: %d\n", result);
- return 1;
- }
-
- printf("System volume: %f\n", volume);
-
-
- Float32 new_volume = 0.5;
- result = system_volume_set(new_volume);
- if (result != noErr) {
- printf("Error setting system volume: %d\n", result);
- return 1;
- }
-
- printf("Set volume to: %f\n", new_volume);
-}