Commit 725ee310 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Fix FuchsiaAudioRenderer to handle seek correctly

FuchsiaAudioRenderer::FlushInternal() is called when seeking media
stream. It's supposed to flush all pending buffers, so playback can
resume from the new position. Problem was that there may be a demuxer
read that's still pending when the function is called. Results of that
read were still used after flush, but they may correspond to the
previous position in the stream (before seek). As result the packet
returned by the pending seek was sitting in the head of the queue
blocking playback of all other packets for the new position after seek,
breaking audio playback. This change updates
FuchsiaAudioRenderer::OnDemuxerStreamReadDone() to drop results if
FlushInternal() was called while the demuxer read operation was pending.

Bug: b/167613125
Change-Id: I134eb54f5729194d419226bc2df53012a32c8d4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422886
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Commit-Queue: David Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809686}
parent 14f07c9f
......@@ -485,6 +485,12 @@ void FuchsiaAudioRenderer::OnDemuxerStreamReadDone(
is_demuxer_read_pending_ = false;
if (drop_next_demuxer_read_result_) {
drop_next_demuxer_read_result_ = false;
ScheduleReadDemuxerStream();
return;
}
if (read_status != DemuxerStream::kOk) {
if (read_status == DemuxerStream::kError) {
OnError(PIPELINE_ERROR_READ);
......@@ -586,6 +592,10 @@ void FuchsiaAudioRenderer::FlushInternal() {
SetBufferState(BUFFERING_HAVE_NOTHING);
last_packet_timestamp_ = base::TimeDelta::Min();
read_timer_.Stop();
if (is_demuxer_read_pending_) {
drop_next_demuxer_read_result_ = true;
}
}
void FuchsiaAudioRenderer::OnEndOfStream() {
......
......@@ -131,6 +131,7 @@ class FuchsiaAudioRenderer : public AudioRenderer, public TimeSource {
DemuxerStream* demuxer_stream_ = nullptr;
bool is_demuxer_read_pending_ = false;
bool drop_next_demuxer_read_result_ = false;
RendererClient* client_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment