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

Commit a889504f authored by Zhou Song's avatar Zhou Song Committed by Gerrit - the friendly Code Review server
Browse files

hal: allow VOIP standby to enable correct device for subsequent usecases

When an MT call is received during a VOIP call, the VOIP could be standby
but not closed, since the standby is ignored, the VOIP use case is left with
active, ringtone will be played on the device of VOIP stream.
Allow putting the VOIP into standby state to release the VOIP use case when it's
not active. Then audio route for susequent usecases can be switched to the
expected device.

Change-Id: I735277d21dbdde7117eb7a4f765993e23cdea45c
CRs-Fixed: 1033873
parent d283740e
Loading
Loading
Loading
Loading
+16 −20
Original line number Diff line number Diff line
@@ -2340,13 +2340,6 @@ static int out_standby(struct audio_stream *stream)

    ALOGD("%s: enter: stream (%p) usecase(%d: %s)", __func__,
          stream, out->usecase, use_case_table[out->usecase]);
    if (out->usecase == USECASE_COMPRESS_VOIP_CALL) {
        /* Ignore standby in case of voip call because the voip output
         * stream is closed in adev_close_output_stream()
         */
        ALOGD("%s: Ignore Standby in VOIP call", __func__);
        return 0;
    }

    lock_output_stream(out);
    if (!out->standby) {
@@ -2358,7 +2351,13 @@ static int out_standby(struct audio_stream *stream)

        pthread_mutex_lock(&adev->lock);
        out->standby = true;
        if (!is_offload_usecase(out->usecase)) {
        if (out->usecase == USECASE_COMPRESS_VOIP_CALL) {
            voice_extn_compress_voip_close_output_stream(stream);
            pthread_mutex_unlock(&adev->lock);
            pthread_mutex_unlock(&out->lock);
            ALOGD("VOIP output entered standby");
            return 0;
        } else if (!is_offload_usecase(out->usecase)) {
            if (out->pcm) {
                pcm_close(out->pcm);
                out->pcm = NULL;
@@ -3230,14 +3229,6 @@ static int in_standby(struct audio_stream *stream)
    ALOGD("%s: enter: stream (%p) usecase(%d: %s)", __func__,
          stream, in->usecase, use_case_table[in->usecase]);

    if (in->usecase == USECASE_COMPRESS_VOIP_CALL) {
        /* Ignore standby in case of voip call because the voip input
         * stream is closed in adev_close_input_stream()
         */
        ALOGV("%s: Ignore Standby in VOIP call", __func__);
        return status;
    }

    lock_input_stream(in);
    if (!in->standby && in->is_st_session) {
        ALOGD("%s: sound trigger pcm stop lab", __func__);
@@ -3251,11 +3242,16 @@ static int in_standby(struct audio_stream *stream)

        pthread_mutex_lock(&adev->lock);
        in->standby = true;
        if (in->usecase == USECASE_COMPRESS_VOIP_CALL) {
            voice_extn_compress_voip_close_input_stream(stream);
            ALOGD("VOIP input entered standby");
        } else {
            if (in->pcm) {
                pcm_close(in->pcm);
                in->pcm = NULL;
            }
            status = stop_input_stream(in);
        }
        pthread_mutex_unlock(&adev->lock);
    }
    pthread_mutex_unlock(&in->lock);