From 9fee7077d483154e7c2ad9442d9e49bb5e7ad2bb Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 11 Jan 2016 20:25:00 +0100 Subject: ao_coreaudio: replace fourcc_repr() Replace with the more general mp_tag_str(). --- audio/out/ao_coreaudio.c | 8 ++++---- audio/out/ao_coreaudio_utils.c | 31 +++---------------------------- audio/out/ao_coreaudio_utils.h | 3 --- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index facbc601f6..471ab6d928 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -384,8 +384,8 @@ static int hotplug_init(struct ao *ao) err = AudioObjectAddPropertyListener( kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao); if (err != noErr) { - char *c1 = fourcc_repr(hotplug_properties[i]); - char *c2 = fourcc_repr(err); + char *c1 = mp_tag_str(hotplug_properties[i]); + char *c2 = mp_tag_str(err); MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2); goto coreaudio_error; } @@ -409,8 +409,8 @@ static void hotplug_uninit(struct ao *ao) err = AudioObjectRemovePropertyListener( kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao); if (err != noErr) { - char *c1 = fourcc_repr(hotplug_properties[i]); - char *c2 = fourcc_repr(err); + char *c1 = mp_tag_str(hotplug_properties[i]); + char *c2 = mp_tag_str(err); MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2); } } diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c index dff672e7d3..6b5d8a7195 100644 --- a/audio/out/ao_coreaudio_utils.c +++ b/audio/out/ao_coreaudio_utils.c @@ -136,36 +136,11 @@ coreaudio_error: return err; } -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. - unsigned char fcc[4] = { - (code >> 24) & 0xFF, - (code >> 16) & 0xFF, - (code >> 8) & 0xFF, - code & 0xFF, - }; - - bool valid_fourcc = true; - for (int i = 0; i < 4; i++) { - if (fcc[i] < 32 || fcc[i] >= 128) - valid_fourcc = false; - } - - if (valid_fourcc) - snprintf(buf, buf_size, "'%c%c%c%c'", fcc[0], fcc[1], fcc[2], fcc[3]); - else - snprintf(buf, buf_size, "%u", (unsigned int)code); - - return buf; -} - bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message) { if (code == noErr) return true; - mp_msg(ao->log, level, "%s (%s)\n", message, fourcc_repr(code)); + mp_msg(ao->log, level, "%s (%s)\n", message, mp_tag_str(code)); return false; } @@ -258,7 +233,7 @@ void ca_print_asbd(struct ao *ao, const char *description, const AudioStreamBasicDescription *asbd) { uint32_t flags = asbd->mFormatFlags; - char *format = fourcc_repr(asbd->mFormatID); + char *format = mp_tag_str(asbd->mFormatID); int mpfmt = ca_asbd_to_mp_format(asbd); MP_VERBOSE(ao, @@ -470,7 +445,7 @@ int64_t ca_get_device_latency_us(struct ao *ao, AudioDeviceID device) if (err == noErr) { latency_frames += temp; MP_VERBOSE(ao, "Latency property %s: %d frames\n", - fourcc_repr(latency_properties[n]), (int)temp); + mp_tag_str(latency_properties[n]), (int)temp); } } diff --git a/audio/out/ao_coreaudio_utils.h b/audio/out/ao_coreaudio_utils.h index a0b5aa002c..780c56864b 100644 --- a/audio/out/ao_coreaudio_utils.h +++ b/audio/out/ao_coreaudio_utils.h @@ -31,9 +31,6 @@ CFStringRef cfstr_from_cstr(char *str); char *cfstr_get_cstr(CFStringRef cfstr); -char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code); -#define fourcc_repr(code) fourcc_repr_buf((char[40]){0}, 40, code) - bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message); #define CHECK_CA_ERROR_L(label, message) \ -- cgit v1.2.3