new_unfilled -> new

This commit is contained in:
Alex Janka 2023-03-09 14:12:28 +11:00
parent 52fe997e28
commit bfb4772536
3 changed files with 3 additions and 27 deletions

View file

@ -136,7 +136,7 @@ fn create_audio_output() -> (AudioOutput, Stream) {
let sample_rate = config.sample_rate().0; let sample_rate = config.sample_rate().0;
let (output, mut rx) = let (output, mut rx) =
AudioOutput::new_unfilled(sample_rate as f32, true, FRAMES_TO_BUFFER, DOWNSAMPLE_TYPE); AudioOutput::new(sample_rate as f32, true, FRAMES_TO_BUFFER, DOWNSAMPLE_TYPE);
let stream = device let stream = device
.build_output_stream( .build_output_stream(

View file

@ -129,7 +129,7 @@ impl Plugin for GameboyEmu {
}; };
if let Some(ref mut vars) = self.vars { if let Some(ref mut vars) = self.vars {
let (output, rx) = AudioOutput::new_unfilled( let (output, rx) = AudioOutput::new(
buffer_config.sample_rate, buffer_config.sample_rate,
false, false,
FRAMES_TO_BUFFER, FRAMES_TO_BUFFER,
@ -141,7 +141,7 @@ impl Plugin for GameboyEmu {
} else { } else {
let (sender, receiver) = channel::<EmulatorMessage>(); let (sender, receiver) = channel::<EmulatorMessage>();
let (output, rx) = AudioOutput::new_unfilled( let (output, rx) = AudioOutput::new(
buffer_config.sample_rate, buffer_config.sample_rate,
false, false,
FRAMES_TO_BUFFER, FRAMES_TO_BUFFER,

View file

@ -2,7 +2,6 @@ use crate::processor::memory::mmio::gpu::Colour;
pub use crate::processor::memory::mmio::joypad::{JoypadButtons, JoypadState}; pub use crate::processor::memory::mmio::joypad::{JoypadButtons, JoypadState};
pub use crate::{HEIGHT, WIDTH}; pub use crate::{HEIGHT, WIDTH};
use async_ringbuf::{AsyncHeapConsumer, AsyncHeapProducer, AsyncHeapRb}; use async_ringbuf::{AsyncHeapConsumer, AsyncHeapProducer, AsyncHeapRb};
use futures::executor;
pub enum EmulatorMessage { pub enum EmulatorMessage {
Stop, Stop,
@ -58,29 +57,6 @@ impl AudioOutput {
wait_for_output: bool, wait_for_output: bool,
frames_to_buffer: usize, frames_to_buffer: usize,
downsample_type: DownsampleType, downsample_type: DownsampleType,
) -> (Self, AsyncHeapConsumer<[f32; 2]>) {
let (mut output, rx) = Self::new_unfilled(
sample_rate,
wait_for_output,
frames_to_buffer,
downsample_type,
);
executor::block_on(
output
.send_rb
.push_iter(vec![[0.; 2]; output.send_rb.free_len() - 1].into_iter()),
)
.unwrap();
(output, rx)
}
pub fn new_unfilled(
sample_rate: f32,
wait_for_output: bool,
frames_to_buffer: usize,
downsample_type: DownsampleType,
) -> (Self, AsyncHeapConsumer<[f32; 2]>) { ) -> (Self, AsyncHeapConsumer<[f32; 2]>) {
let rb_len = (sample_rate as usize / 60) * frames_to_buffer; let rb_len = (sample_rate as usize / 60) * frames_to_buffer;