-
Notifications
You must be signed in to change notification settings - Fork 504
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 4 commits
73f4294
3fd65a7
3c20149
a9f89aa
7542fac
8307def
1039391
e75d942
46ee54a
3157371
2eefede
35cfa20
72a94ca
dd1cc0f
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.
|
||
| /// 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
|
||
| } | ||
|
|
||
| #[cfg(all(target_os = "windows", feature = "asio"))] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make it discoverable on docs.rs: #[cfg_attr(docsrs, doc(cfg(all(target_os = "windows", feature = "asio"))))]
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you still take a look at this one?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it stands, I don't think any specific doc attributes are necessary since everything is available on all platforms and features. |
||
| 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 { | ||
|
roderickvd marked this conversation as resolved.
Outdated
|
||
| 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 { | ||
|
roderickvd marked this conversation as resolved.
Outdated
|
||
| 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.