Silence when playing ogg files

Open
#927 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by reproducing the report: the snippet calls rodio::Decoder::try_from on an attached .ogg file and plays it through rodio::Player::connect_new(handle.mixer()), but the output is silent. Narrow down whether the decoder yields samples at all or the mixer drops them, and check the ogg file itself, which is attached as foo.txt and must be renamed back. Done means the basic example audibly plays an ogg file on the default device.

Written by the indexing model from the issue text.

Description

The basic example fails. The version is 0.22.2

fn main() {
    use rodio::Decoder;
    use std::fs::File;

    // Get an OS-Sink handle to the default physical sound device.
    // Note that the playback stops when the handle is dropped.//!
    let handle = rodio::DeviceSinkBuilder::open_default_sink().expect("open default audio stream");
    let player = rodio::Player::connect_new(handle.mixer());
    // Load a sound from a file, using a path relative to Cargo.toml
    let file = File::open("foo.ogg").unwrap();
    // Decode that sound file into a source
    let source = Decoder::try_from(file).unwrap();
    // Play the sound directly on the device
    handle.mixer().add(source);

    // The sound plays in a separate audio thread,
    // so we need to keep the main thread alive while it's playing.
    std::thread::sleep(std::time::Duration::from_secs(5));
}

Here is the ogg file in question (renamed as txt so that i can upload it on github)

foo.txt

Dominant language
Rust
Stars
2.5k
Forks
338
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RustAudio/rodio

All issues in RustAudio/rodio

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.