feat(infra/local): B3 - local-files media source scaffold#320
Merged
Conversation
Add src/infra/local/ behind a new Cargo feature local-files, implementing the MediaSource and Streamer traits from core::source for local audio files. MediaSource: - playlists() treats each immediate subdir of the root as a playlist, with RFC 8089-compliant file:// URIs (via url::Url::from_file_path), sorted alphabetically. - tracks() lists audio files in a directory, reads tags with lofty, and builds TrackInfo with is_local=true. Untagged files fall back to the filename stem. Files without a track_number tag sort after numbered tracks (0 sentinel maps to u32::MAX). Streamer skeleton: - stream() opens the file, probes format with symphonia, and constructs a decoder to prove the decode pipeline is reachable. - Phase 3 wiring (routing frames into the shared rodio sink) is marked with TODO(multi-source) comments; blocking I/O promotion to spawn_blocking is also noted for the wiring phase. Quality: - is_audio_file uses eq_ignore_ascii_case (no heap allocation vs to_lowercase). - split_artists separates on ';', ' / ' (spaced), ' & '; bare '/' is not a separator so band names like AC/DC are preserved intact. - path_to_file_uri uses url::Url::from_file_path for correct percent-encoding of spaces and non-ASCII bytes; round-trip is handled by Url::to_file_path. - All items marked #[allow(dead_code)] following Wave 0 convention. - Unit tests: URI round-trip, extension detection, artist splitting, directory scan, tag fallback, and decoder construction. Tests use tempfile-backed dirs for full hermeticity.
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
src/infra/local/mod.rsbehind a newlocal-filesCargo feature (deps:symphonia,lofty)MediaSourceforLocalSource:playlists()maps immediate subdirs toPlaylistInfowith RFC 8089-compliantfile://URIs;tracks()scans audio files and reads tags vialoftyStreamerskeleton: opens the file, probes format with symphonia, and constructs a decoder -- Phase 3 sink wiring is marked withTODO(multi-source)commentssrc/infra/mod.rswith#[cfg(feature = "local-files")]#[allow(dead_code)]following Wave 0 convention -- nothing is wired into dispatch/UI yetKey design decisions
path_to_file_uriusesurl::Url::from_file_path(theurlcrate is already a direct dep) for correct percent-encoding of spaces and non-ASCII bytessplit_artistsseparates on";"," / "(spaced slash)," & "-- bare"/"intentionally excluded so band names like AC/DC are not splittrack_number = 0(no tag) sorts after explicitly numbered tracks viau32::MAXsentinelis_audio_fileuseseq_ignore_ascii_caseto avoid per-call heap allocationtokio::task::spawn_blockingis noted in TODO comments for Phase 3 wiringTest plan
cargo build --no-default-features --features telemetry(slim build clean)cargo build --no-default-features --features telemetry,local-files(local-files build clean)cargo test --no-default-features --features telemetry(261 tests pass)cargo test --no-default-features --features telemetry,local-files(278 tests pass, includes new local module tests)cargo clippy --no-default-features --features telemetry -- -D warnings(clean)cargo clippy --no-default-features --features telemetry,local-files -- -D warnings(clean)cargo fmt --all(applied)tempfile-backed temp dirs, generate minimal WAV fixtures inline