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

Commit a9d11687 authored by kunleiz's avatar kunleiz Committed by Shiv Maliyappanahalli
Browse files

hal: Fix wrong output device for voip/music concurrent playback

If music stream is being played through speaker background during
voip call, and later when setForceUse is called with FORCE_NONE
during MODE_NORMAL, phone strategy routing will be switched to handset
device for primary output and this incidentally routes music stream to
handset from HAL side, while device in APM still keeps as speaker for
music. Then after primary output is stopped, it will restore the device
to speaker for music stream, while this routing call is ignored due to
same device on cur_output and output descriptor in APM::stopSource, and makes
music continues on handset.

Handle the restration from HAL side when device mismatch in APM and HAL.

CRs-Fixed: 2070874
Change-Id: I08529cbb148233452d6f8f3e2eed0f88c99dc573
parent 21ffaa86
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2766,6 +2766,8 @@ static int out_standby(struct audio_stream *stream)
{
    struct stream_out *out = (struct stream_out *)stream;
    struct audio_device *adev = out->dev;
    struct audio_usecase *uc_info;
    struct listnode *node;

    ALOGD("%s: enter: stream (%p) usecase(%d: %s)", __func__,
          stream, out->usecase, use_case_table[out->usecase]);
@@ -2804,6 +2806,13 @@ static int out_standby(struct audio_stream *stream)
            }
        }
        stop_output_stream(out);
        //restore output device for active usecase when current snd device and output device mismatch
        list_for_each(node, &adev->usecase_list) {
            uc_info = node_to_item(node, struct audio_usecase, list);
            if ((uc_info->type == PCM_PLAYBACK) &&
                (uc_info->out_snd_device != platform_get_output_snd_device(adev->platform, uc_info->stream.out)))
                select_devices(adev, uc_info->id);
        }
        pthread_mutex_unlock(&adev->lock);
    }
    pthread_mutex_unlock(&out->lock);