Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/xcl/src/hle/xaudio2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,10 @@ pub fn note_console_decode(packets: u64, errors: u64, frames: u64, nonzero: u64)
mod tests {
use super::*;

/// Held by the tests that submit buffers to an XMA voice: they move the process-wide XMA
/// counters, and one of them compares those counters before and after its own submits.
static XMA_COUNTERS: Mutex<()> = Mutex::new(());

fn xma2(channels: u16, rate: u32, samples: u32, bpb: u32, blocks: u16) -> Xma2WaveFormatEx {
Xma2WaveFormatEx {
wfx: WaveFormatEx { tag: WAVE_FORMAT_XMA2, channels, rate, avg_bytes: 0, block_align: 1, bits: 16, cb_size: 34 },
Expand Down Expand Up @@ -1399,6 +1403,7 @@ mod tests {

#[test]
fn xma_voice_keeps_the_decoders_ten_channels() {
let _counters = XMA_COUNTERS.lock().unwrap_or_else(|e| e.into_inner());
unsafe {
let mut eng: *mut c_void = std::ptr::null_mut();
assert_eq!(XAudio2Create(&mut eng, 0, 1), S_OK);
Expand Down Expand Up @@ -1684,6 +1689,7 @@ mod tests {
#[test]
fn xma2_source_voice_decodes_and_manages_lifetime() {
use std::sync::atomic::AtomicUsize;
let _counters = XMA_COUNTERS.lock().unwrap_or_else(|e| e.into_inner());

static ENDED: AtomicUsize = AtomicUsize::new(0);
static STARTED: AtomicUsize = AtomicUsize::new(0);
Expand Down
Loading