summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2023-06-18 16:10:39 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2023-06-18 16:10:39 +0200
commit54ede18180302b14e7de9cc033d1be66592db796 (patch)
tree8f972503fe31ae5cf18f799d915c72c3a0aa1045
parent27c26a2ac5b4df8ba0b8f3f19933a5b213ac5799 (diff)
downloadnihav-player-54ede18180302b14e7de9cc033d1be66592db796.tar.gz
improve error reporting in audio decoder part
-rw-r--r--videoplayer/src/audiodec.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/videoplayer/src/audiodec.rs b/videoplayer/src/audiodec.rs
index 3ed6398..bddec57 100644
--- a/videoplayer/src/audiodec.rs
+++ b/videoplayer/src/audiodec.rs
@@ -122,7 +122,7 @@ impl AudioCallback for AudioOutput {
type Channel = i16;
fn callback(&mut self, out: &mut [Self::Channel]) {
- let mut queue = self.queue.lock().unwrap();
+ let mut queue = self.queue.lock().expect("audio queue should be accessible");
let dstlen = out.len();
let copylen = queue.fill().min(dstlen);
let volume = AUDIO_VOLUME.load(Ordering::Relaxed) as i32;
@@ -183,9 +183,9 @@ fn start_audio_decoding(asystem: &AudioSubsystem, ainfo: NAAudioInfo, mut audio_
let adec = if let DecoderType::Audio(ref mut dec) = audio_dec.dec { dec } else { panic!("not an audio decoder!"); };
let mut samplepos = 0usize;
let dst_chmap = if dst_info.channels == 2 {
- NAChannelMap::from_str("L,R").unwrap()
+ NAChannelMap::from_str("L,R").expect("should be able to create stereo channel map")
} else {
- NAChannelMap::from_str("C").unwrap()
+ NAChannelMap::from_str("C").expect("should be able to create single-channel map")
};
ADEC_STATE.set_state(DecodingState::Normal);
loop {
@@ -208,12 +208,12 @@ fn start_audio_decoding(asystem: &AudioSubsystem, ainfo: NAAudioInfo, mut audio_
if let Ok(out_buf) = convert_audio_frame(&buf, &dst_info, &dst_chmap) {
match out_buf {
NABufferType::AudioI16(abuf) => {
- let mut qdata = queue.lock().unwrap();
+ let mut qdata = queue.lock().expect("audio queue should be accessible");
qdata.add(abuf.get_data(), samplepos);
drop(qdata);
},
NABufferType::AudioPacked(abuf) => {
- let mut qdata = queue.lock().unwrap();
+ let mut qdata = queue.lock().expect("audio queue should be accessible");
qdata.add_bytes(abuf.get_data(), samplepos);
drop(qdata);
},
@@ -226,13 +226,13 @@ fn start_audio_decoding(asystem: &AudioSubsystem, ainfo: NAAudioInfo, mut audio_
Ok(PktSendEvent::GetFrames) => {},
Ok(PktSendEvent::Flush) => {
adec.flush();
- let mut qdata = queue.lock().unwrap();
+ let mut qdata = queue.lock().expect("audio queue should be accessible");
qdata.flush();
ADEC_STATE.set_state(DecodingState::Waiting);
},
Ok(PktSendEvent::End) => break,
Ok(PktSendEvent::ImmediateEnd) => {
- let mut qdata = queue.lock().unwrap();
+ let mut qdata = queue.lock().expect("audio queue should be accessible");
qdata.flush();
break;
},
@@ -243,7 +243,7 @@ fn start_audio_decoding(asystem: &AudioSubsystem, ainfo: NAAudioInfo, mut audio_
};
}
loop {
- let qdata = queue.lock().unwrap();
+ let qdata = queue.lock().expect("audio queue should be accessible");
if qdata.fill() == 0 || ADEC_STATE.is_flushing() {
break;
}
@@ -263,7 +263,7 @@ impl AudioControl {
pub fn new(audio_dec: Option<DecoderStuff>, ainfo: Option<NAAudioInfo>, asystem: &AudioSubsystem) -> Self {
let (apsend, aprecv) = std::sync::mpsc::sync_channel::<PktSendEvent>(20);
let (adevice, athread) = if let Some(audio_dec) = audio_dec {
- start_audio_decoding(asystem, ainfo.unwrap(), audio_dec, aprecv)
+ start_audio_decoding(asystem, ainfo.expect("audio info should be present"), audio_dec, aprecv)
} else {
(None, dummy_audio_thread(aprecv))
};