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

Commit 1de7952e authored by jiabin's avatar jiabin
Browse files

Set PAUSING state when start pausing a stream.

When the stream is pausing, the data callback is already stopped. In
that case, there is not more data written by the client. The aaudio
service need to set the state as PAUSING so that it allows underflow in
the mixer. That can avoid misreporting underrun.

Bug: 336233924
Test: atest AAudioTests --instant
Change-Id: I128aa73a5c9a77eb6c5f11d0bf71b8325b1d4d0d
parent b84f40d7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -88,7 +88,8 @@ void *AAudioServiceEndpointPlay::callbackLoop() {
                }

                aaudio_stream_state_t state = clientStream->getState();
                if (state == AAUDIO_STREAM_STATE_STOPPING) {
                if (state == AAUDIO_STREAM_STATE_STOPPING ||
                    state == AAUDIO_STREAM_STATE_PAUSING) {
                    allowUnderflow = false; // just read what is already in the FIFO
                } else if (state != AAUDIO_STREAM_STATE_STARTED) {
                    continue; // this stream is not running so skip it.
+2 −0
Original line number Diff line number Diff line
@@ -307,6 +307,8 @@ aaudio_result_t AAudioServiceStreamBase::pause_l() {
            .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)result)
            .record(); });

    setState(AAUDIO_STREAM_STATE_PAUSING);

    sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote();
    if (endpoint == nullptr) {
        ALOGE("%s() has no endpoint", __func__);