AudioSink: Add support for multiple listener or provide an AudioSink.Listener wrapper
@tianyif is already working on this.
Since Sep 13, 2024.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
[REQUIRED] Use case description
In order to be able to do some things at audiosink level to access the audioTrack to be able to use VolumeShaper I create an ForwardingAudioSink and want to listen to events about audiotrack init / release.
While the need is specific the issue is global. Since audio sink only support a single setListener we can't register the listener easily in the sink as ExoPlayer register itself later in the decoders and replace our listener.
We can of couse write a wrapper for the listener and dispatch manually, but since that interface have many default implementations, if Google add new callback with a default implementation, we can miss this and so the event won't be dispatched correctly.
Proposed solution
- Add the usual addListener/removeListener to be able to allow multiple listeners.
- Add a ForwardingListener in Media3 to ensure that any new event are properly forwarded and not missed if clients does this manually.
Alternatives considered
Manually create the event forwarder but this is error prone as soon as Google add new events with a default implementation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.