Skip to content

Buffer underrun/overrun on 96000 and 192000 sample_rate flac #827

@UnknownSuperficialNight

Description

@UnknownSuperficialNight

Did a cargo update last night and now started to get audio stream error: Buffer underrun/overrun occurred

After a quick investigation, I needed to set the BufferSize manually instead of using the system one (even though this was not an issue before)

Seems for me, I have to do 2048 in order for this to not underrun

builder: DeviceSinkBuilder { device: "Some(Default Audio Device)", config: DeviceSinkConfig { channel_count: 2, sample_rate: 192000, buffer_size: Fixed(2048), sample_format: F32 } }

Example 512 causing errors:

builder: DeviceSinkBuilder { device: "Some(Default Audio Device)", config: DeviceSinkConfig { channel_count: 2, sample_rate: 96000, buffer_size: Fixed(512), sample_format: F32 } }
audio stream error: Buffer underrun/overrun occurred.
audio stream error: Buffer underrun/overrun occurred.
audio stream error: Buffer underrun/overrun occurred.
audio stream error: Buffer underrun/overrun occurred.

That resolved it for me but still weird this became an issue now, so I'm making this issue just in case

I was able to recreate it with the music_flac example

use std::error::Error;
use std::num::NonZero;
use rodio::DeviceSinkBuilder;

fn main() -> Result<(), Box<dyn Error>> {
    let builder = match DeviceSinkBuilder::from_default_device() {
        Ok(builder) => {
            builder.with_sample_rate(NonZero::new(96000).unwrap()).with_channels(NonZero::new(2 as u16).unwrap())
        }
        Err(err) => {
            panic!("error");
        }
    };

    println!("builder: {:?}", builder);

    let mut stream_handle = match builder.open_sink_or_fallback() {
        Ok(stream_handle) => stream_handle,
        Err(err) => {
            panic!("error2");

        }
    };

    let player = rodio::Player::connect_new(stream_handle.mixer());

    let file = std::fs::File::open("song.flac")?;
    player.append(rodio::Decoder::try_from(file)?);

    player.sleep_until_end();

    Ok(())
}

No idea what changed to cause this, i haven't updated my system or modified my system buffer size any time recently

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions