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

Commit 5346b4a3 authored by kunleiz's avatar kunleiz Committed by Sharad Sangle
Browse files

hal: ensure correct device selection when native playback is atvice

When true native playback is active, output device still uses
SND_DEVICE_OUT_HEADPHONES to playback. This is due to
NATIVE_AUDIO_MODE_TRUE_44_1 mode is missed to add to get correct
output device.

Fix it by adding NATIVE_AUDIO_MODE_TRUE_44_1 mode to get correct
output device when true native playback is active. And backend
config is initialized if current snd device is none.

CRs-Fixed: 2310099
Change-Id: I601592768032a233b358545943861f9fe59220d3
parent 613f1d74
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -2434,6 +2434,10 @@ acdb_init_fail:
                strdup("RX_CDC_DMA_RX_0 Format");
            my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl =
                strdup("RX_CDC_DMA_RX_0 SampleRate");
            my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].bitwidth_mixer_ctl =
                strdup("RX_CDC_DMA_RX_0 Format");
            my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].samplerate_mixer_ctl =
                strdup("RX_CDC_DMA_RX_0 SampleRate");

            if (default_rx_backend)
                free(default_rx_backend);
@@ -2454,6 +2458,10 @@ acdb_init_fail:
                strdup("INT0_MI2S_RX Format");
            my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl =
                strdup("INT0_MI2S_RX SampleRate");
            my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].bitwidth_mixer_ctl =
                strdup("INT0_MI2S_RX Format");
            my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].samplerate_mixer_ctl =
                strdup("INT0_MI2S_RX SampleRate");

            if (default_rx_backend)
                free(default_rx_backend);
@@ -3988,6 +3996,9 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o
        } else if (NATIVE_AUDIO_MODE_SRC == na_mode &&
                   OUTPUT_SAMPLING_RATE_44100 == sample_rate) {
                snd_device = SND_DEVICE_OUT_HEADPHONES_44_1;
        } else if (NATIVE_AUDIO_MODE_TRUE_44_1 == na_mode &&
                   OUTPUT_SAMPLING_RATE_44100 == sample_rate) {
                snd_device = SND_DEVICE_OUT_HEADPHONES_44_1;
        } else if (NATIVE_AUDIO_MODE_MULTIPLE_44_1 == na_mode &&
                   (sample_rate % OUTPUT_SAMPLING_RATE_44100 == 0) &&
                   (out->format != AUDIO_FORMAT_DSD)) {
@@ -6318,6 +6329,13 @@ bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev,

    backend_idx = platform_get_backend_index(snd_device);

    //initialize backend config if current snd_device is SND_DEVICE_NONE
    if (usecase->out_snd_device == SND_DEVICE_NONE) {
        my_data->current_backend_cfg[backend_idx].sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
        my_data->current_backend_cfg[backend_idx].bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
        my_data->current_backend_cfg[backend_idx].channels = CODEC_BACKEND_DEFAULT_CHANNELS;
    }

    if (usecase->type == TRANSCODE_LOOPBACK) {
        backend_cfg.bit_width = usecase->stream.inout->out_config.bit_width;
        backend_cfg.sample_rate = usecase->stream.inout->out_config.sample_rate;