Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

DirectLook plays sound on outputs whose mix format is 24- or 32-bit integer (660)

gelenmedya67c2c8f34786
diff --git a/crates/rustdecoder/src/audio_out.rs b/crates/rustdecoder/src/audio_out.rs
index 93addffd..948ea3b0 100644
--- a/crates/rustdecoder/src/audio_out.rs
+++ b/crates/rustdecoder/src/audio_out.rs
@@ -573,14 +573,32 @@ fn open_stream(en: &IMMDeviceEnumerator) -> std::result::Result<Stream, String>
} else {
None
};
- let Some(format) = format else {
- CoTaskMemFree(Some(mix as *const _));
- return Err(format!("mix format not supported (tag {tag:#x}, {bits} bits)"));
- };
let (rate, channels) = (wf.nSamplesPerSec, wf.nChannels as usize);
- if let Err(e) = client.Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, 1_000_000, 0, mix, None) {
+ // A device whose mix format is neither 32-bit float nor 16-bit PCM (24- or 32-bit integer: common on headphones, USB and
+ // HDMI outputs) is given 32-bit float at its own rate and channels, and the audio engine converts. WHY (issue 660:
+ // "DirectLook: no audio"; it played through the TV, not through the headphones, and DirectLook was not even in the
+ // volume mixer): such a device was refused here and the video played silently. The preview pane's player always opened
+ // its stream this way, and had sound on the same PCs.
+ let float_for_any = WAVEFORMATEX {
+ wFormatTag: 3, // WAVE_FORMAT_IEEE_FLOAT
+ nChannels: wf.nChannels,
+ nSamplesPerSec: rate,
+ nAvgBytesPerSec: rate * u32::from(wf.nChannels) * 4,
+ nBlockAlign: wf.nChannels * 4,
+ wBitsPerSample: 32,
+ cbSize: 0,
+ };
+ let (format, flags, asked): (SampleFormat, u32, *const WAVEFORMATEX) = match format {
+ Some(f) => (f, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, mix),
+ None => (
+ SampleFormat::F32,
+ AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY,
+ &float_for_any,
+ ),
+ };
+ if let Err(e) = client.Initialize(AUDCLNT_SHAREMODE_SHARED, flags, 1_000_000, 0, asked, None) {
CoTaskMemFree(Some(mix as *const _));
- return fail("initialize", e);
+ return Err(format!("initialize (mix format tag {tag:#x}, {bits} bits): {e}"));
}
CoTaskMemFree(Some(mix as *const _));
let event = match CreateEventW(None, false, false, None) {