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;
OSStatus err = CA_GET_STR(devs[i], kAudioObjectPropertyName, &name);
if (err == noErr) {
help = talloc_asprintf_append(help,
"%s (id: %" PRIu32 ")\n", name, devs[i]);
free(name);
} else
help = talloc_asprintf_append(help,
"Unknown (id: %" PRIu32 ")\n", devs[i]);
if (err == noErr)
talloc_steal(devs, name);
else
name = "Unknown";
help = talloc_asprintf_append(
help, "%s (id: %" PRIu32 ")\n", name, devs[i]);
}
free(devs);
talloc_free(devs);
coreaudio_error:
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",
device_name, selected_device);
free(device_name);
talloc_free(device_name);
// Save selected device id
p->device = selected_device;
@ -318,7 +318,7 @@ static int init(struct ao *ao, char *params)
size_t n_bitmaps;
ca_bitmaps_from_layouts(layouts, n_layouts, &bitmaps, &n_bitmaps);
free(layouts);
talloc_free(layouts);
struct mp_chmap_sel chmap_sel = {0};
@ -535,11 +535,11 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
else
d->stream_asbd = formats[max_rate_format].mFormat;
free(formats);
talloc_free(formats);
}
}
free(streams);
talloc_free(streams);
if (d->stream_idx < 0) {
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_utils.h"
#include "talloc.h"
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
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);
CHECK_CA_ERROR("can't fetch property size");
*data = malloc(p_size);
*data = talloc_size(NULL, p_size);
*elements = p_size / element_size;
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(
CFStringGetLength(string), CA_CFSTR_ENCODING) + 1;
*data = malloc(size);
*data = talloc_size(NULL, size);
CFStringGetCString(string, *data, size, CA_CFSTR_ENCODING);
CFRelease(string);
coreaudio_error:

View File

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