Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
toolchain: ["1.87"]
toolchain: ["1.89"]
include:
- os: macos-latest
MACOS: true
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- Added Opus support via `symphonia-adapter-libopus`.
- Third-party Symphonia codecs can be registered with `DecoderBuilder::with_decoder`.

## Version [0.22.1] (2026-02-22)

### Fixed
Expand Down
113 changes: 99 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository = "https://github.com/RustAudio/rodio"
documentation = "https://docs.rs/rodio"
exclude = ["assets/**", "tests/**"]
edition = "2021"
rust-version = "1.87"
rust-version = "1.89"

[features]
# Default feature set provides audio playback and common format support
Expand Down Expand Up @@ -50,6 +50,9 @@ noise = ["rand", "rand_distr"]
# Enable WebAssembly support for web browsers
wasm-bindgen = ["cpal/wasm-bindgen"]

# Base symphonia feature (doesn't enable any codecs)
symphonia = ["dep:symphonia"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there are a lot of places that use #[cfg(feature = "symphonia")] even though there was no feature named symphonia. A feature with this name was created implicitly due to the other features that reference symphonia/xxx. For symphonia-libopus, I wanted to make sure the base symphonia feature was also enabled, so we need to make this feature explicit now.


# To decode an audio source with Rodio, you need to enable the appropriate features for *both* the
# demuxer and the decoder.
#
Expand Down Expand Up @@ -96,6 +99,9 @@ symphonia-wav = ["symphonia/wav"]
# Enable SIMD optimisations for Symphonia
symphonia-simd = ["symphonia/opt-simd"]

# libopus adapter for Symphonia
symphonia-libopus = ["symphonia", "dep:symphonia-adapter-libopus"]

# Alternative decoders and demuxers
claxon = ["dep:claxon"] # FLAC
hound = ["dep:hound"] # WAV
Expand Down Expand Up @@ -126,13 +132,16 @@ atomic_float = { version = "1.1.0", optional = true }
rtrb = { version = "0.3.2", optional = true }
num-rational = "0.4.2"

symphonia-adapter-libopus = { version = "0.2", optional = true }

[dev-dependencies]
quickcheck = "1"
rstest = "0.26"
rstest_reuse = "0.7"
approx = "0.5.1"
divan = "0.1.14"
inquire = "0.9.3"
symphonia-adapter-fdk-aac = "0.1"

[[bench]]
name = "effects"
Expand Down Expand Up @@ -230,6 +239,10 @@ required-features = ["playback", "vorbis"]
name = "music_wav"
required-features = ["playback", "wav"]

[[example]]
name = "music_opus"
required-features = ["playback", "symphonia-libopus"]

[[example]]
name = "noise_generator"
required-features = ["playback", "noise"]
Expand All @@ -253,3 +266,7 @@ required-features = ["playback", "vorbis"]
[[example]]
name = "stereo"
required-features = ["playback", "vorbis"]

[[example]]
name = "third_party_codec"
required-features = ["playback", "symphonia", "symphonia-isomp4"]
Binary file added assets/music.opus
Binary file not shown.
13 changes: 13 additions & 0 deletions examples/music_opus.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
let stream_handle = rodio::DeviceSinkBuilder::open_default_sink()?;
let player = rodio::Player::connect_new(stream_handle.mixer());

let file = std::fs::File::open("assets/music.opus")?;
player.append(rodio::Decoder::try_from(file)?);

player.sleep_until_end();

Ok(())
}
23 changes: 23 additions & 0 deletions examples/third_party_codec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use rodio::decoder::DecoderBuilder;
use std::error::Error;
use symphonia_adapter_fdk_aac::AacDecoder;

fn main() -> Result<(), Box<dyn Error>> {
let stream_handle = rodio::DeviceSinkBuilder::open_default_sink()?;
let sink = rodio::Player::connect_new(stream_handle.mixer());

let file = std::fs::File::open("assets/music.m4a")?;
let len = file.metadata()?.len();
let decoder = DecoderBuilder::new()
.with_data(file)
// Note: the length must be known for Symphonia to properly detect the format for this file
// This limitation will be removed in Symphonia 0.6
.with_byte_len(len)
.with_decoder::<AacDecoder>()
.build()?;
sink.append(decoder);

sink.sleep_until_end();

Ok(())
}
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
inputs: inputs.utils.lib.eachDefaultSystem (
system: let
pkgs = inputs.nixpkgs.legacyPackages.${system}.extend inputs.rust-overlay.overlays.default;
rust = pkgs.rust-bin.stable."1.87.0".default.override {
rust = pkgs.rust-bin.stable."1.89.0".default.override {
extensions = [ "rust-src" "rust-analyzer" ];
};
in {
Expand Down
Loading