sample rate support
This commit is contained in:
parent
b0b0484d4b
commit
6e0eb073d1
7 changed files with 150 additions and 17 deletions
|
|
@ -4,6 +4,14 @@ extern "C" ASIOError get_sample_rate(double * rate){
|
|||
return ASIOGetSampleRate(reinterpret_cast<ASIOSampleRate *>(rate));
|
||||
}
|
||||
|
||||
extern "C" ASIOError set_sample_rate(double rate){
|
||||
return ASIOSetSampleRate(rate);
|
||||
}
|
||||
|
||||
extern "C" ASIOError can_sample_rate(double rate){
|
||||
return ASIOCanSampleRate(rate);
|
||||
}
|
||||
|
||||
extern AsioDrivers* asioDrivers;
|
||||
bool loadAsioDriver(char *name);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@
|
|||
// Helper function to wrap confusing preprocessor
|
||||
extern "C" ASIOError get_sample_rate(double * rate);
|
||||
|
||||
// Helper function to wrap confusing preprocessor
|
||||
extern "C" ASIOError set_sample_rate(double rate);
|
||||
|
||||
// Helper function to wrap confusing preprocessor
|
||||
extern "C" ASIOError can_sample_rate(double rate);
|
||||
|
||||
extern "C" bool load_asio_driver(char * name);
|
||||
extern "C" void remove_current_driver();
|
||||
extern "C" long get_driver_names(char **names, long maxDrivers);
|
||||
|
|
@ -167,6 +167,8 @@ fn create_bindings(cpal_asio_dir: &PathBuf) {
|
|||
.whitelist_function("ASIOGetChannelInfo")
|
||||
.whitelist_function("ASIOGetBufferSize")
|
||||
.whitelist_function("get_sample_rate")
|
||||
.whitelist_function("set_sample_rate")
|
||||
.whitelist_function("can_sample_rate")
|
||||
.whitelist_function("ASIOInit")
|
||||
.whitelist_function("ASIOCreateBuffers")
|
||||
.whitelist_function("ASIOStart")
|
||||
|
|
|
|||
|
|
@ -238,6 +238,24 @@ impl Drivers {
|
|||
|
||||
sample_rate
|
||||
}
|
||||
|
||||
pub fn set_sample_rate(&self, sample_rate: u32) -> Result<(), AsioError>{
|
||||
// Initialize memory for calls
|
||||
let rate: c_double = c_double::from(sample_rate);
|
||||
|
||||
unsafe {
|
||||
get_drivers().asio_set_sample_rate(rate)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_sample_rate(&self, sample_rate: u32) -> bool {
|
||||
// Initialize memory for calls
|
||||
let rate: c_double = c_double::from(sample_rate);
|
||||
|
||||
unsafe {
|
||||
get_drivers().asio_can_sample_rate(rate).is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_data_type(&self) -> Result<AsioSampleType, AsioDriverError> {
|
||||
// Initialize memory for calls
|
||||
|
|
@ -538,6 +556,24 @@ unsafe fn asio_get_sample_rate(&mut self, rate: &mut c_double) -> Result<(), Asi
|
|||
}
|
||||
}
|
||||
|
||||
unsafe fn asio_set_sample_rate(&mut self, rate: c_double) -> Result<(), AsioError> {
|
||||
if let AsioState::Offline = self.state {
|
||||
Err(AsioError::NoDrivers)
|
||||
} else {
|
||||
let result = ai::set_sample_rate(rate);
|
||||
asio_result!(result)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn asio_can_sample_rate(&mut self, rate: c_double) -> Result<(), AsioError> {
|
||||
if let AsioState::Offline = self.state {
|
||||
Err(AsioError::NoDrivers)
|
||||
} else {
|
||||
let result = ai::can_sample_rate(rate);
|
||||
asio_result!(result)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn asio_get_channel_info(&mut self, ci: &mut ai::ASIOChannelInfo) -> Result<(), AsioError> {
|
||||
if let AsioState::Offline = self.state {
|
||||
Err(AsioError::NoDrivers)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue