Some cleanup in outputdefault test prog
This commit is contained in:
parent
52eb0206eb
commit
93c7f71d1c
@ -6,14 +6,15 @@ use std::io;
|
|||||||
use std::{thread, time};
|
use std::{thread, time};
|
||||||
// use
|
// use
|
||||||
|
|
||||||
fn spawn_stdin_channel() -> Receiver<String> {
|
/// Spawns a thread and waits for a single line, pushes it to the receiver and returns
|
||||||
|
fn stdin_channel_wait_for_return() -> Receiver<String> {
|
||||||
|
|
||||||
let (tx, rx) = unbounded();
|
let (tx, rx) = unbounded();
|
||||||
thread::spawn(move || 'tt: loop {
|
thread::spawn(move || {
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
io::stdin().read_line(&mut buffer).unwrap();
|
io::stdin().read_line(&mut buffer).unwrap();
|
||||||
if tx.send(buffer).is_err() {
|
// Do not care whether we succeed here.
|
||||||
break 'tt;
|
let _ = tx.send(buffer);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
rx
|
rx
|
||||||
}
|
}
|
||||||
@ -24,42 +25,42 @@ fn sleep(millis: u64) {
|
|||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let mut smgr = StreamMgr::new();
|
let mut smgr = StreamMgr::new();
|
||||||
|
|
||||||
println!("Starting stream...");
|
let stdin_channel = stdin_channel_wait_for_return();
|
||||||
smgr.startDefaultOutputStream()?;
|
|
||||||
let stdin_channel = spawn_stdin_channel();
|
|
||||||
|
|
||||||
println!("Creating signal generator...");
|
println!("Creating signal generator...");
|
||||||
let mut siggen = Siggen::newSineWave(2, 100.);
|
let mut siggen = Siggen::newSineWave(2, 432.);
|
||||||
siggen.setDCOffset(&[0.1, 0.]);
|
|
||||||
// let mut siggen = Siggen::newWhiteNoise(2);
|
// Some things that can be done
|
||||||
|
// siggen.setDCOffset(&[0.1, 0.]);
|
||||||
|
|
||||||
|
// Reduce all gains a bit...
|
||||||
siggen.setAllGains(0.1);
|
siggen.setAllGains(0.1);
|
||||||
// siggen.setMute(&[true, true]);
|
|
||||||
// siggen.setMute(&[true, false]);
|
// Apply signal generator
|
||||||
// siggen.setAllMute(false);
|
|
||||||
smgr.setSiggen(siggen)?;
|
smgr.setSiggen(siggen)?;
|
||||||
|
|
||||||
|
println!("Starting stream...");
|
||||||
|
smgr.startDefaultOutputStream()?;
|
||||||
|
|
||||||
|
println!("Press <enter> key to quit...");
|
||||||
'infy: loop {
|
'infy: loop {
|
||||||
match stdin_channel.try_recv() {
|
match stdin_channel.try_recv() {
|
||||||
Ok(_key) => break 'infy,
|
Ok(_key) => break 'infy,
|
||||||
Err(TryRecvError::Empty) => {}
|
Err(TryRecvError::Empty) => {}
|
||||||
Err(TryRecvError::Disconnected) => panic!("Channel disconnected"),
|
Err(TryRecvError::Disconnected) => panic!("Channel disconnected"),
|
||||||
}
|
}
|
||||||
sleep(1000);
|
sleep(100);
|
||||||
match smgr.getStatus(StreamType::Output) {
|
match smgr.getStatus(StreamType::Output) {
|
||||||
StreamStatus::NotRunning => {
|
StreamStatus::NotRunning => {
|
||||||
println!("Stream is not running?");
|
println!("Stream is not running?");
|
||||||
break 'infy;
|
break 'infy;
|
||||||
}
|
}
|
||||||
StreamStatus::Running => {
|
StreamStatus::Running => {}
|
||||||
println!("Stream is running...");
|
|
||||||
}
|
|
||||||
StreamStatus::Error(e) => {
|
StreamStatus::Error(e) => {
|
||||||
println!("Stream error: {}", e);
|
println!("Stream error: {}", e);
|
||||||
break 'infy;
|
break 'infy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// let stat = smgr.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user