Do not change audio capabilities for error recovery without context

If the deprecated path without a context is used, the capabilities
are set externally and can't recover automatically back to the real
capabilities.

Issue: androidx/media#2168
PiperOrigin-RevId: 730427339
This commit is contained in:
tonihei 2025-02-24 06:32:06 -08:00 committed by Copybara-Service
parent c90ca4e86e
commit 5610cc8465

View File

@ -1275,8 +1275,9 @@ public final class DefaultAudioSink implements AudioSink {
if (listener != null) {
listener.onAudioSinkError(e);
}
if (e.isRecoverable) {
if (e.isRecoverable && context != null) {
// Change to the audio capabilities supported by all the devices during the error recovery.
// Only do this if we have a context and the capabilities can automatically adjust back.
audioCapabilities = DEFAULT_AUDIO_CAPABILITIES;
throw e; // Do not delay the exception if it can be recovered at higher level.
}