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

Commit 6cbe136e authored by Lakshman Chaluvaraju's avatar Lakshman Chaluvaraju
Browse files

a2dp : pcm prepare fail for input during a2dp suspend and reconfig

Start input is failing due to race condition in a2dp suspend
and a2dp connection/disconnection. If a2dp suspend params are
and then a2dp disconnection comes, reseting the suspended
flag can cause a2dp_is_ready function return invalid value
during start input and hence pcm prepare fails.
Avoid setting a2dp suspend state to false if sco is still on.

Change-Id: I83950ddd0d4d3bbe6f30846cba48f6eb88c14690
parent 2cc132a7
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -992,6 +992,8 @@ static void open_a2dp_source() {
                ALOGE("Failed to open source stream for a2dp: status %d", ret);
            }
            a2dp.bt_state_source = A2DP_STATE_CONNECTED;
            if (!a2dp.adev->bt_sco_on)
                a2dp.a2dp_source_suspended = false;
        } else {
            ALOGD("Called a2dp open with improper state %d", a2dp.bt_state_source);
        }
@@ -1088,6 +1090,7 @@ static int close_a2dp_output()
    }
    a2dp.a2dp_source_started = false;
    a2dp.a2dp_source_total_active_session_requests = 0;
    if (!a2dp.adev->bt_sco_on)
        a2dp.a2dp_source_suspended = false;
    a2dp.bt_encoder_format = CODEC_TYPE_INVALID;
    a2dp.enc_sampling_rate = 48000;
@@ -2946,6 +2949,13 @@ int a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
        goto param_handled;
    }

    ret = str_parms_get_str(parms, "BT_SCO", value, sizeof(value));
    if (ret >= 0) {
        if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0) {
            a2dp.a2dp_source_suspended = true;
        }
    }

param_handled:
    ALOGV("end of a2dp setparam");
    return status;