nothing was achieved
This commit is contained in:
parent
4268f87013
commit
6a7f563c32
4
debugmac.txt
Normal file
4
debugmac.txt
Normal file
|
@ -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 }
|
|
@ -1,13 +1,13 @@
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncWriteExt};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use cpal::traits::HostTrait;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn Error>> {
|
async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// Connect to a peer
|
// Connect to a peer
|
||||||
let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
|
let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
|
||||||
|
let mut _buffer = [0, 16];
|
||||||
// Write some data.
|
// Write some data.
|
||||||
stream.write_all(b"hello world!").await?;
|
stream.write_all(b"hello world!").await?;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use tokio::io::{self, AsyncReadExt};
|
use tokio::io::{self, AsyncReadExt,AsyncWriteExt};
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
use std::str;
|
use std::str;
|
||||||
|
@ -13,11 +13,17 @@ async fn main() -> io::Result<()> {
|
||||||
//init the host and device
|
//init the host and device
|
||||||
let host = cpal::default_host();
|
let host = cpal::default_host();
|
||||||
let device = host.default_output_device().expect("No output device available");
|
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());
|
//println!("{:?}", host.output_devices().unwrap().next().unwrap().name());
|
||||||
for dev in host.output_devices().unwrap() {
|
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
|
//output
|
||||||
let mut supported_output_configs_range = device.supported_output_configs()
|
let mut supported_output_configs_range = device.supported_output_configs()
|
||||||
|
@ -28,13 +34,13 @@ async fn main() -> io::Result<()> {
|
||||||
println!("{:?}", supported_output_config);
|
println!("{:?}", supported_output_config);
|
||||||
|
|
||||||
|
|
||||||
/* //input
|
/* //input
|
||||||
let mut supported_input_configs_range = in_device.supported_input_configs()
|
let mut supported_input_configs_range = in_device.supported_input_configs()
|
||||||
.expect("error querying input");
|
.expect("error querying input");
|
||||||
let mut supported_input_config = supported_input_configs_range.next()
|
let mut supported_input_config = supported_input_configs_range.next()
|
||||||
.expect("input no supported config :(")
|
.expect("input no supported config :(")
|
||||||
.with_max_sample_rate();
|
.with_max_sample_rate();
|
||||||
println!("{:?}",supported_input_config); */
|
println!("{:?}",supported_input_config); */
|
||||||
|
|
||||||
/*SupportedStreamConfig {
|
/*SupportedStreamConfig {
|
||||||
channels: 1,
|
channels: 1,
|
||||||
|
@ -46,31 +52,32 @@ async fn main() -> io::Result<()> {
|
||||||
//setting config due to default configs
|
//setting config due to default configs
|
||||||
let config = StreamConfig {
|
let config = StreamConfig {
|
||||||
channels: 1,
|
channels: 1,
|
||||||
sample_rate: cpal::SampleRate(384000),
|
sample_rate: cpal::SampleRate(441000),
|
||||||
buffer_size: Fixed(384),
|
buffer_size: Fixed(16),
|
||||||
};
|
};
|
||||||
|
|
||||||
//init stream
|
//init stream
|
||||||
let stream = device.build_output_stream(
|
let stream_out = device.build_output_stream(
|
||||||
&config,
|
&config,
|
||||||
move |data: &mut [f32], _: &cpal::OutputCallbackInfo| {
|
move |data: &mut [f32], _: &cpal::OutputCallbackInfo| {
|
||||||
// react to stream events and read or write stream data here.
|
// react to stream events and read or write stream data here.
|
||||||
//`println!("{:?}",data);
|
//println!("{:?}",data);
|
||||||
},
|
},
|
||||||
move |_err| {
|
move |_err| {
|
||||||
// react to errors here.
|
// react to errors here.
|
||||||
panic!("shit fucked!");
|
panic!("shit fucked!");
|
||||||
},
|
},
|
||||||
).unwrap();
|
).unwrap();
|
||||||
stream.play();
|
stream_out.play();
|
||||||
|
|
||||||
//temp bc buffer size will be set in cpal
|
//temp bc buffer size will be set in cpal
|
||||||
let mut buffer = [0; 11];
|
let mut buffer = [0; 16];
|
||||||
loop {
|
loop {
|
||||||
let (mut socket, addr) = listener.accept().await?;
|
let (mut socket, addr) = listener.accept().await?;
|
||||||
|
|
||||||
let msg = socket.read(&mut buffer[..]).await?;
|
let msg = socket.read(&mut buffer[..]).await?;
|
||||||
println!("{}: {:?}",addr,str::from_utf8(&buffer[..msg]));
|
println!("{}: {:?}",addr,str::from_utf8(&buffer[..msg]));
|
||||||
|
socket.write_all(b"pong").await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue