Reset fallback state on decoder reinit earlier 02/320902/2
authorJakub Gajownik <j.gajownik2@samsung.com>
Wed, 20 Nov 2024 11:08:14 +0000 (12:08 +0100)
committerj.gajownik2 <j.gajownik2@samsung.com>
Mon, 25 Nov 2024 09:26:00 +0000 (10:26 +0100)
This change fixes rare issue with decoder stream reinitialization:
When decoder emits a frame, decoder stream sets flag to indicated
that no decoder fallback should be done. In case config change is
received and decoder reinitialization is finished before first
decoder buffer, flag is not reset. Then if first decode fails,
fallback is not enabled leading to persistent error on DecoderStream.

Flag reset should be done always when decoder initialization is
finished, no matter result.

Related upstream patch:
> Reset fallback state on decoder reinit
> https://chromium-review.googlesource.com/c/chromium/src/+/601210

Bug: https://jira-eu.sec.samsung.net/browse/VDGAME-627
Change-Id: Iff21f35155dce9d9502007060d696eeea4fd518c
Signed-off-by: Jakub Gajownik <j.gajownik2@samsung.com>
media/filters/decoder_stream.cc

index 5c592dc3fd10f5e80a3ec0566ada35bf446f724e..403146a8536634cadb5049a2cbf20c1b067de5a2 100644 (file)
@@ -964,6 +964,11 @@ void DecoderStream<StreamType>::CompleteDecoderReinitialization(
 
   state_ = status.is_ok() ? STATE_NORMAL : STATE_ERROR;
 
+  // Re-enable fallback to software after reinitialization. This is the last
+  // place we can clear that state, and as such is the least likely to interfere
+  // with the rest of the fallback algorithm.
+  decoder_produced_a_frame_ = false;
+
   if (reset_cb_) {
     std::move(reset_cb_).Run();
     return;
@@ -979,14 +984,6 @@ void DecoderStream<StreamType>::CompleteDecoderReinitialization(
     return;
   }
 
-  // Re-enable fallback to software after reinitialization. This is the last
-  // place we can clear that state, and as such is the least likely to interfere
-  // with the rest of the fallback algorithm.
-  // TODO(tguilbert): investigate setting this flag at an earlier time. This
-  // could fix the hypothetical edge case of receiving a decode error when
-  // flushing the decoder during a seek operation.
-  decoder_produced_a_frame_ = false;
-
   // We may still have too many |ready_outputs_| or |unprepared_outputs_| to
   // initiate another read to the demuxer stream. If so, the read will be
   // initiated later once we vended enough outputs to read again.