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

Commit da9b56b5 authored by Andy Hung's avatar Andy Hung
Browse files

Fix out_write frame count to match return code.

When we return that we have consumed bytes we must update
our frame counter properly.

Bug: 31546611
Change-Id: I3285c96a6b51baf84a57c0f70afe82269c44c4cd
parent 2b0e5a6f
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2063,14 +2063,16 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
            else
                ret = pcm_write(out->pcm, (void *)buffer, bytes);

            if (ret == 0)
                out->written += bytes / (out->config.channels * sizeof(short));

            release_out_focus(out, ns);
        }
    }

exit:
    // For PCM we always consume the buffer and return #bytes regardless of ret.
    if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD) {
        out->written += bytes / (out->config.channels * sizeof(short));
    }

    pthread_mutex_unlock(&out->lock);

    if (ret != 0) {