8000 Fall back to mp3 on devices without an Opus decoder (#4018) by m86hussein · Pull Request #4019 · quran/quran_android · GitHub
[go: up one dir, main page]

Skip to content
8000

Fall back to mp3 on devices without an Opus decoder (#4018) - #4019

Open
m86hussein wants to merge 1 commit into
quran:mainfrom
m86hussein:fix/opus-fallback-when-no-decoder
Open

m86hussein wants to merge 1 commit into
quran:mainfrom
m86hussein:fix/opus-fallback-when-no-decoder

Conversation

@m86hussein
Copy link
Copy Markdown
Contributor

Summary

Addresses #4018 — on devices without an Opus decoder, audio downloaded/streamed after 3.6.1 plays silently (highlighting advances, no sound), while mp3-only qaris (e.g. Basfar) keep working.

As discussed in the issue, after 3.6.1 new downloads/streaming default to Opus (via QuranAudioExtensionDecider). Some devices — notably certain e-ink tablets (Onyx BOOX, Android 15) — ship firmware without a system Opus decoder, so ExoPlayer has nothing to decode the stream with and fails silently.

Why not bundle the Opus decoder?

The obvious "just ship a software Opus decoder" route isn't viable here: the media3 decoder extensions (androidx.media3:media3-decoder-opus) are not published to Google Maven and require a from-source NDK build. So instead this PR makes format selection aware of what the device can actually play.

Change

  • New AudioDecoderCapabilities interface + MediaCodecAudioDecoderCapabilities implementation that queries the platform MediaCodecList once (cached) for an audio/opus decoder.
  • QuranAudioExtensionDecider now only prefers Opus when the qari has an opus URL and the device has an Opus decoder; otherwise it uses mp3. allowedAudioExtensions likewise returns only mp3 on devices without an Opus decoder, so stale/undecodable opus files aren't treated as valid.

This is device-agnostic (fixes every device lacking an Opus decoder, not just BOOX) and routes through the single existing format chooser, so both the download and streaming paths are covered.

Tests

  • Added unit tests to QuranAudioExtensionDeciderTest covering the no-opus-decoder device case for both Qari and QariItem; existing opus/mp3 behavior is preserved via an injected fake capability.

Verification note

I don't have a BOOX / e-ink device, so I couldn't verify end-to-end on affected hardware. The decider logic is covered by unit tests; on-device confirmation from the reporter would be appreciated. Happy to adjust the approach (e.g. combine with an ExoPlayer decoder-init exception fallback) based on your preference.

New downloads and streaming use Opus after 3.6.1. Devices without an Opus decoder (e.g. some e-ink tablets) play Opus silently: playback advances but no audio is produced, while mp3-only qaris keep working. Gate the Opus format on actual device decoder support (queried via MediaCodecList) in QuranAudioExtensionDecider and fall back to mp3 otherwise, for both downloads and streaming.

Addresses quran#4018
@ahmedre
ahmedre commented Nov 9, 2026
Copy link
Copy Markdown
Contributor

JazakumAllah khairan patch looks good but one question is as to whether or not the device reports opus support or not (silent playback suggests to me (?) that it might report it as present when it isn't?)

@ahmedre ahmedre left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also add a

appCoroutineScope.launch { audioDecoderCapabilities.isOpusSupported() }

in the application subclass - and add a provides method for auto?

* [AudioDecoderCapabilities] implementation backed by the platform [MediaCodecList]. The result
* is computed once and cached, since the set of available decoders does not change at runtime.
*/
@ContributesBinding(AppScope::class)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SingleIn(AppScope::class)

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.

2 participants

0