Repository navigation
Fix DSD decoder respawn to match the audio engine's payload format - #318
Merged
Merged
Conversation
On DAPs, only attempt DoP when DAP bit-perfect mode is enabled, since the shared mixer route cannot verify a DoP carrier. Otherwise fall back to PCM decimation to avoid misinterpreting decimated PCM. Also hard-fail DoP pre-flight only when a direct USB session is actually active, and exclude DsdDoP when reconfiguring the engine for PCM decimation so a DoP-configured engine cannot be reused.
DSD decoders spawned for seek/next/requeue inferred their output encoding from pipeline flags, which spawns a DoP decoder into a native-DSD stream (DoP low byte 0x00 = silence on the native wire). Record the encoding at engine creation and reuse it for respawns. Also force engine recreation when a caller excludes the current strategy, and normalize WavPack PCM samples by native bit depth rather than container width.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes silent DSD playback after seeking, track changes, and requeues on DAPs that
run a native-DSD engine, and corrects WavPack PCM level normalization.
DSD respawns no longer infer their encoding from pipeline flags
their output encoding from the pipeline mode. A native-DSD DAP engine runs its
raw-bypass pipeline as
PipelineMode::Dop, so a respawn inferred DoP andspawned a DoP decoder into a native stream. The native render loop reads each
word's low byte, and a DoP word's low byte is always
0x00— silence. Theresult was DSD audio that went quiet once you seeked or advanced.
Pcm/Dop/Native) at engine creation in anew
EngineDsdModeonAudioCallbackData, fixed for the engine's lifetimebecause the format is burned into the stream.
spawn_decodernow takes theengine's callback data and reads that recorded mode instead of re-deriving it
from the current preference.
native DSD map to
Native, DoP maps toDop, and everything else (includingthe desktop/cpal engine) is
Pcm.example the DoP-to-PCM decimation fallback), even when the rate/strategy
checks would otherwise reuse the handle — a mismatched payload format cannot be
swapped in place.
WavPack PCM normalized by native bit depth
depth (a 24-bit file yields ±2^23 even though it occupies three bytes), but the
old scale keyed off the container width and normalized 3- and 4-byte samples by
2^31. A 24-bit file was therefore scaled 256x too quiet.
wavpack_pcm_scale(bits_per_sample, bytes_per_sample), which normalizes bythe real bit depth (falling back to the container width when depth is missing,
clamped to 1..=32). This also handles wasted-bit files such as 20-bit audio
stored in a 24-bit container, and fixes the log line to report both values.
Tests
engine_dsd_mode_roundtrips_and_defaults_to_pcm.dsd_respawn_matches_engine_payload_format_not_pipeline_flags, which writes aminimal stereo DSD64 DSF fixture and asserts a native engine respawns at
352800 Hz (not the 176400 Hz DoP carrier the old inference chose), a DoP engine
still respawns DoP, and a PCM-decimation engine respawns PCM.
pcm_scale_normalizes_to_native_bit_depthcovering 8/16/24/32-bit, 20-bit ina 24-bit container, and the missing-depth fallback.
Related issue
none
Checklist
flutter analyzepassesflutter testpassescargo test --manifest-path rust/Cargo.tomlpassesflutter run --flavor full)CHANGELOG.mdupdated for user-facing changes