X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/1a444762d8fd7d48e4f56a87c6bd77f837522d5d..bc6fb90d7053082e7aaf261f4da8905c49e9fe01:/m17codec2/src/lib.rs?ds=inline diff --git a/m17codec2/src/lib.rs b/m17codec2/src/lib.rs index 0f3c8a5..1d05f27 100755 --- a/m17codec2/src/lib.rs +++ b/m17codec2/src/lib.rs @@ -8,10 +8,7 @@ use m17app::adapter::StreamAdapter; use m17app::app::TxHandle; use m17app::link_setup::LinkSetup; use m17app::link_setup::M17Address; -use m17core::address::Address; -use m17core::address::Callsign; -use m17core::protocol::LsfFrame; -use m17core::protocol::StreamFrame; +use m17app::StreamFrame; use std::collections::VecDeque; use std::fs::File; use std::io::Write; @@ -64,6 +61,12 @@ impl Codec2Adapter { } } +impl Default for Codec2Adapter { + fn default() -> Self { + Self::new() + } +} + struct AdapterState { tx: Option, /// Circular buffer of output samples for playback @@ -186,8 +189,8 @@ impl WavePlayer { loop { let mut last_one = false; - for mut out in out_buf.chunks_mut(8) { - for i in 0..160 { + for out in out_buf.chunks_mut(8) { + for i in in_buf.iter_mut() { let sample = match samples.next() { Some(Ok(sample)) => sample, _ => { @@ -195,16 +198,16 @@ impl WavePlayer { 0 } }; - in_buf[i] = sample; + *i = sample; } - codec.encode(&mut out, &in_buf); + codec.encode(out, &in_buf); } tx.transmit_stream_next(&StreamFrame { lich_idx: lsf_chunk as u8, lich_part: setup.lich_part(lsf_chunk as u8), frame_number, end_of_stream: last_one, - stream_data: out_buf.clone(), + stream_data: out_buf, }); frame_number += 1; lsf_chunk = (lsf_chunk + 1) % 6;