-
Notifications
You must be signed in to change notification settings - Fork 491
ASIO: open control panel #1074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
ASIO: open control panel #1074
Changes from 3 commits
73f4294
3fd65a7
3c20149
a9f89aa
7542fac
8307def
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| //! Implementations for ASIO-specific device functionality. | ||
|
|
||
| use crate::BackendSpecificError; | ||
| use crate::Device; | ||
|
|
||
| /// Extension trait for ASIO-specific device functionality. | ||
| pub trait AsioDeviceExt { | ||
Sin-tel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// Returns `true` if this device is an ASIO device. | ||
| fn is_asio_device(&self) -> bool; | ||
|
|
||
| /// Opens the ASIO driver's control panel window. | ||
| /// | ||
| /// This provides access to device-specific settings like buffer size, | ||
| /// sample rate, input/output routing, and hardware-specific features. | ||
| /// | ||
| /// # Blocking Behavior | ||
| /// | ||
| /// **WARNING**: This call may block until the user closes the control panel. | ||
| /// Consider spawning a thread to avoid blocking the main thread. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns an error if this device is not an ASIO device. | ||
| fn asio_open_control_panel(&self) -> Result<(), BackendSpecificError>; | ||
Sin-tel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| #[cfg(all(target_os = "windows", feature = "asio"))] | ||
|
||
| impl AsioDeviceExt for Device { | ||
| fn is_asio_device(&self) -> bool { | ||
| matches!(self.as_inner(), crate::platform::DeviceInner::Asio(_)) | ||
| } | ||
|
|
||
| fn asio_open_control_panel(&self) -> Result<(), BackendSpecificError> { | ||
| use crate::host::asio::GLOBAL_ASIO; | ||
| use crate::platform::DeviceInner; | ||
|
|
||
| if let DeviceInner::Asio(ref asio_device) = self.as_inner() { | ||
| let description = asio_device | ||
| .description() | ||
| .map_err(|e| BackendSpecificError { | ||
| description: format!("Could not get device name: {:?}", e), | ||
| })?; | ||
|
|
||
| let driver = GLOBAL_ASIO | ||
| .get() | ||
| .ok_or(BackendSpecificError { | ||
|
||
| description: "ASIO not initialized.".into(), | ||
| })? | ||
| .load_driver(description.name()) | ||
| .map_err(|e| BackendSpecificError { | ||
| description: format!("Failed to load driver: {:?}", e), | ||
| })?; | ||
|
|
||
| driver | ||
| .open_control_panel() | ||
| .map_err(|e| BackendSpecificError { | ||
| description: format!("Failed to open control panel: {:?}", e), | ||
| }) | ||
| } else { | ||
| Err(BackendSpecificError { | ||
|
||
| description: "Not an ASIO device".to_string(), | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(all(target_os = "windows", feature = "asio")))] | ||
| impl AsioDeviceExt for Device { | ||
| fn is_asio_device(&self) -> bool { | ||
| false | ||
| } | ||
|
|
||
| fn asio_open_control_panel(&self) -> Result<(), BackendSpecificError> { | ||
| Err(not_available()) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(all(target_os = "windows", feature = "asio")))] | ||
| fn not_available() -> BackendSpecificError { | ||
| BackendSpecificError { | ||
| description: "ASIO is not available on this platform".to_string(), | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.