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;
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 {
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);
},
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;
},
};
}
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;
}
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))
};