Refactor asio message to use a match expr. Fix some typos.

This commit is contained in:
mitchmindtree 2019-07-05 13:19:42 +02:00
parent 64dc6accf9
commit 714dab7270
2 changed files with 14 additions and 18 deletions

View File

@ -783,7 +783,6 @@ extern "C" fn asio_message(
_message: *mut (), _message: *mut (),
_opt: *mut c_double, _opt: *mut c_double,
) -> c_long { ) -> c_long {
let mut ret = 0;
match selector { match selector {
ai::kAsioSelectorSupported => { ai::kAsioSelectorSupported => {
// Indicate what message selectors are supported. // Indicate what message selectors are supported.
@ -795,20 +794,18 @@ extern "C" fn asio_message(
// Following added in ASIO 2.0. // Following added in ASIO 2.0.
| ai::kAsioSupportsTimeInfo | ai::kAsioSupportsTimeInfo
| ai::kAsioSupportsTimeCode | ai::kAsioSupportsTimeCode
| ai::kAsioSupportsInputMonitor => { | ai::kAsioSupportsInputMonitor => 1,
ret = 1; _ => 0,
}
_ => (),
} }
} }
ai::kAsioResetRequest => { ai::kAsioResetRequest => {
// Defer the task and perform the reset of the driver during the next "safe" situation // Defer the task and perform the reset of the driver during the next "safe" situation
// You cannot reset the driver right now, as this code is called from the driver. Reset // You cannot reset the driver right now, as this code is called from the driver. Reset
// the driver is done by completely destruct is. I.e. ASIOStop(), ASIODisposeBuffers(), // the driver is done by completely destruct it. I.e. ASIOStop(), ASIODisposeBuffers(),
// Destruction. Afterwards you initialize the driver again. // Destruction. Afterwards you initialize the driver again.
// TODO: Handle this. // TODO: Handle this.
ret = 1; 1
} }
ai::kAsioResyncRequest => { ai::kAsioResyncRequest => {
@ -818,7 +815,7 @@ extern "C" fn asio_message(
// which could loose data because the Mutex was hold too long by another thread. // which could loose data because the Mutex was hold too long by another thread.
// However a driver can issue it in other situations, too. // However a driver can issue it in other situations, too.
// TODO: Handle this. // TODO: Handle this.
ret = 1; 1
} }
ai::kAsioLatenciesChanged => { ai::kAsioLatenciesChanged => {
@ -826,37 +823,37 @@ extern "C" fn asio_message(
// Beware, it this does not mean that the buffer sizes have changed! You might need to // Beware, it this does not mean that the buffer sizes have changed! You might need to
// update internal delay data. // update internal delay data.
// TODO: Handle this. // TODO: Handle this.
ret = 1; 1
} }
ai::kAsioEngineVersion => { ai::kAsioEngineVersion => {
// Return the supported ASIO version of the host application If a host applications // Return the supported ASIO version of the host application If a host applications
// does not implement this selector, ASIO 1.0 is assumed by the driver // does not implement this selector, ASIO 1.0 is assumed by the driver
ret = 2; 2
} }
ai::kAsioSupportsTimeInfo => { ai::kAsioSupportsTimeInfo => {
// Informs the driver whether the asioCallbacks.bufferSwitchTimeInfo() callback is // Informs the driver whether the asioCallbacks.bufferSwitchTimeInfo() callback is
// supported. For compatibility with ASIO 1.0 drivers the host application should // supported. For compatibility with ASIO 1.0 drivers the host application should
// always support the "old" bufferSwitch method, too, which we do. // always support the "old" bufferSwitch method, too, which we do.
ret = 1; 1
} }
ai::kAsioSupportsTimeCode => { ai::kAsioSupportsTimeCode => {
// Informs the driver whether the application is interested in time code info. If an // Informs the driver whether the application is interested in time code info. If an
// application does not need to know about time code, the driver has less work to do. // application does not need to know about time code, the driver has less work to do.
// TODO: Provide an option for this? // TODO: Provide an option for this?
ret = 0; 0
} }
_ => (), // Unknown/unhandled message type. _ => 0, // Unknown/unhandled message type.
} }
ret
} }
/// Similar to buffer switch but with time info /// Similar to buffer switch but with time info.
/// Not currently used ///
/// If only `buffer_switch` is called by the driver instead, the `buffer_switch` callback will
/// create the necessary timing info and call this function.
/// ///
/// TODO: Provide some access to `ai::ASIOTime` once CPAL gains support for time stamps. /// TODO: Provide some access to `ai::ASIOTime` once CPAL gains support for time stamps.
extern "C" fn buffer_switch_time_info( extern "C" fn buffer_switch_time_info(

View File

@ -523,7 +523,6 @@ mod platform_impl {
} }
} }
// TODO: Add `Asio asio` once #221 lands.
#[cfg(windows)] #[cfg(windows)]
mod platform_impl { mod platform_impl {
#[cfg(feature = "asio")] #[cfg(feature = "asio")]