From 4f5f034ba2556fdbd3247922694da01576f4f9cd Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 2 Jul 2014 19:34:16 +0200 Subject: ao_coreaudio: move channel mapping away from utils Channel mapping functions are only used in the AUHAL based coreaudio, so move them there. --- audio/out/ao_coreaudio_utils.c | 123 ----------------------------------------- 1 file changed, 123 deletions(-) (limited to 'audio/out/ao_coreaudio_utils.c') diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c index 235e7fba42..da06656e9d 100644 --- a/audio/out/ao_coreaudio_utils.c +++ b/audio/out/ao_coreaudio_utils.c @@ -175,126 +175,3 @@ void ca_print_asbd(struct ao *ao, const char *description, talloc_free(format); } -static const int speaker_map[][2] = { - { kAudioChannelLabel_Left, MP_SPEAKER_ID_FL }, - { kAudioChannelLabel_Right, MP_SPEAKER_ID_FR }, - { kAudioChannelLabel_Center, MP_SPEAKER_ID_FC }, - { kAudioChannelLabel_LFEScreen, MP_SPEAKER_ID_LFE }, - { kAudioChannelLabel_LeftSurround, MP_SPEAKER_ID_BL }, - { kAudioChannelLabel_RightSurround, MP_SPEAKER_ID_BR }, - { kAudioChannelLabel_LeftCenter, MP_SPEAKER_ID_FLC }, - { kAudioChannelLabel_RightCenter, MP_SPEAKER_ID_FRC }, - { kAudioChannelLabel_CenterSurround, MP_SPEAKER_ID_BC }, - { kAudioChannelLabel_LeftSurroundDirect, MP_SPEAKER_ID_SL }, - { kAudioChannelLabel_RightSurroundDirect, MP_SPEAKER_ID_SR }, - { kAudioChannelLabel_TopCenterSurround, MP_SPEAKER_ID_TC }, - { kAudioChannelLabel_VerticalHeightLeft, MP_SPEAKER_ID_TFL }, - { kAudioChannelLabel_VerticalHeightCenter, MP_SPEAKER_ID_TFC }, - { kAudioChannelLabel_VerticalHeightRight, MP_SPEAKER_ID_TFR }, - { kAudioChannelLabel_TopBackLeft, MP_SPEAKER_ID_TBL }, - { kAudioChannelLabel_TopBackCenter, MP_SPEAKER_ID_TBC }, - { kAudioChannelLabel_TopBackRight, MP_SPEAKER_ID_TBR }, - - // unofficial extensions - { kAudioChannelLabel_RearSurroundLeft, MP_SPEAKER_ID_SDL }, - { kAudioChannelLabel_RearSurroundRight, MP_SPEAKER_ID_SDR }, - { kAudioChannelLabel_LeftWide, MP_SPEAKER_ID_WL }, - { kAudioChannelLabel_RightWide, MP_SPEAKER_ID_WR }, - { kAudioChannelLabel_LFE2, MP_SPEAKER_ID_LFE2 }, - - { kAudioChannelLabel_HeadphonesLeft, MP_SPEAKER_ID_DL }, - { kAudioChannelLabel_HeadphonesRight, MP_SPEAKER_ID_DR }, - - { kAudioChannelLabel_Unknown, -1 }, -}; - -static int ca_label_to_mp_speaker_id(AudioChannelLabel label) -{ - for (int i = 0; speaker_map[i][1] >= 0; i++) - if (speaker_map[i][0] == label) - return speaker_map[i][1]; - return -1; -} - -static void ca_log_layout(struct ao *ao, AudioChannelLayout *layout) -{ - if (!mp_msg_test(ao->log, MSGL_V)) - return; - - AudioChannelDescription *descs = layout->mChannelDescriptions; - - MP_VERBOSE(ao, "layout: tag: <%d>, bitmap: <%d>, " - "descriptions <%d>\n", - layout->mChannelLayoutTag, - layout->mChannelBitmap, - layout->mNumberChannelDescriptions); - - for (int i = 0; i < layout->mNumberChannelDescriptions; i++) { - AudioChannelDescription d = descs[i]; - MP_VERBOSE(ao, " - description %d: label <%d, %d>, flags: <%u>, " - "coords: <%f, %f, %f>\n", i, - d.mChannelLabel, - ca_label_to_mp_speaker_id(d.mChannelLabel), - d.mChannelFlags, - d.mCoordinates[0], - d.mCoordinates[1], - d.mCoordinates[2]); - } -} - -bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout, - struct mp_chmap *chmap) -{ - AudioChannelLayoutTag tag = layout->mChannelLayoutTag; - uint32_t layout_size = sizeof(layout); - OSStatus err; - - if (tag == kAudioChannelLayoutTag_UseChannelBitmap) { - err = AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutForBitmap, - sizeof(uint32_t), - &layout->mChannelBitmap, - &layout_size, - layout); - CHECK_CA_ERROR("failed to convert channel bitmap to descriptions"); - } else if (tag != kAudioChannelLayoutTag_UseChannelDescriptions) { - err = AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutForTag, - sizeof(AudioChannelLayoutTag), - &layout->mChannelLayoutTag, - &layout_size, - layout); - CHECK_CA_ERROR("failed to convert channel tag to descriptions"); - } - - ca_log_layout(ao, layout); - - // If the channel layout uses channel descriptions, from my - // experiments there are there three possibile cases: - // * The description has a label kAudioChannelLabel_Unknown: - // Can't do anything about this (looks like non surround - // layouts are like this). - // * The description uses positional information: this in - // theory could be used but one would have to map spatial - // positions to labels which is not really feasible. - // * The description has a well known label which can be mapped - // to the waveextensible definition: this is the kind of - // descriptions we process here. - - for (int n = 0; n < layout->mNumberChannelDescriptions; n++) { - AudioChannelLabel label = layout->mChannelDescriptions[n].mChannelLabel; - uint8_t speaker = ca_label_to_mp_speaker_id(label); - if (label == kAudioChannelLabel_Unknown) - continue; - if (speaker < 0) { - MP_VERBOSE(ao, "channel label=%d unusable to build channel " - "bitmap, skipping layout\n", label); - } else { - chmap->speaker[n] = speaker; - chmap->num = n + 1; - } - } - - return chmap->num > 0; -coreaudio_error: - ca_log_layout(ao, layout); - return false; -} -- cgit v1.2.3