diff --git a/crates/xcl/src/hle/xaudio2.rs b/crates/xcl/src/hle/xaudio2.rs index 38f9912727..41adedcfad 100644 --- a/crates/xcl/src/hle/xaudio2.rs +++ b/crates/xcl/src/hle/xaudio2.rs @@ -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 }, @@ -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); @@ -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);