-
Notifications
You must be signed in to change notification settings - Fork 465
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
Conversation
|
Hey! I think the asio-sys part is worth having regardless of the cpal API discussion. While I believe the ASIO control panels are blocking modals, it seems that PortAudio and JUCE also expose them. For the build script changes: the linker errors make sense - Re: the cpal API, I agree we should use extension traits rather than exposing this through // In src/platform/asio.rs or similar
#[cfg(all(target_os = "windows", feature = "asio"))]
pub trait AsioDeviceExt {
fn asio_open_control_panel(&self) -> Result<(), BackendSpecificError>;
}
impl AsioDeviceExt for Device {
fn asio_open_control_panel(&self) -> Result<(), BackendSpecificError> {
if let DeviceInner::Asio(ref d) = self.as_inner() {
d.open_control_panel()
} else {
// or maybe introduce a new error variant
Err(BackendSpecificError {
description: "Not an ASIO device".to_string(),
})
}
}
}Usage would be like: use cpal::platform::asio::AsioDeviceExt;
let device = host.default_output_device()?;
device.asio_open_control_panel()?;This keeps the main |
|
Had the above extension traits in mind for v0.18 by the way, not v0.17. |
|
Cool, trying out the extension trait now. It seems pretty nice! How I did it right now still has the problem with docs not generating though. |
roderickvd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some considerations inline. Let's pay particular attention to getting the extension traits right. When we start adding them, it'd be highly desirable to keep them consistent and stable for the other hosts and time to come.
Also don't forget about a changelog entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making this an example in asio-sys/examples instead?
| use crate::BackendSpecificError; | ||
| use crate::Device; | ||
|
|
||
| pub trait AsioDeviceExt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like the public API to have good documentation. Proposal:
/// Extension trait for ASIO-specific device functionality.
| use crate::Device; | ||
|
|
||
| pub trait AsioDeviceExt { | ||
| fn asio_open_control_panel(&self) -> Result<(), BackendSpecificError>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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 blocks 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.
| #[cfg(feature = "custom")] | ||
| pub use crate::host::custom::{Device as CustomDevice, Host as CustomHost, Stream as CustomStream}; | ||
|
|
||
| #[cfg(all(target_os = "windows", feature = "asio"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cross-platform compatibility in downstream code, the configuration guard should be moved from here into platform/asio.rs like so:
#[cfg(all(target_os = "windows", feature = "asio"))]
impl AsioDeviceExt for Device {
// ...
}
#[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())
}
fn asio_reset_device(&self) -> Result<(), BackendSpecificError> {
Err(not_available())
}
}
fn not_available() -> BackendSpecificError {
BackendSpecificError {
description: "ASIO is not available on this platform".to_string(),
}
}
Just putting this here for now so people know it is at least possible.
Will have to think about a proper API if we want to include this. (extension traits?)
I would also be fine having this only exposed in asio-sys for now, but you'd need to expose driver internals if you want to use it from cpal.
Also, I had to modify the build script to get rid of linker errors, not sure what's up with that.