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)
32 lines
915 B
TOML
32 lines
915 B
TOML
[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 }
|
|
|
|
# Optional dependencies for playlist integration
|
|
pmoplaylist = { path = "../pmoplaylist", optional = true }
|
|
pmocache = { path = "../pmocache", 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 = ["dep:pmoplaylist", "dep:pmoaudiocache", "dep:pmocache", "dep:pmoflac"]
|
|
all = ["cache-sink", "playlist"]
|