Skip to content

Serialize audio capability callbacks on receiver handler - #3388

Draft
ajay-jg wants to merge 2 commits into
androidx:mainfrom
ajay-jg:fix-audio-capabilities-callback-thread
Draft

Serialize audio capability callbacks on receiver handler#3388
ajay-jg wants to merge 2 commits into
androidx:mainfrom
ajay-jg:fix-audio-capabilities-callback-thread

Conversation

@ajay-jg

@ajay-jg ajay-jg commented Aug 20, 2026

Copy link
Copy Markdown

Fixes #3386

Why

On some Android TV/STB devices, AudioDeviceCallback can be invoked from a looper-less OEM thread such as AudioMonitorHdmiThread. AudioCapabilitiesReceiver currently evaluates capabilities and notifies its listener directly from that callback.

This can call DefaultAudioSink.onAudioCapabilitiesChanged() off the playback looper and crash with:

IllegalStateException: Current looper (null) is not the playback looper (main)

What changed

  • Added regression coverage for device-added and device-removed callbacks delivered from a raw thread without a looper.
  • Posted audio capability updates to the receiver handler, including routed-device state updates on removal.

Testing

./gradlew :lib-exoplayer:testDebugUnitTest --tests androidx.media3.exoplayer.audio.AudioCapabilitiesReceiverWrongThreadTest --no-daemon

The test failed before the fix with the callback thread name and passed after the fix with the receiver handler thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant