Skip to content

Fix FLAC playback in float output mode - #125

Merged
lostf1sh merged 1 commit into
mainfrom
codex/fix-flac-float-playback
Sep 12, 2026
Merged

lostf1sh merged 1 commit into
mainfrom
codex/fix-flac-float-playback

Conversation

@lostf1sh

Copy link
Copy Markdown
Collaborator

FLAC playback can become distorted when 32-bit float output is enabled, as reported on the Galaxy S25 Ultra. Route FLAC through the bundled FFmpeg renderer in this mode so it decodes directly to float PCM. System Default and Direct retain the platform decoder order.

Capture the output mode when building each player so decoder selection stays consistent with its audio sink during mode changes. Add regression coverage for FLAC routing, MIME casing, and existing ALAC, MIDI, and AAC behavior across output modes.

Fixes #122.

Validation:

  • :app:compileDebugKotlin passed.
  • :app:testDebugUnitTest passed: 592 tests, including 15 decoder-policy tests.
  • Android 16 emulator verification passed for 16-bit/44.1 kHz and 24-bit/96 kHz stereo FLAC: FFmpeg was selected and every decoded float sample matched the original PCM. Galaxy S25 Ultra confirmation is still needed.
  • :app:lintDebug failed with 94 existing errors in files identical to main: Media3 opt-in annotations in FadingPlayer.kt and translation/plural resource errors. None of the errors are in the changed files.

@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown

Greptile Summary

This PR routes FLAC through the bundled FFmpeg renderer when 32-bit float output is active and snapshots the output mode during player construction so decoder and sink configuration remain aligned.

  • Preserves platform decoder ordering for System Default and Direct output.
  • Retains extension-only routing for ALAC and MIDI.
  • Adds regression coverage for FLAC routing, case-insensitive MIME matching, AAC, ALAC, and MIDI behavior across output modes.

Confidence Score: 5/5

The PR appears safe to merge; no actionable correctness, security, or repository-rule violations were identified.

The bundled FFmpeg renderer is available for the new FLAC route, output-mode state remains coherent throughout synchronous player construction, all call sites were updated, and regression tests cover the affected routing matrix.

Important Files Changed

Filename Overview
app/src/main/java/com/lostf1sh/pixelplayeross/data/service/player/AudioDecoderPolicy.kt Adds output-mode-aware FLAC routing while preserving existing extension-only and platform-decoder behavior.
app/src/main/java/com/lostf1sh/pixelplayeross/data/service/player/DualPlayerEngine.kt Captures the output mode once per player build and consistently applies it to decoder, sink, renderer, and audio-session configuration.
app/src/test/java/com/lostf1sh/pixelplayeross/data/service/player/AudioDecoderPolicyTest.kt Expands decoder-policy coverage across output modes, including FLAC float routing and MIME-case handling.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Build ExoPlayer] --> B[Capture current output mode]
    B --> C{FLAC with float output?}
    C -- Yes --> D[Exclude platform FLAC decoders]
    D --> E[Bundled FFmpeg renderer]
    C -- No --> F{ALAC or MIDI?}
    F -- Yes --> E
    F -- No --> G[Preserve Media3 platform decoder order]
    B --> H[Configure matching audio sink]
Loading

Reviews (1): Last reviewed commit: "Fix FLAC playback in float output mode" | Re-trigger Greptile

@lostf1sh
lostf1sh merged commit af2ed74 into main Sep 12, 2026
3 checks passed
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.

[Bug]: Hi Fi mode destroys FLAC songs

1 participant