1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 14:50:07 +00:00

ao_coreaudio: switch properties getters to talloc

This commit is contained in:
Stefano Pigozzi 2013-07-15 08:39:55 +02:00
parent af6ad6717f
commit 7d58c51fd6
3 changed files with 19 additions and 18 deletions

View File

@ -215,16 +215,16 @@ static void print_help(void)
char *name; char *name;
OSStatus err = CA_GET_STR(devs[i], kAudioObjectPropertyName, &name); OSStatus err = CA_GET_STR(devs[i], kAudioObjectPropertyName, &name);
if (err == noErr) { if (err == noErr)
help = talloc_asprintf_append(help, talloc_steal(devs, name);
"%s (id: %" PRIu32 ")\n", name, devs[i]); else
free(name); name = "Unknown";
} else
help = talloc_asprintf_append(help, help = talloc_asprintf_append(
"Unknown (id: %" PRIu32 ")\n", devs[i]); help, "%s (id: %" PRIu32 ")\n", name, devs[i]);
} }
free(devs); talloc_free(devs);
coreaudio_error: coreaudio_error:
ca_msg(MSGL_FATAL, "%s", help); ca_msg(MSGL_FATAL, "%s", help);
@ -294,7 +294,7 @@ static int init(struct ao *ao, char *params)
"selected audio output device: %s (%" PRIu32 ")\n", "selected audio output device: %s (%" PRIu32 ")\n",
device_name, selected_device); device_name, selected_device);
free(device_name); talloc_free(device_name);
// Save selected device id // Save selected device id
p->device = selected_device; p->device = selected_device;
@ -318,7 +318,7 @@ static int init(struct ao *ao, char *params)
size_t n_bitmaps; size_t n_bitmaps;
ca_bitmaps_from_layouts(layouts, n_layouts, &bitmaps, &n_bitmaps); ca_bitmaps_from_layouts(layouts, n_layouts, &bitmaps, &n_bitmaps);
free(layouts); talloc_free(layouts);
struct mp_chmap_sel chmap_sel = {0}; struct mp_chmap_sel chmap_sel = {0};
@ -535,11 +535,11 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
else else
d->stream_asbd = formats[max_rate_format].mFormat; d->stream_asbd = formats[max_rate_format].mFormat;
free(formats); talloc_free(formats);
} }
} }
free(streams); talloc_free(streams);
if (d->stream_idx < 0) { if (d->stream_idx < 0) {
ca_msg(MSGL_WARN, "can't find any digital output stream format\n"); ca_msg(MSGL_WARN, "can't find any digital output stream format\n");

View File

@ -21,6 +21,7 @@
#include "audio/out/ao_coreaudio_properties.h" #include "audio/out/ao_coreaudio_properties.h"
#include "audio/out/ao_coreaudio_utils.h" #include "audio/out/ao_coreaudio_utils.h"
#include "talloc.h"
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector, OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
uint32_t size, void *data) uint32_t size, void *data)
@ -61,7 +62,7 @@ OSStatus ca_get_ary(AudioObjectID id, ca_scope scope, ca_sel selector,
err = AudioObjectGetPropertyDataSize(id, &p_addr, 0, NULL, &p_size); err = AudioObjectGetPropertyDataSize(id, &p_addr, 0, NULL, &p_size);
CHECK_CA_ERROR("can't fetch property size"); CHECK_CA_ERROR("can't fetch property size");
*data = malloc(p_size); *data = talloc_size(NULL, p_size);
*elements = p_size / element_size; *elements = p_size / element_size;
err = ca_get(id, scope, selector, p_size, *data); err = ca_get(id, scope, selector, p_size, *data);
@ -86,7 +87,7 @@ OSStatus ca_get_str(AudioObjectID id, ca_scope scope, ca_sel selector,
CFStringGetMaximumSizeForEncoding( CFStringGetMaximumSizeForEncoding(
CFStringGetLength(string), CA_CFSTR_ENCODING) + 1; CFStringGetLength(string), CA_CFSTR_ENCODING) + 1;
*data = malloc(size); *data = talloc_size(NULL, size);
CFStringGetCString(string, *data, size, CA_CFSTR_ENCODING); CFStringGetCString(string, *data, size, CA_CFSTR_ENCODING);
CFRelease(string); CFRelease(string);
coreaudio_error: coreaudio_error:

View File

@ -116,12 +116,12 @@ bool ca_stream_supports_digital(AudioStreamID stream)
AudioStreamBasicDescription asbd = formats[i].mFormat; AudioStreamBasicDescription asbd = formats[i].mFormat;
ca_print_asbd("supported format:", &(asbd)); ca_print_asbd("supported format:", &(asbd));
if (ca_format_is_digital(asbd)) { if (ca_format_is_digital(asbd)) {
free(formats); talloc_free(formats);
return true; return true;
} }
} }
free(formats); talloc_free(formats);
coreaudio_error: coreaudio_error:
return false; return false;
} }
@ -139,12 +139,12 @@ bool ca_device_supports_digital(AudioDeviceID device)
for (int i = 0; i < n_streams; i++) { for (int i = 0; i < n_streams; i++) {
if (ca_stream_supports_digital(streams[i])) { if (ca_stream_supports_digital(streams[i])) {
free(streams); talloc_free(streams);
return true; return true;
} }
} }
free(streams); talloc_free(streams);
coreaudio_error: coreaudio_error:
return false; return false;