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

Commit a6cd66de authored by Yunfei Zhang's avatar Yunfei Zhang Committed by Gerrit - the friendly Code Review server
Browse files

hal: enable mono clips for incall music delivery

Currently ICMD output is set as stereo and do downmix to
mono when writing to driver, the speed of mono playback
will be doubled.

Do downmix for steteo clips only to fix it.

Change-Id: I654cad4348f2538e07b596ec7b00a5c8f53f537a
parent 7a2f2c06
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
@@ -748,8 +748,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);