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 15 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
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -6,7 +6,7 @@ on:
branches: [main, master]

env:
RUSTFLAGS: "-C debuginfo=0 -D warnings"
RUSTFLAGS: '-C debuginfo=0 -D warnings'
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

Expand All @@ -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 --no-default-features --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
39 changes: 27 additions & 12 deletions Cargo.toml
@@ -1,29 +1,44 @@
[package]
name = "rodio"
version = "0.14.0"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "Audio playback library"
keywords = ["audio", "playback", "gamedev"]
repository = "https://github.com/RustAudio/rodio"
documentation = "http://docs.rs/rodio"
edition = "2018"
keywords = ["audio", "playback", "gamedev"]
license = "MIT OR Apache-2.0"
name = "rodio"
est31 marked this conversation as resolved.
Show resolved Hide resolved
repository = "https://github.com/RustAudio/rodio"
version = "0.14.0"

[dependencies]
claxon = {version = "0.4.2", optional = true}
cpal = "0.13"
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 }
hound = {version = "3.3.1", optional = true}
lewton = {version = "0.10", optional = true}
est31 marked this conversation as resolved.
Show resolved Hide resolved
minimp3 = {version = "0.5.0", optional = true}
symphonia = {version = "0.3", optional = true, default-features = false}
thiserror = "1.0.25"
est31 marked this conversation as resolved.
Show resolved Hide resolved

[features]
default = ["flac", "vorbis", "wav", "mp3"]
default = ["flac", "mp3", "vorbis", "wav"]
est31 marked this conversation as resolved.
Show resolved Hide resolved

flac = ["claxon"]
vorbis = ["lewton"]
wav = ["hound"]
mp3 = ["minimp3"]
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"]
vorbis = ["lewton"]
wasm-bindgen = ["cpal/wasm-bindgen"]
wav = ["hound"]
est31 marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
quickcheck = "0.9.2"

[build-dependencies]
cfg_aliases = "0.1.1"

[[example]]
name = "music_m4a"
required-features = ["symphonia-isomp4", "symphonia-aac"]
20 changes: 12 additions & 8 deletions README.md
Expand Up @@ -6,23 +6,27 @@

Rust playback library.

- Playback is handled by [cpal](https://github.com/RustAudio/cpal).
- MP3 decoding is handled by [minimp3](https://github.com/lieff/minimp3).
- 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).
- Playback is handled by [CPAL](https://github.com/RustAudio/cpal).
- MP3 decoding is handled by [Minimp3](https://github.com/lieff/minimp3).
- WAV decoding is handled by [Hound](https://github.com/ruud-v-a/hound).
est31 marked this conversation as resolved.
Show resolved Hide resolved
- 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)

[The documentation](http://docs.rs/rodio) contains an introduction to the library.

## License
[License]: #license

[license]: #license

Licensed under either of

* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0), or
est31 marked this conversation as resolved.
Show resolved Hide resolved
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0), or
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

Expand Down
17 changes: 17 additions & 0 deletions build.rs
@@ -0,0 +1,17 @@
use cfg_aliases::cfg_aliases;

fn main() {
// Add alias to see if any symphonia features are enabled
// This prevents having to copy/paste this large cfg check each time
cfg_aliases! {
est31 marked this conversation as resolved.
Show resolved Hide resolved
symphonia: {
any(
feature = "symphonia-mp3",
feature = "symphonia-wav",
feature = "symphonia-aac",
feature = "symphonia-isomp4",
feature = "symphonia-flac"
)
}
}
}
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();
}