recording v1
This commit is contained in:
parent
2cfd60757a
commit
c978583863
|
@ -182,6 +182,12 @@ impl Iterator for Devices {
|
||||||
// so returning first in list as default
|
// so returning first in list as default
|
||||||
pub fn default_input_device() -> Option<Device> {
|
pub fn default_input_device() -> Option<Device> {
|
||||||
let mut driver_list = sys::get_driver_list();
|
let mut driver_list = sys::get_driver_list();
|
||||||
|
for dn in &driver_list{
|
||||||
|
if dn == "ASIO4ALL v2"{
|
||||||
|
println!("Defaulted to ASIO4ALL **remove from production**");
|
||||||
|
return Some(Device{ driver_name: dn.clone() });
|
||||||
|
}
|
||||||
|
}
|
||||||
match driver_list.pop() {
|
match driver_list.pop() {
|
||||||
Some(dn) => Some(Device{ driver_name: dn }),
|
Some(dn) => Some(Device{ driver_name: dn }),
|
||||||
None => None,
|
None => None,
|
||||||
|
|
|
@ -9,6 +9,7 @@ use std::marker::PhantomData;
|
||||||
use super::Device;
|
use super::Device;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use UnknownTypeOutputBuffer;
|
use UnknownTypeOutputBuffer;
|
||||||
|
use UnknownTypeInputBuffer;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use self::itertools::Itertools;
|
use self::itertools::Itertools;
|
||||||
|
@ -23,7 +24,7 @@ pub struct EventLoop {
|
||||||
pub struct StreamId(usize);
|
pub struct StreamId(usize);
|
||||||
|
|
||||||
pub struct InputBuffer<'a, T: 'a> {
|
pub struct InputBuffer<'a, T: 'a> {
|
||||||
marker: PhantomData<&'a T>,
|
buffer: &'a mut [T],
|
||||||
}
|
}
|
||||||
pub struct OutputBuffer<'a, T: 'a> {
|
pub struct OutputBuffer<'a, T: 'a> {
|
||||||
buffer: &'a mut [T],
|
buffer: &'a mut [T],
|
||||||
|
@ -43,7 +44,6 @@ impl EventLoop {
|
||||||
device: &Device,
|
device: &Device,
|
||||||
format: &Format,
|
format: &Format,
|
||||||
) -> Result<StreamId, CreationError> {
|
) -> Result<StreamId, CreationError> {
|
||||||
/*
|
|
||||||
let stream_type = sys::get_data_type(&device.driver_name).expect("Couldn't load data type");
|
let stream_type = sys::get_data_type(&device.driver_name).expect("Couldn't load data type");
|
||||||
match sys::prepare_stream(&device.driver_name) {
|
match sys::prepare_stream(&device.driver_name) {
|
||||||
Ok(stream) => {
|
Ok(stream) => {
|
||||||
|
@ -57,7 +57,6 @@ impl EventLoop {
|
||||||
let bytes_per_channel = format.data_type.sample_size();
|
let bytes_per_channel = format.data_type.sample_size();
|
||||||
let num_channels = format.channels.clone();
|
let num_channels = format.channels.clone();
|
||||||
|
|
||||||
// Get stream types
|
|
||||||
|
|
||||||
sys::set_callback(move |index| unsafe {
|
sys::set_callback(move |index| unsafe {
|
||||||
if let Some(ref asio_stream) = *asio_stream.lock().unwrap() {
|
if let Some(ref asio_stream) = *asio_stream.lock().unwrap() {
|
||||||
|
@ -86,20 +85,18 @@ impl EventLoop {
|
||||||
let mut buffer: Vec<$SampleType> = Vec::new();
|
let mut buffer: Vec<$SampleType> = Vec::new();
|
||||||
let length = channels[0].len();
|
let length = channels[0].len();
|
||||||
for i in 0..length{
|
for i in 0..length{
|
||||||
for channel in channels{
|
for channel in &channels{
|
||||||
buffer.push(channel[i]);
|
buffer.push(channel[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
// Deinter all the channels
|
|
||||||
let deinter_channels = deinterleave(&mut cpal_buffer[..],
|
|
||||||
num_channels as usize);
|
|
||||||
|
|
||||||
|
let mut channels: Vec<Vec<$SampleType>> = vec![Vec::new(); num_channels as usize];
|
||||||
// For each channel write the cpal data to
|
// For each channel write the cpal data to
|
||||||
// the asio buffer
|
// the asio buffer
|
||||||
// Also need to check for Endian
|
// Also need to check for Endian
|
||||||
for (i, channel) in deinter_channels.into_iter().enumerate(){
|
for (i, channel) in channels.iter_mut().enumerate(){
|
||||||
let buff_ptr = (asio_stream
|
let buff_ptr = (asio_stream
|
||||||
.buffer_infos[i]
|
.buffer_infos[i]
|
||||||
.buffers[index as usize] as *mut $AsioType)
|
.buffers[index as usize] as *mut $AsioType)
|
||||||
|
@ -108,14 +105,15 @@ impl EventLoop {
|
||||||
std::slice::from_raw_parts_mut(
|
std::slice::from_raw_parts_mut(
|
||||||
buff_ptr,
|
buff_ptr,
|
||||||
asio_stream.buffer_size as usize);
|
asio_stream.buffer_size as usize);
|
||||||
for (asio_s, cpal_s) in asio_buffer.iter_mut()
|
for asio_s in asio_buffer.iter(){
|
||||||
.zip(&channel){
|
channel.push( (*asio_s as i64 *
|
||||||
*asio_s = (*cpal_s as i64 *
|
::std::$SampleTypeIdent::MAX as i64 /
|
||||||
::std::$AsioTypeIdent::MAX as i64 /
|
::std::$AsioTypeIdent::MAX as i64) as $SampleType);
|
||||||
::std::$SampleTypeIdent::MAX as i64) as $AsioType;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// interleave all the channels
|
||||||
|
let inter_buffer = interleave(channels);
|
||||||
|
|
||||||
|
|
||||||
let buff = InputBuffer{
|
let buff = InputBuffer{
|
||||||
|
@ -126,12 +124,12 @@ impl EventLoop {
|
||||||
StreamData::Input{
|
StreamData::Input{
|
||||||
buffer: UnknownTypeInputBuffer::$SampleFormat(
|
buffer: UnknownTypeInputBuffer::$SampleFormat(
|
||||||
::InputBuffer{
|
::InputBuffer{
|
||||||
target: Some(super::super::InputBuffer::Asio(buff))
|
buffer: Some(super::super::InputBuffer::Asio(buff))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
// Generic over types
|
// Generic over types
|
||||||
// TODO check for endianess
|
// TODO check for endianess
|
||||||
match stream_type {
|
match stream_type {
|
||||||
|
@ -161,8 +159,6 @@ impl EventLoop {
|
||||||
Err(CreationError::DeviceNotAvailable)
|
Err(CreationError::DeviceNotAvailable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
unimplemented!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_output_stream(
|
pub fn build_output_stream(
|
||||||
|
@ -319,10 +315,9 @@ impl EventLoop {
|
||||||
|
|
||||||
impl<'a, T> InputBuffer<'a, T> {
|
impl<'a, T> InputBuffer<'a, T> {
|
||||||
pub fn buffer(&self) -> &[T] {
|
pub fn buffer(&self) -> &[T] {
|
||||||
unimplemented!()
|
&self.buffer
|
||||||
}
|
}
|
||||||
pub fn finish(self) {
|
pub fn finish(self) {
|
||||||
unimplemented!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue