implements PR014 a PR016
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
use prometeu_drivers::{AudioCommand, Channel, MAX_CHANNELS, OUTPUT_SAMPLE_RATE};
|
||||
use prometeu_hal::LoopMode;
|
||||
use ringbuf::traits::{Consumer, Producer, Split};
|
||||
use ringbuf::HeapRb;
|
||||
use ringbuf::traits::{Consumer, Producer, Split};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
@@ -93,6 +93,12 @@ pub struct HostAudio {
|
||||
_stream: Option<Box<dyn AudioStreamHandle>>,
|
||||
}
|
||||
|
||||
impl Default for HostAudio {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl HostAudio {
|
||||
pub fn new() -> Self {
|
||||
Self { producer: None, perf_consumer: None, _stream: None }
|
||||
@@ -150,7 +156,7 @@ impl HostAudio {
|
||||
pub fn send_commands(&mut self, commands: &mut Vec<AudioCommand>) {
|
||||
if let Some(producer) = &mut self.producer {
|
||||
for cmd in commands.drain(..) {
|
||||
if let Err(_) = producer.try_push(cmd) {
|
||||
if producer.try_push(cmd).is_err() {
|
||||
eprintln!("[HostAudio] Command ringbuffer full, dropping command.");
|
||||
}
|
||||
}
|
||||
@@ -301,6 +307,12 @@ pub struct AudioMixer {
|
||||
paused: bool,
|
||||
}
|
||||
|
||||
impl Default for AudioMixer {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl AudioMixer {
|
||||
pub fn new() -> Self {
|
||||
Self { voices: Default::default(), last_processing_time: Duration::ZERO, paused: false }
|
||||
|
||||
Reference in New Issue
Block a user