Initial gui working
This commit is contained in:
9 files changed
+3615
-103
No files matched your search
@@ -1,3 +1,4 @@
|
||||
pub mod audio_source_thread;
|
||||
pub mod tx_thread;
|
||||
pub mod udp_connection;
|
||||
pub mod util;
|
||||
@@ -95,7 +95,14 @@ impl<T: Read + Write> TxThread<T> {
|
||||
info!("Starting TX Thread...");
|
||||
loop {
|
||||
if let Err(err) = self.handle_msg() {
|
||||
error!("Failed to process message: {err:?}")
|
||||
match err {
|
||||
Error::RecvFailed(_err) => {
|
||||
return;
|
||||
}
|
||||
_ => {
|
||||
error!("Failed to process message: {err:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
use std::io::{Read, Write};
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OpusUdpConnection {
|
||||
udp_socket: UdpSocket,
|
||||
dest: SocketAddr,
|
||||
}
|
||||
|
||||
impl OpusUdpConnection {
|
||||
pub fn new(src: SocketAddr, dest: SocketAddr) -> Result<Self, std::io::Error> {
|
||||
Ok(Self {
|
||||
udp_socket: UdpSocket::bind(src)?,
|
||||
dest,
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn set_read_timeout(&mut self, timeout: Option<Duration>) -> std::io::Result<()> {
|
||||
self.udp_socket.set_read_timeout(timeout)
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for OpusUdpConnection {
|
||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||
self.udp_socket.send_to(buf, self.dest)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Read for OpusUdpConnection {
|
||||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||
self.udp_socket.recv(buf)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user