androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.69k stars 405 forks source link

Allow changing DefaultAudioSink.offloadMode #133

Open yschimke opened 2 years ago

yschimke commented 2 years ago

Use case description

Audio offload may remove features such as volume normalization, gapless playback, playback speed. If offload is provided as a user preference, it should be possible to change the mode in DefaultAudioSink without restarting to destroy the ExoPlayer instance and it's AudioSink.

Proposed solution

Allow changing the offload mode on an existing DefaultAudioSink, potentially only when not actively playing.

Alternatives considered

Some mechanism to tear down an ExoPlayer instance and rebuild it?

tonihei commented 2 years ago

Offload integration in ExoPlayer is still an experimental feature and subject to future changes. The final integration likely uses a different way to set the offload preferences other than hardcoding them in the constructor of DefaultAudioSink. I'll keep this issue open because changing the value is not currently supported.

yschimke commented 2 years ago

There are still some edge cases that can cause offload to be disabled until process restart.

If you start playing with a headset that isn't compatible with offload, then even if you change later to a compatible headset, it will keep using non offloaded.

But good to hear about the final integration, sounds good.

Feel free to close if it's no longer planned.

yschimke commented 2 years ago

Flagging that for any apps that want mixed formats on Wear, such as Music + Podcasts, may want to enable/disable offload when a new playlist is selected. Tearing down exoplayer seems very disruptive for this.

Are there other options to achieve this? Say a decorating AudioSink?