Files
pmomusic/pmoaudio-ext/Cargo.toml

38 lines
1.1 KiB
TOML
Raw Normal View History

[package]
name = "pmoaudio-ext"
version = "0.1.0"
edition = "2021"
[dependencies]
# Core audio types
pmoaudio = { path = "../pmoaudio" }
pmocovers = { path = "../pmocovers"}
# Optional dependencies for cache-sink feature
pmoaudiocache = { path = "../pmoaudiocache", optional = true }
pmoflac = { path = "../pmoflac", optional = true }
pmometadata = { path = "../pmometadata", optional = true }
feat: Add PlaylistSource and ResamplingNode for playlist playback This commit implements a new audio source that reads from pmoplaylist and streams tracks continuously, along with a resampling node to normalize sample rates. ## New Components ### PlaylistSource (pmoaudio-ext) - New source in pmoaudio-ext/src/sources/playlist_source.rs - Reads from pmoplaylist ReadHandle - Decodes tracks from audio cache (pmoaudiocache) - Emits PCM with heterogeneous sample_rate and bit_depth - Polls playlist when empty (configurable interval, default 100ms) - Emits TrackBoundary markers between tracks - Graceful shutdown with EndOfStream on stop - Gated behind 'playlist' feature flag **Design Philosophy:** - Keeps each node simple (single responsibility) - Emits raw PCM without format normalization - Pipeline designer chooses how to handle heterogeneity - Ideal for Radio Paradise (homogeneous streams) - Requires ResamplingNode + ToI24Node for mixed playlists ### ResamplingNode (pmoaudio) - Generic resampling node in pmoaudio/src/nodes/resampling_node.rs - Normalizes variable sample rates to a target rate - Uses libsoxr for high-quality resampling - Automatically detects sample rate changes - Recreates resampler as needed - Preserves chunk type (I16/I24/I32/F32/F64) - Quality adapts to bit depth (Medium/High/Very High) ## Architecture PlaylistSource is placed in pmoaudio-ext to avoid circular dependencies: - pmoaudio-ext depends on: pmoaudio, pmoplaylist, pmoaudiocache - No reverse dependencies = clean dependency graph ## Configuration ### pmoaudio-ext/Cargo.toml - Updated 'playlist' feature to include pmoaudiocache, pmocache, pmoflac - Added sources module export ### pmoaudio - Added resampling_node module - Public export: ResamplingNode ## System Requirements ⚠️ **IMPORTANT**: libsoxr-dev must be installed for compilation See INSTALL_NOTES.md for installation instructions per platform. ## Usage Example ```rust // Radio Paradise (homogeneous 44.1kHz/16bit) let mut source = PlaylistSource::new(playlist, cache); let to_i24 = ToI24Node::new(); source.register(Box::new(to_i24)); // Mixed playlist (needs normalization) let mut source = PlaylistSource::new(playlist, cache); let mut resampler = ResamplingNode::new(48000); // Force 48kHz let to_i24 = ToI24Node::new(); source.register(Box::new(resampler)); resampler.register(Box::new(to_i24)); ``` ## Files Changed - pmoaudio-ext/Cargo.toml: Update playlist feature - pmoaudio-ext/src/lib.rs: Add sources module - pmoaudio-ext/src/sources/mod.rs: New sources module - pmoaudio-ext/src/sources/playlist_source.rs: New PlaylistSource (580 lines) - pmoaudio/src/nodes/resampling_node.rs: New ResamplingNode (350 lines) - pmoaudio/src/nodes/mod.rs: Register resampling_node - pmoaudio/src/lib.rs: Export ResamplingNode - INSTALL_NOTES.md: System requirements documentation ## Future Work - GapInsertionNode (inserts silence between tracks) - CrossfadeNode (fade-in/fade-out mixing) - Examples (deferred until implementation validated)
2025-11-05 13:44:24 +00:00
# Optional dependencies for playlist integration
pmoplaylist = { path = "../pmoplaylist", optional = true }
feat: Add PlaylistSource and ResamplingNode for playlist playback This commit implements a new audio source that reads from pmoplaylist and streams tracks continuously, along with a resampling node to normalize sample rates. ## New Components ### PlaylistSource (pmoaudio-ext) - New source in pmoaudio-ext/src/sources/playlist_source.rs - Reads from pmoplaylist ReadHandle - Decodes tracks from audio cache (pmoaudiocache) - Emits PCM with heterogeneous sample_rate and bit_depth - Polls playlist when empty (configurable interval, default 100ms) - Emits TrackBoundary markers between tracks - Graceful shutdown with EndOfStream on stop - Gated behind 'playlist' feature flag **Design Philosophy:** - Keeps each node simple (single responsibility) - Emits raw PCM without format normalization - Pipeline designer chooses how to handle heterogeneity - Ideal for Radio Paradise (homogeneous streams) - Requires ResamplingNode + ToI24Node for mixed playlists ### ResamplingNode (pmoaudio) - Generic resampling node in pmoaudio/src/nodes/resampling_node.rs - Normalizes variable sample rates to a target rate - Uses libsoxr for high-quality resampling - Automatically detects sample rate changes - Recreates resampler as needed - Preserves chunk type (I16/I24/I32/F32/F64) - Quality adapts to bit depth (Medium/High/Very High) ## Architecture PlaylistSource is placed in pmoaudio-ext to avoid circular dependencies: - pmoaudio-ext depends on: pmoaudio, pmoplaylist, pmoaudiocache - No reverse dependencies = clean dependency graph ## Configuration ### pmoaudio-ext/Cargo.toml - Updated 'playlist' feature to include pmoaudiocache, pmocache, pmoflac - Added sources module export ### pmoaudio - Added resampling_node module - Public export: ResamplingNode ## System Requirements ⚠️ **IMPORTANT**: libsoxr-dev must be installed for compilation See INSTALL_NOTES.md for installation instructions per platform. ## Usage Example ```rust // Radio Paradise (homogeneous 44.1kHz/16bit) let mut source = PlaylistSource::new(playlist, cache); let to_i24 = ToI24Node::new(); source.register(Box::new(to_i24)); // Mixed playlist (needs normalization) let mut source = PlaylistSource::new(playlist, cache); let mut resampler = ResamplingNode::new(48000); // Force 48kHz let to_i24 = ToI24Node::new(); source.register(Box::new(resampler)); resampler.register(Box::new(to_i24)); ``` ## Files Changed - pmoaudio-ext/Cargo.toml: Update playlist feature - pmoaudio-ext/src/lib.rs: Add sources module - pmoaudio-ext/src/sources/mod.rs: New sources module - pmoaudio-ext/src/sources/playlist_source.rs: New PlaylistSource (580 lines) - pmoaudio/src/nodes/resampling_node.rs: New ResamplingNode (350 lines) - pmoaudio/src/nodes/mod.rs: Register resampling_node - pmoaudio/src/lib.rs: Export ResamplingNode - INSTALL_NOTES.md: System requirements documentation ## Future Work - GapInsertionNode (inserts silence between tracks) - CrossfadeNode (fade-in/fade-out mixing) - Examples (deferred until implementation validated)
2025-11-05 13:44:24 +00:00
pmocache = { path = "../pmocache", optional = true }
Fix stream_block buffer cycling issue with FFPlay PROBLEM: When streaming Radio Paradise blocks via HTTP using FFPlay, the buffer would cycle between 0KB and ~130KB approximately once per second, causing audio dropouts and interruptions. VLC worked fine, but FFPlay was sensitive to the burst transmission pattern. ROOT CAUSE: In StreamingFlacSink::broadcast_flac_stream(), the broadcaster was reading 8KB (8192 bytes) at a time from the FLAC encoder and sending the entire chunk at once to all HTTP clients. This created a "burst" pattern: - Read 8KB from encoder - Send entire 8KB chunk to all clients - Sleep if ahead of real-time pacing - Repeat FFPlay's buffer would fill rapidly with each 8KB burst, then drain completely before the next burst arrived, causing the observed cycling behavior. SOLUTION: Reduced the HTTP broadcast buffer size from 8KB to 512 bytes in StreamingFlacSink::broadcast_flac_stream(). This creates a much smoother, more continuous data flow that FFPlay can handle without buffer cycling. The 512-byte buffer size is: - Small enough to prevent burst transmission - Large enough to avoid excessive overhead - Sufficient for smooth streaming with real-time pacing CHANGES: - Restore stream_block.rs example from git history - Restore StreamingFlacSink and StreamingOggFlacSink from git history - Add "streaming" feature to pmoaudio-ext - Reduce broadcast buffer from 8192 to 512 bytes - Update pmoparadise to use pmoaudio-ext streaming feature TESTING: Test with FFPlay to verify smooth buffering: ```bash cargo run --example stream_block --features full -- 0 # In another terminal: ffplay http://localhost:8080/test/stream ``` Watch the "aq=" value in FFPlay output. It should now remain stable instead of cycling between 0KB and 130KB.
2025-11-13 06:59:27 +00:00
# Optional dependencies for streaming feature
bytes = { version = "1.5", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
# Async runtime
tokio = { version = "1.0", features = ["full"] }
tokio-util = { version = "0.7" }
async-trait = "0.1"
# Utilities
tracing = "0.1"
[features]
default = []
cache-sink = ["dep:pmoaudiocache", "dep:pmoflac", "dep:pmometadata"]
playlist = ["cache-sink", "dep:pmoplaylist", "dep:pmocache"]
Fix stream_block buffer cycling issue with FFPlay PROBLEM: When streaming Radio Paradise blocks via HTTP using FFPlay, the buffer would cycle between 0KB and ~130KB approximately once per second, causing audio dropouts and interruptions. VLC worked fine, but FFPlay was sensitive to the burst transmission pattern. ROOT CAUSE: In StreamingFlacSink::broadcast_flac_stream(), the broadcaster was reading 8KB (8192 bytes) at a time from the FLAC encoder and sending the entire chunk at once to all HTTP clients. This created a "burst" pattern: - Read 8KB from encoder - Send entire 8KB chunk to all clients - Sleep if ahead of real-time pacing - Repeat FFPlay's buffer would fill rapidly with each 8KB burst, then drain completely before the next burst arrived, causing the observed cycling behavior. SOLUTION: Reduced the HTTP broadcast buffer size from 8KB to 512 bytes in StreamingFlacSink::broadcast_flac_stream(). This creates a much smoother, more continuous data flow that FFPlay can handle without buffer cycling. The 512-byte buffer size is: - Small enough to prevent burst transmission - Large enough to avoid excessive overhead - Sufficient for smooth streaming with real-time pacing CHANGES: - Restore stream_block.rs example from git history - Restore StreamingFlacSink and StreamingOggFlacSink from git history - Add "streaming" feature to pmoaudio-ext - Reduce broadcast buffer from 8192 to 512 bytes - Update pmoparadise to use pmoaudio-ext streaming feature TESTING: Test with FFPlay to verify smooth buffering: ```bash cargo run --example stream_block --features full -- 0 # In another terminal: ffplay http://localhost:8080/test/stream ``` Watch the "aq=" value in FFPlay output. It should now remain stable instead of cycling between 0KB and 130KB.
2025-11-13 06:59:27 +00:00
streaming = ["dep:pmoflac", "dep:pmometadata", "dep:bytes", "dep:serde"]
all = ["cache-sink", "playlist", "streaming"]