From 64b8b5f91ae61ace1d8d6e7a82327fc06e69b750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Krause?= Date: Wed, 7 Dec 2016 12:50:46 +0100 Subject: [PATCH] Don't panic on error InitialFileHeadersCorrupt --- src/player.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/player.rs b/src/player.rs index 7648fd7..822b6d1 100644 --- a/src/player.rs +++ b/src/player.rs @@ -256,7 +256,10 @@ impl PlayerInternal { decoder = match load_track(&self.session, track_id) { Some(mut decoder) => { - vorbis_time_seek_ms(&mut decoder, position as i64).unwrap(); + match vorbis_time_seek_ms(&mut decoder, position as i64) { + Ok(_) => (), + Err(err) => error!("Vorbis error: {:?}", err), + } self.update(|state| { state.status = if play { @@ -290,7 +293,10 @@ impl PlayerInternal { } Some(PlayerCommand::Seek(position)) => { - vorbis_time_seek_ms(decoder.as_mut().unwrap(), position as i64).unwrap(); + match vorbis_time_seek_ms(decoder.as_mut().unwrap(), position as i64) { + Ok(_) => (), + Err(err) => error!("Vorbis error: {:?}", err), + } self.update(|state| { state.position_ms = vorbis_time_tell_ms(decoder.as_mut().unwrap()).unwrap() as u32; state.position_measured_at = util::now_ms(); @@ -301,7 +307,10 @@ impl PlayerInternal { Some(PlayerCommand::SeekAt(position, measured_at)) => { let position = (util::now_ms() - measured_at + position as i64) as u32; - vorbis_time_seek_ms(decoder.as_mut().unwrap(), position as i64).unwrap(); + match vorbis_time_seek_ms(decoder.as_mut().unwrap(), position as i64) { + Ok(_) => (), + Err(err) => error!("Vorbis error: {:?}", err), + } self.update(|state| { state.position_ms = vorbis_time_tell_ms(decoder.as_mut().unwrap()).unwrap() as u32; state.position_measured_at = util::now_ms();