diff --git a/src/audio.rs b/src/audio.rs index fc14e79..f3301bd 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -40,12 +40,6 @@ impl AudioCallback for ApuSampler { // if we didn't have enough, decrease the ratio so we take more samples from the APU if l > target { *b = b.split_off(target); - self.sample_ratio += 0.005; - // println!("raised ratio to {}", self.sample_ratio); - } else { - b.clear(); - self.sample_ratio -= 0.05; - // println!("lowered ratio to {}", self.sample_ratio); } } else { println!("buffer empty!"); // happens when the callback fires twice between video frames diff --git a/src/main.rs b/src/main.rs index 1fe8f90..4db4ea9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,11 +79,11 @@ fn main() -> Result<(), String> { if end_of_frame { fps += 1; // keep track of how many frames we've rendered this second draw_to_window(&mut texture, &mut canvas, &screen_buffer)?; // draw the buffer to the window with SDL + let mut b = apu_buffer.lock().unwrap(); // unlock mutex to the real buffer + b.append(&mut temp_buffer); // send this frame's audio data, emptying the temp buffer let now = Instant::now(); // if we're running faster than 60Hz, kill time if now < timer + Duration::from_millis(1000/60) { - let mut b = apu_buffer.lock().unwrap(); // unlock mutex to the real buffer - b.append(&mut temp_buffer); // send this frame's audio data, emptying the temp buffer std::thread::sleep(timer + Duration::from_millis(1000/60) - now); } timer = Instant::now();