summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_coreaudio_utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-05 21:47:04 +0200
committerwm4 <wm4@nowhere>2015-05-05 21:47:04 +0200
commit399267393bb96710cde53c2fc7563f55cc32deb8 (patch)
tree4421a331f0bc685ac29c942a057237048232882a /audio/out/ao_coreaudio_utils.c
parent7a5f5a8adf5921ed8fcee29d76113d9a7f018974 (diff)
downloadmpv-399267393bb96710cde53c2fc7563f55cc32deb8.tar.bz2
mpv-399267393bb96710cde53c2fc7563f55cc32deb8.tar.xz
ao_coreaudio_utils: don't require talloc for fourcc_repr()
Instead, apply a trick to make the caller allocate enough space on the stack.
Diffstat (limited to 'audio/out/ao_coreaudio_utils.c')
-rw-r--r--audio/out/ao_coreaudio_utils.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c
index 716f0df5e3..e8eccdc5d3 100644
--- a/audio/out/ao_coreaudio_utils.c
+++ b/audio/out/ao_coreaudio_utils.c
@@ -128,7 +128,7 @@ coreaudio_error:
return err;
}
-char *fourcc_repr(void *talloc_ctx, uint32_t code)
+char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code)
{
// Extract FourCC letters from the uint32_t and finde out if it's a valid
// code that is made of letters.
@@ -145,23 +145,19 @@ char *fourcc_repr(void *talloc_ctx, uint32_t code)
valid_fourcc = false;
}
- char *repr;
if (valid_fourcc)
- repr = talloc_asprintf(talloc_ctx, "'%c%c%c%c'",
- fcc[0], fcc[1], fcc[2], fcc[3]);
+ snprintf(buf, buf_size, "'%c%c%c%c'", fcc[0], fcc[1], fcc[2], fcc[3]);
else
- repr = talloc_asprintf(NULL, "%u", (unsigned int)code);
+ snprintf(buf, buf_size, "%u", (unsigned int)code);
- return repr;
+ return buf;
}
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message)
{
if (code == noErr) return true;
- char *error_string = fourcc_repr(NULL, code);
- mp_msg(ao->log, level, "%s (%s)\n", message, error_string);
- talloc_free(error_string);
+ mp_msg(ao->log, level, "%s (%s)\n", message, fourcc_repr(code));
return false;
}
@@ -245,7 +241,7 @@ void ca_print_asbd(struct ao *ao, const char *description,
const AudioStreamBasicDescription *asbd)
{
uint32_t flags = asbd->mFormatFlags;
- char *format = fourcc_repr(NULL, asbd->mFormatID);
+ char *format = fourcc_repr(asbd->mFormatID);
int mpfmt = ca_asbd_to_mp_format(asbd);
MP_VERBOSE(ao,
@@ -263,8 +259,6 @@ void ca_print_asbd(struct ao *ao, const char *description,
(flags & kAudioFormatFlagIsAlignedHigh) ? " aligned" : "",
(flags & kAudioFormatFlagIsNonInterleaved) ? " P" : "",
mpfmt ? af_fmt_to_str(mpfmt) : "unusable");
-
- talloc_free(format);
}
// Return whether new is an improvement over old. Assume a higher value means