Open pmendozav opened 1 week ago
- When I add two
CustomMediaCodecRenderer
instances at indices 0 and 1, and trigger an exception in index 0 (for example, by havinggetDecoderInfos()
return an empty list), playback fails, and there’s no indication that the player attempts to use index 1.
This sounds like you're expecting to see fallback between Renderer
instances, but the boolean you're toggling is about decoder fallback. These are different abstractions. I think it's expected that you don't see fallback from one Renderer
to another.
2. If I place it in
onCodecInitialized
, playback continues; however, if I place it inonQueueInputBuffer
, playback doesn’t recover (see commentserror_1
,error_2
in the code).
This matches my reading of the documentation on the enableDecoderFallback
parameter of the MediaCodecRenderer
constructor (emphasis mine):
Whether to enable fallback to lower-priority decoders if decoder initialization fails
- How can I confirm that
CustomMediaCodecRenderer
has indeed switched to a fallback decoder?
The code looks like it should emit the event to VideoRendererEventListener
(and log it to logcat) via MediaCodecVideoRenderer.onCodecError
:
When I try this in the demo app by enabling decoder fallback on the DefaultRenderersFactory
instantiated in DemoUtil
and throwing an exception for the first code (based on name) at the bottom MediaCodecVideoRenderer.onCodecInitialized
, i see the exception logged from MediaCodecVideoRenderer
. If i then implement AnalyticsListener.onVideoCodecError
in EventLogger
I also see it logged there (this is wired via VideoRendererEventListener
).
Aside: MediaCodecRenderer.onCodecInitialized
is documented as (emphasis mine):
Called when a
MediaCodec
has been created and configured.
i.e. this is only called after initialization is complete, so throwing an exception in here to simulate an initialization failure is technically too late. It happens to work at the moment, due to the structure of the code, but I wouldn't rely on this remaining true forever.
Hello everyone,
I’m having trouble understanding the behavior of
enableDecoderFallback
and the specific level at which it operates. Essentially, I want to confirm thatenableDecoderFallback
is functioning as expected.Here’s what I did:
I customized
demos/main
with the following classes:VideoRendererEventListener
(fromVideoRendererEventListener
): to add logs and monitor behavior when exceptions are thrown.CustomMediaCodecRenderer
(fromMediaCodecVideoRenderer
): to generate exceptions and examine available decoders.CustomRendererFactory
(fromDefaultRenderersFactory
): to manage bothVideoRendererEventListener
andCustomMediaCodecRenderer
.With these helper classes, I performed the following tests:
CustomMediaCodecRenderer
instances at indices 0 and 1, and trigger an exception in index 0 (for example, by havinggetDecoderInfos()
return an empty list), playback fails, and there’s no indication that the player attempts to use index 1.CustomMediaCodecRenderer
at index 0 while keeping the hardware decoder selected by the player, playback behaves differently depending on where I place the exception. If I place it inonCodecInitialized
, playback continues; however, if I place it inonQueueInputBuffer
, playback doesn’t recover (see commentserror_1
,error_2
in the code).In each case, logs capture the error but don’t indicate any fallback from hardware to software within the same
CustomMediaCodecRenderer
. This raises some questions:CustomMediaCodecRenderer
has indeed switched to a fallback decoder?onQueueInputBuffer
) remain unhandled, causing playback to fail?Thank you for any insights!
Here is my fork with the changes I made
utilities classes:
Change in
PlayerActivity.java