Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68a8711e authored by Eric Laurent's avatar Eric Laurent Committed by Gerrit - the friendly Code Review server
Browse files

audio hal: report index channel masks for USB

Report only index channel masks for USB output profiles
supporting more than two channels.

Bug: 120947396
Test: play multichannel audio over USB
Change-Id: I10f6d4751a5a17674d24fb0d074f1dd6a71a06e1
(cherry picked from commit d01f3972959d9e2c22d35d15d0f55c6d9e088694)
parent 180e00bc
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -1845,14 +1845,31 @@ static inline int read_usb_sup_channel_masks(bool is_playback,
    channel_count = DEFAULT_CHANNEL_COUNT;

    if (is_playback) {
        // For playback we never report mono because the framework always outputs stereo
        // audio_channel_out_mask_from_count() does return positional masks for channel counts
        // above 2 but we want indexed masks here.
        supported_channel_masks[num_masks++] = audio_channel_out_mask_from_count(channel_count);
        // start from 2 channels as framework currently doesn't support mono.
        if (channels >= FCC_2) {
            supported_channel_masks[num_masks++] = audio_channel_out_mask_from_count(FCC_2);
        }
        for (channel_count = FCC_2;
                channel_count <= channels && num_masks < max_masks;
                ++channel_count) {
            supported_channel_masks[num_masks++] =
                    audio_channel_mask_for_index_assignment_from_count(channel_count);
        }
    } else {
        // audio_channel_in_mask_from_count() does the right conversion to either positional or
        // indexed mask
        supported_channel_masks[num_masks++] = audio_channel_in_mask_from_count(channel_count);
        for ( ; channel_count <= channels && num_masks < max_masks; channel_count++) {
            audio_channel_mask_t mask = AUDIO_CHANNEL_NONE;
            if (channel_count <= FCC_2) {
                mask = audio_channel_in_mask_from_count(channel_count);
                supported_channel_masks[num_masks++] = mask;
            }
            const audio_channel_mask_t index_mask =
                    audio_channel_mask_for_index_assignment_from_count(channel_count);
            if (mask != index_mask && num_masks < max_masks) { // ensure index mask added.
                supported_channel_masks[num_masks++] = index_mask;
            }
        }
    }

    for (channel_count = channels; ((channel_count >= DEFAULT_CHANNEL_COUNT) &&