Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional Symphonia backend #376

Merged
merged 20 commits into from Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: install linux deps
run: |
sudo apt update
sudo apt install --no-install-recommends libasound2-dev pkg-config
sudo apt install -y --no-install-recommends libasound2-dev pkg-config
if: contains(matrix.os, 'ubuntu')

- name: install ${{ matrix.toolchain }} toolchain
Expand All @@ -55,7 +55,8 @@ jobs:
cargo fmt --all -- --check
if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest'

- run: cargo test --all-targets --all-features
- run: cargo test --all-targets
- run: cargo test --features=symphonia-all --all-targets
cargo-publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
Expand All @@ -66,7 +67,7 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install alsa
run: sudo apt install --no-install-recommends libasound2-dev pkg-config
run: sudo apt install -y --no-install-recommends libasound2-dev pkg-config
- name: Run cargo publish for rodio
continue-on-error: true
run: |
Expand Down
11 changes: 11 additions & 0 deletions Cargo.toml
Expand Up @@ -15,6 +15,7 @@ claxon = { version = "0.4.2", optional = true }
hound = { version = "3.3.1", optional = true }
lewton = { version = "0.10", optional = true }
minimp3 = { version = "0.5.0", optional = true }
symphonia = {version = "0.3", optional = true }

[features]
default = ["flac", "vorbis", "wav", "mp3"]
Expand All @@ -24,6 +25,16 @@ vorbis = ["lewton"]
wav = ["hound"]
mp3 = ["minimp3"]
wasm-bindgen = ["cpal/wasm-bindgen"]
symphonia-aac = ["symphonia/aac"]
symphonia-all = ["symphonia-aac", "symphonia-flac", "symphonia-isomp4", "symphonia-mp3", "symphonia-wav"]
symphonia-flac = ["symphonia/flac"]
symphonia-isomp4 = ["symphonia/isomp4"]
symphonia-mp3 = ["symphonia/mp3"]
symphonia-wav = ["symphonia/wav", "symphonia/pcm"]

[dev-dependencies]
quickcheck = "0.9.2"

[[example]]
name = "music_m4a"
required-features = ["symphonia-isomp4", "symphonia-aac"]
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -11,6 +11,9 @@ Rust playback library.
- WAV decoding is handled by [hound](https://github.com/ruud-v-a/hound).
- Vorbis decoding is handled by [lewton](https://github.com/est31/lewton).
- Flac decoding is handled by [claxon](https://github.com/ruuda/claxon).
- MP4 and AAC (both disabled by default) are handled by [Symphonia](https://github.com/pdeljanov/Symphonia).

Alternatively, Symphonia can be used to decode any of the other codecs above with the exception of Vorbis. See the docs for more details on backends.

# [Documentation](http://docs.rs/rodio)

Expand All @@ -28,4 +31,4 @@ at your option.

### License of your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Binary file added examples/music.m4a
Binary file not shown.
11 changes: 11 additions & 0 deletions examples/music_m4a.rs
@@ -0,0 +1,11 @@
use std::io::BufReader;

fn main() {
let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
let sink = rodio::Sink::try_new(&handle).unwrap();

let file = std::fs::File::open("examples/music.m4a").unwrap();
sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap());

sink.sleep_until_end();
}