aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/audio.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-10-12 21:04:22 +0200
committerGitHub <noreply@github.com>2020-10-12 21:04:22 +0200
commit7a7499aeaa45a33aed4b3bfd339c950fa21e1a08 (patch)
tree4cbc408c5813bc37a213cd0476417e7b905fd83e /mumd/src/audio.rs
parent2deba9cda37de3fcc04d3ec11ffea0f18a0dbb69 (diff)
downloadmum-7a7499aeaa45a33aed4b3bfd339c950fa21e1a08.tar.gz
change to actual logging (#2)
Diffstat (limited to 'mumd/src/audio.rs')
-rw-r--r--mumd/src/audio.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs
index eeae4da..9b794a6 100644
--- a/mumd/src/audio.rs
+++ b/mumd/src/audio.rs
@@ -4,6 +4,7 @@ use cpal::traits::HostTrait;
use cpal::{
InputCallbackInfo, OutputCallbackInfo, Sample, SampleFormat, SampleRate, Stream, StreamConfig,
};
+use log::*;
use mumble_protocol::voice::VoicePacketPayload;
use opus::Channels;
use std::collections::hash_map::Entry;
@@ -62,7 +63,7 @@ impl Audio {
let input_supported_sample_format = input_supported_config.sample_format();
let input_config: StreamConfig = input_supported_config.into();
- let err_fn = |err| eprintln!("an error occurred on the output audio stream: {}", err);
+ let err_fn = |err| error!("An error occurred on the output audio stream: {}", err);
let client_streams = Arc::new(Mutex::new(HashMap::new()));
let output_stream = match output_supported_sample_format {
@@ -90,7 +91,7 @@ impl Audio {
1 => Channels::Mono,
2 => Channels::Stereo,
_ => unimplemented!(
- "only 1 or 2 channels supported, got {})",
+ "Only 1 or 2 channels supported, got {})",
input_config.channels
),
},
@@ -147,7 +148,7 @@ impl Audio {
.decode_packet(payload, self.output_config.channels as usize);
}
Entry::Vacant(_) => {
- eprintln!("cannot find session id {}", session_id);
+ warn!("Can't find session id {}", session_id);
}
}
}
@@ -155,7 +156,7 @@ impl Audio {
pub fn add_client(&self, session_id: u32) {
match self.client_streams.lock().unwrap().entry(session_id) {
Entry::Occupied(_) => {
- eprintln!("session id {} already exists", session_id);
+ warn!("Session id {} already exists", session_id);
}
Entry::Vacant(entry) => {
entry.insert(ClientStream::new(
@@ -172,8 +173,8 @@ impl Audio {
entry.remove();
}
Entry::Vacant(_) => {
- eprintln!(
- "tried to remove session id {} that doesn't exist",
+ warn!(
+ "Tried to remove session id {} that doesn't exist",
session_id
);
}
@@ -194,7 +195,7 @@ impl ClientStream {
match channels {
1 => Channels::Mono,
2 => Channels::Stereo,
- _ => unimplemented!("only 1 or 2 channels supported, got {}", channels),
+ _ => unimplemented!("Only 1 or 2 channels supported, got {}", channels),
},
)
.unwrap(),
@@ -207,12 +208,12 @@ impl ClientStream {
let mut out: Vec<f32> = vec![0.0; 720 * channels * 4]; //720 is because that is the max size of packet we can get that we want to decode
let parsed = self.opus_decoder
.decode_float(&bytes, &mut out, false)
- .expect("error decoding");
+ .expect("Error decoding");
out.truncate(parsed);
self.buffer.extend(out);
}
_ => {
- unimplemented!("payload type not supported");
+ unimplemented!("Payload type not supported");
}
}
}