macos: use newer audio API for 10.11.
This commit is contained in:
parent
d7523502fe
commit
11832c587a
|
@ -13,9 +13,6 @@ This can be used with pipes by other processes to
|
|||
query the hardware. Or just to display a status
|
||||
line in screen or tmux or some Xorg program.
|
||||
|
||||
If I'd thought more about it I'd have made it modular, so
|
||||
apologies for the crust!
|
||||
|
||||
Install:
|
||||
make (or gmake)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ HAVE_ALSA := $(shell if [ $(ALSA_TEST) -eq 0 ]; then echo "true"; else echo "fal
|
|||
UNAME := $(shell uname -s)
|
||||
|
||||
ifeq ($(UNAME),Darwin)
|
||||
CFLAGS += -framework AudioToolBox
|
||||
CFLAGS += -framework CoreAudio
|
||||
else ifeq ($(UNAME),Linux)
|
||||
ifeq ($(HAVE_ALSA),true)
|
||||
CFLAGS += -lasound -DHAVE_ALSA=1
|
||||
|
|
|
@ -182,7 +182,7 @@ Fcontents(const char *path)
|
|||
int n = 1024;
|
||||
|
||||
buf = malloc(n * sizeof(byte) + 1);
|
||||
if (!buf) exit(0 << 1);
|
||||
if (!buf) return NULL;
|
||||
|
||||
while ((count = (fread(byte, sizeof(byte), 1, f))) > 0)
|
||||
{
|
||||
|
@ -191,13 +191,13 @@ Fcontents(const char *path)
|
|||
{
|
||||
n *= 2;
|
||||
char *tmp = realloc(buf, n * sizeof(byte) + 1);
|
||||
if (!tmp) exit(1 << 1);
|
||||
if (!tmp) return NULL;
|
||||
buf = tmp;
|
||||
}
|
||||
memcpy(&buf[bytes - sizeof(byte)], byte, sizeof(byte));
|
||||
}
|
||||
|
||||
if (!feof(f)) exit(2 << 1);
|
||||
if (!feof(f)) return NULL;
|
||||
fclose(f);
|
||||
|
||||
buf[bytes] = 0;
|
||||
|
@ -848,14 +848,14 @@ out:
|
|||
prop.mScope = kAudioObjectPropertyScopeGlobal;
|
||||
prop.mElement = kAudioObjectPropertyElementMaster;
|
||||
|
||||
if (AudioHardwareServiceGetPropertyData(kAudioObjectSystemObject, &prop, 0, NULL, &id_size, &id))
|
||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, NULL, &id_size, &id))
|
||||
return (0);
|
||||
|
||||
prop.mSelector = kAudioDevicePropertyVolumeScalar;
|
||||
prop.mScope = kAudioDevicePropertyScopeOutput;
|
||||
prop.mElement = 0;
|
||||
|
||||
if (AudioHardwareServiceGetPropertyData(id, &prop, 0, NULL, &vol_size, &volume))
|
||||
if (AudioObjectGetPropertyData(id, &prop, 0, NULL, &vol_size, &volume))
|
||||
return (0);
|
||||
|
||||
mixer->volume_left = mixer->volume_right = volume * 100;
|
||||
|
|
Loading…
Reference in New Issue