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
(cherry picked from commit 5610cc846589aafa416c39567f4f5599e98a77ef)
This commit is contained in:
tonihei 2025-02-24 06:32:06 -08:00 committed by oceanjules
parent ff65d7b05b
commit 50f6bdd1fd

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.
}