Commit 55cb653e authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Fix stream restart handling in StreamProcessorHelper

Fixes for the following issues in StreamProcessorHelper
1. Inputs packets were released prematurely when resetting the stream.
2. Output packets from previous streams were not ignored.
3. Reset() wasn't resetting the stream.

Bug: 1011117
Change-Id: I907590d92a92052bb3ed9518dd17b0eaa668403e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1838169Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702634}
parent bbbf9187
......@@ -121,11 +121,12 @@ void StreamProcessorHelper::ProcessEos() {
}
void StreamProcessorHelper::Reset() {
if (active_stream_) {
if (!active_stream_) {
// Nothing to do if we don't have an active stream.
return;
}
if (processor_ && active_stream_) {
if (processor_) {
processor_->CloseCurrentStream(stream_lifetime_ordinal_,
/*release_input_buffers=*/false,
/*release_output_buffers=*/false);
......@@ -133,7 +134,6 @@ void StreamProcessorHelper::Reset() {
stream_lifetime_ordinal_ += 2;
active_stream_ = false;
input_packets_.clear();
}
void StreamProcessorHelper::OnStreamFailed(uint64_t stream_lifetime_ordinal,
......@@ -259,6 +259,7 @@ void StreamProcessorHelper::OnOutputPacket(fuchsia::media::Packet output_packet,
if (!output_packet.has_header() ||
!output_packet.header().has_buffer_lifetime_ordinal() ||
!output_packet.header().has_packet_index() ||
!output_packet.has_stream_lifetime_ordinal() ||
!output_packet.has_buffer_index()) {
DLOG(ERROR) << "Received OnOutputPacket() with missing required fields.";
OnError();
......@@ -270,6 +271,13 @@ void StreamProcessorHelper::OnOutputPacket(fuchsia::media::Packet output_packet,
return;
}
if (output_packet.stream_lifetime_ordinal() != stream_lifetime_ordinal_) {
// Output packets from old streams still need to be recycled.
OnRecycleOutputBuffer(output_buffer_lifetime_ordinal_,
output_packet.header().packet_index());
return;
}
auto buffer_index = output_packet.buffer_index();
auto packet_index = output_packet.header().packet_index();
base::TimeDelta timestamp;
......
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