Skip to content

Commit

Permalink
fix: play sounds at correct sample rate
Browse files Browse the repository at this point in the history
  • Loading branch information
mbillingr committed Jul 28, 2018
1 parent 32485eb commit 7d6eafc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bmixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::time::Duration;

use rodio::{Sample, Source};
use rodio::{source::UniformSourceIterator, Sample, Source};

use bformat::Bformat;
use bstream::{self, Bstream, SoundController};
Expand Down Expand Up @@ -106,7 +106,12 @@ impl BmixerComposer {
where
I: Source<Item = f32> + Send + 'static,
{
let (bstream, sound_ctl) = bstream::bstream(input);
let (bstream, sound_ctl) = if input.sample_rate() == self.sample_rate {
bstream::bstream(input)
} else {
let input = UniformSourceIterator::new(input, 1, self.sample_rate);
bstream::bstream(input)
};

self.pending_streams
.lock()
Expand Down

0 comments on commit 7d6eafc

Please sign in to comment.