refactor: resync with qbqt baseline and restore genre browser
Some checks failed
Build for Windows / build-windows (push) Has been cancelled

This commit is contained in:
joren
2026-03-30 22:36:39 +02:00
parent 200ef39d04
commit 3346b424b3
26 changed files with 8533 additions and 446 deletions

View File

@@ -3,7 +3,7 @@ use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
StreamConfig,
};
use rb::{RbConsumer, RbProducer, SpscRb, RB};
use rb::{RbConsumer, RbInspector, RbProducer, SpscRb, RB};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
@@ -13,6 +13,7 @@ use symphonia::core::audio::AudioBufferRef;
const RING_BUFFER_SIZE: usize = 32 * 1024;
pub struct AudioOutput {
_ring: SpscRb<f32>,
ring_buf_producer: rb::Producer<f32>,
_stream: cpal::Stream,
pub sample_rate: u32,
@@ -50,6 +51,7 @@ impl AudioOutput {
stream.play()?;
Ok(Self {
_ring: ring,
ring_buf_producer: producer,
_stream: stream,
sample_rate,
@@ -87,4 +89,13 @@ impl AudioOutput {
}
Ok(())
}
pub fn flush(&self) {
// Wait until the ring buffer is fully emptied by cpal
while !self._ring.is_empty() {
std::thread::sleep(std::time::Duration::from_millis(10));
}
// Give the physical DAC an extra 100ms to output the last samples
std::thread::sleep(std::time::Duration::from_millis(100));
}
}