summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_coreaudio.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/out/ao_coreaudio.c')
-rw-r--r--audio/out/ao_coreaudio.c66
1 files changed, 26 insertions, 40 deletions
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c
index 84a5524496..48fc3a4779 100644
--- a/audio/out/ao_coreaudio.c
+++ b/audio/out/ao_coreaudio.c
@@ -202,21 +202,17 @@ static void print_help(void)
"Available output devices:\n");
AudioDeviceID *devs;
- uint32_t devs_size =
- GetGlobalAudioPropertyArray(kAudioObjectSystemObject,
- kAudioHardwarePropertyDevices,
- (void **)&devs);
- if (!devs_size) {
- ca_msg(MSGL_FATAL, "Failed to get list of output devices.\n");
- goto coreaudio_out;
- }
+ size_t n_devs;
+
+ OSStatus err =
+ CA_GET_ARY(kAudioObjectSystemObject, kAudioHardwarePropertyDevices,
+ &devs, &n_devs);
- int devs_n = devs_size / sizeof(AudioDeviceID);
+ CHECK_CA_ERROR("Failed to get list of output devices.");
- for (int i = 0; i < devs_n; i++) {
+ for (int i = 0; i < n_devs; i++) {
char *name;
- OSStatus err =
- GetAudioPropertyString(devs[i], kAudioObjectPropertyName, &name);
+ OSStatus err = CA_GET_STR(devs[i], kAudioObjectPropertyName, &name);
if (err == noErr) {
help = talloc_asprintf_append(help,
@@ -229,7 +225,7 @@ static void print_help(void)
free(devs);
-coreaudio_out:
+coreaudio_error:
ca_msg(MSGL_FATAL, "%s", help);
talloc_free(help);
}
@@ -290,10 +286,7 @@ static int init(struct ao *ao, char *params)
}
char *device_name;
- err = GetAudioPropertyString(selected_device,
- kAudioObjectPropertyName,
- &device_name);
-
+ err = CA_GET_STR(selected_device, kAudioObjectPropertyName, &device_name);
CHECK_CA_ERROR("could not get selected audio device name");
ca_msg(MSGL_V,
@@ -548,11 +541,10 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
struct priv *p = ao->priv;
struct priv_d *d = p->digital;
OSStatus err = noErr;
- uint32_t size;
uint32_t is_alive = 1;
err = CA_GET(p->device, kAudioDevicePropertyDeviceIsAlive, &is_alive);
- CHECK_CA_WARN( "could not check whether device is alive");
+ CHECK_CA_WARN("could not check whether device is alive");
if (!is_alive)
ca_msg(MSGL_WARN, "device is not alive\n");
@@ -565,44 +557,38 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
err = ca_disable_mixing(p->device, &d->changed_mixing);
CHECK_CA_WARN("failed to disable mixing");
- AudioStreamID *streams = NULL;
- /* Get a list of all the streams on this device. */
- size = GetAudioPropertyArray(p->device,
- kAudioDevicePropertyStreams,
- kAudioDevicePropertyScopeOutput,
- (void **)&streams);
+ AudioStreamID *streams;
+ size_t n_streams;
- if (!size) {
- ca_msg(MSGL_WARN, "could not get number of streams\n");
- goto coreaudio_error;
- }
+ /* Get a list of all the streams on this device. */
+ err = CA_GET_ARY_O(p->device, kAudioDevicePropertyStreams,
+ &streams, &n_streams);
- int streams_n = size / sizeof(AudioStreamID);
+ CHECK_CA_ERROR("could not get number of streams");
- for (int i = 0; i < streams_n && d->stream_idx < 0; i++) {
+ for (int i = 0; i < n_streams && d->stream_idx < 0; i++) {
bool digital = ca_stream_supports_digital(streams[i]);
if (digital) {
- /* Find a stream with a cac3 stream. */
- AudioStreamRangedDescription *formats = NULL;
- size = GetGlobalAudioPropertyArray(streams[i],
- kAudioStreamPropertyAvailablePhysicalFormats,
- (void **)&formats);
+ AudioStreamRangedDescription *formats;
+ size_t n_formats;
+
+ err = CA_GET_ARY(streams[i],
+ kAudioStreamPropertyAvailablePhysicalFormats,
+ &formats, &n_formats);
- if (!size) {
+ if (err != noErr) {
ca_msg(MSGL_WARN, "could not get number of stream formats\n");
continue; // try next one
}
- int formats_n = size / sizeof(AudioStreamRangedDescription);
- /* If this stream supports a digital (cac3) format, then set it. */
int req_rate_format = -1;
int max_rate_format = -1;
d->stream = streams[i];
d->stream_idx = i;
- for (int j = 0; j < formats_n; j++)
+ for (int j = 0; j < n_formats; j++)
if (ca_format_is_digital(formats[j].mFormat)) {
// select the digital format that has exactly the same
// samplerate. If an exact match cannot be found, select