diff --git a/debugmac.txt b/debugmac.txt new file mode 100644 index 0000000..1128599 --- /dev/null +++ b/debugmac.txt @@ -0,0 +1,4 @@ + Ok("MacBook Pro Speakers") + Ok("ZoomAudioDevice") +Ok("MacBook Pro Speakers") +SupportedStreamConfig { channels: 2, sample_rate: SampleRate(44100), buffer_size: Range { min: 15, max: 4096 }, sample_format: F32 } diff --git a/src/rx/main.rs b/src/rx/main.rs index 7cfee7d..c5286b5 100644 --- a/src/rx/main.rs +++ b/src/rx/main.rs @@ -1,13 +1,13 @@ use tokio::net::TcpStream; -use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; +use tokio::io::{AsyncWriteExt}; use std::error::Error; -use cpal::traits::HostTrait; + #[tokio::main] async fn main() -> Result<(), Box> { // Connect to a peer let mut stream = TcpStream::connect("127.0.0.1:8080").await?; - + let mut _buffer = [0, 16]; // Write some data. stream.write_all(b"hello world!").await?; diff --git a/src/tx/main.rs b/src/tx/main.rs index ee6bd41..a04f18e 100644 --- a/src/tx/main.rs +++ b/src/tx/main.rs @@ -1,4 +1,4 @@ -use tokio::io::{self, AsyncReadExt}; +use tokio::io::{self, AsyncReadExt,AsyncWriteExt}; use tokio::net::TcpListener; use std::str; @@ -13,11 +13,17 @@ async fn main() -> io::Result<()> { //init the host and device let host = cpal::default_host(); let device = host.default_output_device().expect("No output device available"); - //let in_device = host.default_input_device().expect("balls"); + // let in_device = host.default_input_device().expect("balls"); //println!("{:?}", host.output_devices().unwrap().next().unwrap().name()); for dev in host.output_devices().unwrap() { - println!("{:?}", dev.name()); + println!(" {:?}", dev.name()); } + println!("{:?}",device.name()); + /* println!("\n"); + for dev in host.input_devices().unwrap() { + print!(" {:?}", dev.name()); + } */ + //output let mut supported_output_configs_range = device.supported_output_configs() @@ -28,13 +34,13 @@ async fn main() -> io::Result<()> { println!("{:?}", supported_output_config); - /* //input + /* //input let mut supported_input_configs_range = in_device.supported_input_configs() .expect("error querying input"); let mut supported_input_config = supported_input_configs_range.next() .expect("input no supported config :(") .with_max_sample_rate(); - println!("{:?}",supported_input_config); */ + println!("{:?}",supported_input_config); */ /*SupportedStreamConfig { channels: 1, @@ -46,31 +52,32 @@ async fn main() -> io::Result<()> { //setting config due to default configs let config = StreamConfig { channels: 1, - sample_rate: cpal::SampleRate(384000), - buffer_size: Fixed(384), + sample_rate: cpal::SampleRate(441000), + buffer_size: Fixed(16), }; //init stream - let stream = device.build_output_stream( + let stream_out = device.build_output_stream( &config, move |data: &mut [f32], _: &cpal::OutputCallbackInfo| { // react to stream events and read or write stream data here. - //`println!("{:?}",data); + //println!("{:?}",data); }, move |_err| { // react to errors here. panic!("shit fucked!"); }, ).unwrap(); - stream.play(); + stream_out.play(); //temp bc buffer size will be set in cpal - let mut buffer = [0; 11]; + let mut buffer = [0; 16]; loop { let (mut socket, addr) = listener.accept().await?; let msg = socket.read(&mut buffer[..]).await?; println!("{}: {:?}",addr,str::from_utf8(&buffer[..msg])); + socket.write_all(b"pong").await?; } }