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

Commit f465a627 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: enable mono clips for incall music delivery"

parents 076fa62c a6cd66de
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -5680,7 +5680,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
                int16_t *src = (int16_t *)buffer;
                int16_t *dst = (int16_t *)buffer;

                LOG_ALWAYS_FATAL_IF(out->config.channels != 1 || channel_count != 2 ||
                LOG_ALWAYS_FATAL_IF(channel_count > 2 ||
                                    out->format != AUDIO_FORMAT_PCM_16_BIT,
                                    "out_write called for %s use case with wrong properties",
                                    use_case_table[out->usecase]);
@@ -5694,12 +5694,13 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
                 * Code below goes over each frame in the buffer and adds both
                 * L and R samples and then divides by 2 to convert to mono
                 */
                if (channel_count == 2) {
                    for (size_t i = 0; i < frames ; i++, dst++, src += 2) {
                        *dst = (int16_t)(((int32_t)src[0] + (int32_t)src[1]) >> 1);
                    }
                    bytes_to_write /= 2;
                }

            }
            ALOGVV("%s: writing buffer (%zu bytes) to pcm device", __func__, bytes);

            long ns = 0;
+2 −2
Original line number Diff line number Diff line
@@ -747,8 +747,8 @@ int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,

        out->config = pcm_config_incall_music;
        //FIXME: add support for MONO stream configuration when audioflinger mixer supports it
        out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
        out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
        out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_MONO;
        out->supported_channel_masks[1] = AUDIO_CHANNEL_OUT_STEREO;
        out->config.rate = out->sample_rate;

        ALOGV("%s: mode=%d, usecase id=%d", __func__, adev->mode, out->usecase);