Skip to content

Commit 3c20149

Browse files
committed
fix driver loading in device
1 parent 3fd65a7 commit 3c20149

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/host/asio/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod stream;
2525
///
2626
/// ASIO only supports loading a single driver at a time globally, so all Host instances
2727
/// must share the same underlying sys::Asio wrapper to properly coordinate driver access.
28-
static GLOBAL_ASIO: OnceLock<Arc<sys::Asio>> = OnceLock::new();
28+
pub(crate) static GLOBAL_ASIO: OnceLock<Arc<sys::Asio>> = OnceLock::new();
2929

3030
/// The host for ASIO.
3131
#[derive(Debug)]

src/platform/asio.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,27 @@ impl AsioDeviceExt for Device {
3131
}
3232

3333
fn asio_open_control_panel(&self) -> Result<(), BackendSpecificError> {
34+
use crate::host::asio::GLOBAL_ASIO;
3435
use crate::platform::DeviceInner;
3536

3637
if let DeviceInner::Asio(ref asio_device) = self.as_inner() {
37-
asio_device
38-
.driver
38+
let description = asio_device
39+
.description()
40+
.map_err(|e| BackendSpecificError {
41+
description: format!("Could not get device name: {:?}", e),
42+
})?;
43+
44+
let driver = GLOBAL_ASIO
45+
.get()
46+
.ok_or(BackendSpecificError {
47+
description: "ASIO not initialized.".into(),
48+
})?
49+
.load_driver(description.name())
50+
.map_err(|e| BackendSpecificError {
51+
description: format!("Failed to load driver: {:?}", e),
52+
})?;
53+
54+
driver
3955
.open_control_panel()
4056
.map_err(|e| BackendSpecificError {
4157
description: format!("Failed to open control panel: {:?}", e),

0 commit comments

Comments
 (0)