2 extern crate nihav_core;
3 extern crate nihav_registry;
4 extern crate nihav_allstuff;
10 use std::time::{Duration, Instant};
12 use std::sync::atomic::{AtomicU8, Ordering};
14 use sdl2::event::{Event, WindowEvent};
15 use sdl2::keyboard::{Keycode, Mod};
16 use sdl2::mouse::MouseButton;
17 use sdl2::render::{Canvas, Texture, TextureCreator};
18 use sdl2::pixels::PixelFormatEnum;
19 use sdl2::video::{Window, WindowContext};
21 use nihav_registry::detect;
22 use nihav_core::frame::*;
23 use nihav_core::io::byteio::{FileReader, ByteReader};
24 use nihav_core::reorder::*;
25 use nihav_core::codecs::*;
26 use nihav_core::demuxers::*;
27 use nihav_registry::register::*;
28 use nihav_allstuff::*;
38 #[derive(Clone,Copy,Debug,PartialEq)]
48 impl Default for DecodingState {
49 fn default() -> Self { DecodingState::Normal }
52 impl From<u8> for DecodingState {
53 fn from(val: u8) -> Self {
55 0 => DecodingState::Normal,
56 1 => DecodingState::Waiting,
57 2 => DecodingState::Flush,
58 3 => DecodingState::Prefetch,
59 4 => DecodingState::End,
60 _ => DecodingState::Error,
70 const fn new() -> Self {
72 state: AtomicU8::new(DecodingState::Normal as u8)
75 fn set_state(&self, state: DecodingState) {
76 self.state.store(state as u8, Ordering::Release);
78 fn get_state(&self) -> DecodingState {
79 self.state.load(Ordering::Acquire).into()
81 fn is_flushing(&self) -> bool {
82 matches!(self.get_state(), DecodingState::Flush | DecodingState::Error)
86 #[cfg(feature="debug")]
87 macro_rules! debug_log {
88 ($log: expr; $blk: block) => {
89 $log.logfile.write($blk.as_bytes()).unwrap();
90 $log.logfile.write(b"\n").unwrap();
93 #[cfg(not(feature="debug"))]
94 macro_rules! debug_log {
95 ($log: expr; $blk: block) => {};
98 pub enum PktSendEvent {
107 pub enum DecoderType {
108 Audio(Box<dyn NADecoder + Send>),
109 Video(Box<dyn NADecoder + Send>, Box<dyn FrameReorderer + Send>),
110 VideoMT(Box<dyn NADecoderMT + Send>, MTFrameReorderer),
113 pub struct DecoderStuff {
114 pub dsupp: Box<NADecoderSupport>,
115 pub dec: DecoderType,
118 fn format_time(ms: u64) -> String {
120 let ds = (ms % 1000) / 100;
121 let (min, s) = (s / 60, s % 60);
122 let (h, min) = (min / 60, min % 60);
125 format!("{}.{}", s, ds)
127 format!("{}:{:02}.{}", min, s, ds)
130 format!("{}:{:02}:{:02}.{}", h, min, s, ds)
134 const FRAME_QUEUE_LEN: usize = 25;
135 const MAX_VOLUME: usize = 200;
137 pub type FrameRecord = (NABufferType, u64);
139 pub struct TimeKeep {
147 ref_time: Instant::now(),
151 pub fn get_cur_time(&self) -> u64 {
152 let add = self.ref_time.elapsed().as_millis() as u64;
155 fn reset_ts(&mut self) {
158 fn reset_all(&mut self, ts: u64) {
159 self.ref_time = Instant::now();
162 fn set_ts(&mut self) {
163 self.ref_ts = self.get_cur_time();
165 fn set_time(&mut self) {
166 self.ref_time = Instant::now();
170 pub struct DispFrame<'a> {
174 pub rgb_tex: Texture<'a>,
175 pub yuv_tex: Texture<'a>,
178 pub struct DispQueue<'a> {
179 pub pool: Vec<DispFrame<'a>>,
189 impl<'a> DispQueue<'a> {
190 fn new(texture_creator: &'a TextureCreator<WindowContext>, width: usize, height: usize, len: usize) -> Self {
191 let mut pool = Vec::with_capacity(len);
192 for _ in 0..len + 1 {
193 let rgb_tex = texture_creator.create_texture_streaming(PixelFormatEnum::RGB24, width as u32, height as u32).expect("failed to create RGB texture");
194 let yuv_tex = texture_creator.create_texture_streaming(PixelFormatEnum::IYUV, ((width + 1) & !1) as u32, ((height + 1) & !1) as u32).expect("failed to create YUV texture");
195 pool.push(DispFrame{ ts: 0, is_yuv: false, valid: false, rgb_tex, yuv_tex });
197 pool[len].is_yuv = false;
198 pool[len].rgb_tex.with_lock(None, |buffer: &mut [u8], _pitch: usize| {
199 for el in buffer.iter_mut() { *el = 0; }
200 }).expect("RGB texture could not be locked");
202 Self { pool, first_ts: 0, last_ts: 0, start: 0, end: 0, len, width, height }
205 fn flush(&mut self) {
210 for frm in self.pool.iter_mut() {
215 fn get_last_texture(&mut self, osd: &OSD) -> &Texture<'a> {
216 if self.pool[self.len].is_yuv {
218 self.pool[self.len].yuv_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
219 osd.draw_yuv(buffer, pitch);
220 }).expect("YUV texture locking failure");
222 &self.pool[self.len].yuv_tex
225 self.pool[self.len].rgb_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
226 osd.draw_rgb(buffer, pitch);
227 }).expect("RGB texture locking failure");
229 &self.pool[self.len].rgb_tex
232 pub fn is_empty(&self) -> bool { self.start == self.end }
233 pub fn is_full(&self) -> bool { self.len == 0 || self.start == (self.end + 1) % self.len }
234 pub fn move_end(&mut self) {
236 if self.end >= self.len {
237 self.end -= self.len;
240 pub fn move_start(&mut self) {
241 self.pool.swap(self.start, self.len);
243 if self.start >= self.len {
244 self.start -= self.len;
246 if !self.is_empty() {
247 self.first_ts = self.pool[self.start].ts;
252 fn try_display(disp_queue: &mut DispQueue, canvas: &mut Canvas<Window>, osd: &mut OSD, ctime: &TimeKeep) -> Option<u64> {
253 while !disp_queue.is_empty() {
254 let disp_time = disp_queue.first_ts;
255 let ctime = ctime.get_cur_time();
256 if disp_time > ctime + 10 {
257 return Some(disp_time - ctime);
258 } else if disp_time + 10 < ctime {
259 disp_queue.move_start();
264 let frm = &mut disp_queue.pool[disp_queue.start];
265 let texture = if frm.is_yuv {
267 frm.yuv_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
268 osd.draw_yuv(buffer, pitch);
269 }).expect("YUV texture locking failure");
274 frm.rgb_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
275 osd.draw_rgb(buffer, pitch);
276 }).expect("RGB texture locking failure");
281 canvas.copy(texture, None, None).expect("canvas blit failure");
284 disp_queue.move_start();
285 if !disp_queue.is_empty() {
286 return Some((disp_queue.first_ts - ctime).saturating_sub(2));
296 sdl_context: sdl2::Sdl,
297 vsystem: sdl2::VideoSubsystem,
298 asystem: sdl2::AudioSubsystem,
302 acontrol: AudioControl,
303 vcontrol: VideoControl,
325 #[cfg(feature="debug")]
331 let sdl_context = sdl2::init().expect("SDL2 init failure");
332 let vsystem = sdl_context.video().expect("video subsystem init failure");
333 let asystem = sdl_context.audio().expect("audio subsystem init failure");
334 vsystem.disable_screen_saver();
335 let acontrol = AudioControl::new(None, None, &asystem);
336 let vcontrol = VideoControl::new(None, 0, 0, 0, 0);
338 sdl_context, asystem, vsystem,
359 tkeep: TimeKeep::new(),
364 #[cfg(feature="debug")]
365 logfile: File::create("debug.log").expect("'debug.log' should be available for writing"),
368 fn seek(&mut self, off: u64, fwd: bool, dmx: &mut Demuxer, disp_queue: &mut DispQueue) -> Result<(), ()> {
369 let cur_time = self.tkeep.get_cur_time();
370 let seektime = if fwd { cur_time + off * 1000 } else {
371 cur_time.saturating_sub(off * 1000) };
372 debug_log!(self; {format!(" seek to {}", seektime)});
374 let ret = dmx.seek(NATimePoint::Milliseconds(seektime));
376 println!(" seek error");
377 return Ok(()); //TODO: not ignore some of seek errors?
380 self.acontrol.flush();
381 self.vcontrol.flush();
384 self.tkeep.reset_ts();
385 self.prefill(dmx, disp_queue)?;
386 if !disp_queue.is_empty() {
387 self.tkeep.reset_all(disp_queue.first_ts);
389 let mut iterations = 0;
390 let mut time = self.acontrol.get_time();
391 while time.is_none() {
393 std::thread::yield_now();
394 if iterations > 1000000 { println!(" still no time set?!"); break; }
395 time = self.acontrol.get_time();
397 if let Some(time) = time {
398 self.tkeep.reset_all(time);
402 self.acontrol.resume();
406 fn prefill(&mut self, dmx: &mut Demuxer, disp_queue: &mut DispQueue) -> Result<(), ()> {
407 debug_log!(self; {" prefilling"});
408 while self.vcontrol.get_queue_size() < FRAME_QUEUE_LEN {
409 let mut try_send = self.acontrol.get_queue_size() < FRAME_QUEUE_LEN && (!self.has_video || (!self.vcontrol.is_filled(FRAME_QUEUE_LEN) && !disp_queue.is_full()));
411 if !self.vcontrol.try_send_queued() && self.vcontrol.get_queue_size() > FRAME_QUEUE_LEN / 2 {
414 if !self.acontrol.try_send_queued() && self.acontrol.get_queue_size() > FRAME_QUEUE_LEN / 2 {
418 match dmx.get_frame() {
419 Err(DemuxerError::EOF) => break,
422 let streamno = pkt.get_stream().get_id();
423 if self.has_video && streamno == self.video_str {
424 self.vcontrol.try_send_video(PktSendEvent::Packet(pkt));
425 } else if self.has_audio && streamno == self.audio_str {
426 self.acontrol.try_send_audio(PktSendEvent::Packet(pkt));
431 self.vcontrol.fill(disp_queue);
438 while self.vcontrol.get_queue_size() > 0 && !disp_queue.is_full() {
439 self.vcontrol.try_send_queued();
440 self.vcontrol.fill(disp_queue);
441 std::thread::sleep(Duration::from_millis(10));
443 self.vcontrol.wait_for_frames()?;
444 self.vcontrol.fill(disp_queue);
446 debug_log!(self; {format!(" prefilling done, frames {}-{} audio {}", disp_queue.start, disp_queue.end, self.acontrol.get_fill())});
449 fn toggle_pause(&mut self) {
450 self.paused = !self.paused;
452 self.vsystem.enable_screen_saver();
455 self.vsystem.disable_screen_saver();
456 self.tkeep.set_time();
459 self.acontrol.pause();
461 self.acontrol.resume();
464 fn handle_events(&mut self, event_pump: &mut sdl2::EventPump, canvas: &mut Canvas<Window>, dmx: &mut Demuxer, disp_queue: &mut DispQueue) -> Result<bool, ()> {
465 for event in event_pump.poll_iter() {
466 if let Event::Quit {..} = event {
471 if let Event::Window {win_event: WindowEvent::Exposed, ..} = event {
473 canvas.copy(disp_queue.get_last_texture(&self.osd), None, None).expect("blitting failure");
476 if let Event::MouseButtonDown {mouse_btn: MouseButton::Right, ..} = event {
479 if let Event::KeyDown {keycode: Some(keycode), keymod, ..} = event {
486 Keycode::Q if matches!(keymod, Mod::RSHIFTMOD | Mod::LSHIFTMOD) => {
491 Keycode::Return => return Ok(true),
492 Keycode::Right => { self.seek(10, true, dmx, disp_queue)?; },
493 Keycode::Left => { self.seek(10, false, dmx, disp_queue)?; },
494 Keycode::Up => { self.seek(60, true, dmx, disp_queue)?; },
495 Keycode::Down => { self.seek(60, false, dmx, disp_queue)?; },
496 Keycode::PageUp => { self.seek(600, true, dmx, disp_queue)?; },
497 Keycode::PageDown => { self.seek(600, false, dmx, disp_queue)?; },
498 Keycode::Space => { self.toggle_pause(); },
499 Keycode::Plus | Keycode::KpPlus => {
500 self.volume = (self.volume + 10).min(MAX_VOLUME);
502 self.acontrol.set_volume(self.volume);
505 Keycode::Minus | Keycode::KpMinus => {
506 self.volume = self.volume.saturating_sub(10);
508 self.acontrol.set_volume(self.volume);
512 self.debug = !self.debug;
515 self.mute = !self.mute;
517 self.acontrol.set_volume(0);
519 self.acontrol.set_volume(self.volume);
523 self.vcontrol.try_send_video(PktSendEvent::HurryUp);
531 print!("{:60}\r", ' ');
532 std::io::stdout().flush().unwrap();
538 fn play(&mut self, name: &str, start_time: NATimePoint) {
539 debug_log!(self; {format!("Playing {}", name)});
541 // prepare data source
542 let path = Path::new(name);
543 let mut file = if let Ok(handle) = File::open(path) {
546 println!("failed to open {}", name);
550 let mut fr = FileReader::new_read(&mut file);
551 let mut br = ByteReader::new(&mut fr);
552 let res = detect::detect_format(name, &mut br);
554 println!("cannot detect format for {}", name);
557 let (dmx_name, _score) = res.unwrap();
558 debug_log!(self; {format!(" found demuxer {} with score {:?}", dmx_name, _score)});
559 println!("trying demuxer {} on {}", dmx_name, name);
561 let mut dmx_reg = RegisteredDemuxers::new();
562 nihav_register_all_demuxers(&mut dmx_reg);
563 let mut dec_reg = RegisteredDecoders::new();
564 nihav_register_all_decoders(&mut dec_reg);
565 let mut mtdec_reg = RegisteredMTDecoders::new();
567 nihav_register_all_mt_decoders(&mut mtdec_reg);
570 let ret = dmx_reg.find_demuxer(dmx_name);
572 println!("error finding {} demuxer", dmx_name);
575 dmx_fact = ret.unwrap();
576 br.seek(SeekFrom::Start(0)).expect("should be able to seek to the start");
577 let ret = create_demuxer(dmx_fact, &mut br);
579 println!("error creating demuxer");
582 let mut dmx = ret.unwrap();
583 if start_time != NATimePoint::None {
584 debug_log!(self; {format!(" start seek to {}", start_time)});
585 if dmx.seek(start_time).is_err() {
586 println!("initial seek failed");
591 let mut height = 480;
594 let mut ainfo: Option<NAAudioInfo> = None;
596 let mut video_dec: Option<DecoderStuff> = None;
597 let mut audio_dec: Option<DecoderStuff> = None;
599 let duration = dmx.get_duration();
601 println!(" total duration {}", format_time(duration));
603 self.has_video = false;
604 self.has_audio = false;
606 self.osd.set_duration(duration);
607 for i in 0..dmx.get_num_streams() {
608 let s = dmx.get_stream(i).unwrap();
609 let info = s.get_info();
610 let decfunc = dec_reg.find_decoder(info.get_name());
611 let decfunc_mt = mtdec_reg.find_decoder(info.get_name());
612 println!("stream {} - {} {}", i, s, info.get_name());
613 debug_log!(self; {format!(" stream {} - {} {}", i, s, info.get_name())});
614 let str_id = s.get_id();
616 if video_dec.is_none() && self.play_video {
617 if let Some(decfunc) = decfunc_mt {
618 let mut dec = (decfunc)();
619 let mut dsupp = Box::new(NADecoderSupport::new());
620 let props = info.get_properties().get_video_info().unwrap();
621 if props.get_width() != 0 {
622 width = props.get_width();
623 height = props.get_height();
625 if dec.init(&mut dsupp, info.clone(), self.vthreads).is_ok() {
626 video_dec = Some(DecoderStuff{ dsupp, dec: DecoderType::VideoMT(dec, MTFrameReorderer::new()) });
627 self.video_str = str_id;
628 let (tbn, tbd) = s.get_timebase();
631 self.has_video = true;
634 println!("failed to create multi-threaded decoder, falling back");
637 if let Some(decfunc) = decfunc {
638 let mut dec = (decfunc)();
639 let mut dsupp = Box::new(NADecoderSupport::new());
640 let props = info.get_properties().get_video_info().unwrap();
641 if props.get_width() != 0 {
642 width = props.get_width();
643 height = props.get_height();
645 let desc = get_codec_description(info.get_name());
646 let (reorder_depth, reord) = if desc.is_none() || (desc.unwrap().caps & CODEC_CAP_COMPLEX_REORDER) == 0 {
647 let reord: Box<dyn FrameReorderer + Send> = Box::new(IPBReorderer::new());
650 let reord: Box<dyn FrameReorderer + Send> = Box::new(ComplexReorderer::new());
653 dsupp.pool_u8 = NAVideoBufferPool::new(reorder_depth);
654 dsupp.pool_u16 = NAVideoBufferPool::new(reorder_depth);
655 dsupp.pool_u32 = NAVideoBufferPool::new(reorder_depth);
656 if dec.init(&mut dsupp, info).is_err() {
657 println!("failed to initialise video decoder");
660 video_dec = Some(DecoderStuff{ dsupp, dec: DecoderType::Video(dec, reord) });
661 self.video_str = str_id;
662 let (tbn, tbd) = s.get_timebase();
665 self.has_video = true;
667 println!("no video decoder for {} found!", info.get_name());
670 } else if info.is_audio() {
671 if audio_dec.is_none() && self.play_audio {
672 if let Some(decfunc) = decfunc {
673 let mut dec = (decfunc)();
674 let mut dsupp = Box::new(NADecoderSupport::new());
675 ainfo = info.get_properties().get_audio_info();
676 if dec.init(&mut dsupp, info).is_err() {
677 println!("failed to initialise audio decoder");
680 audio_dec = Some(DecoderStuff{ dsupp, dec: DecoderType::Audio(dec) });
681 self.audio_str = str_id;
682 self.has_audio = true;
684 println!("no audio decoder for {} found!", info.get_name());
688 println!("decoder {} not found", info.get_name());
691 if !self.has_video && !self.has_audio {
692 println!("No playable streams found.");
696 while (width <= 384) && (height <= 288) {
701 // prepare playback structure
702 let mut new_vcontrol = VideoControl::new(video_dec, width, height, tb_num, tb_den);
703 std::mem::swap(&mut self.vcontrol, &mut new_vcontrol);
705 let mut new_acontrol = AudioControl::new(audio_dec, ainfo, &self.asystem);
706 std::mem::swap(&mut self.acontrol, &mut new_acontrol);
709 self.acontrol.set_volume(0);
711 self.acontrol.set_volume(self.volume);
714 let fname = path.file_name();
715 let wname = if let Some(fname) = fname {
716 "NihAV player - ".to_owned() + fname.to_str().expect("should be able to set window title")
718 "NihAV player".to_owned()
720 let mut builder = self.vsystem.window(&wname, width as u32, height as u32);
721 let window = if let (Some(xpos), Some(ypos)) = (self.xpos, self.ypos) {
722 builder.position(xpos, ypos).build().expect("should be able to set window position")
724 builder.position_centered().build().expect("should be able to centre window")
726 let mut canvas = window.into_canvas().build().expect("should be able to build canvas");
727 let texture_creator = canvas.texture_creator();
728 let mut disp_q = DispQueue::new(&texture_creator, width, height, if self.has_video { FRAME_QUEUE_LEN } else { 0 });
731 canvas.copy(disp_q.get_last_texture(&self.osd), None, None).expect("blit failure");
735 self.has_audio = self.acontrol.has_audio();
736 if !self.has_video && !self.has_audio {
737 println!("No playable streams.");
742 if self.prefill(&mut dmx, &mut disp_q).is_err() {
743 std::mem::swap(&mut self.vcontrol, &mut new_vcontrol);
744 new_vcontrol.finish();
745 std::mem::swap(&mut self.acontrol, &mut new_acontrol);
746 new_acontrol.finish();
749 self.tkeep.reset_all(if !disp_q.is_empty() { disp_q.first_ts } else { 0 });
751 self.acontrol.resume();
753 let mut event_pump = self.sdl_context.event_pump().expect("should be able to create event pump");
754 let mut last_disp = Instant::now();
755 let mut has_data = true;
757 let ret = self.handle_events(&mut event_pump, &mut canvas, &mut dmx, &mut disp_q);
758 if matches!(ret, Ok(true) | Err(_)) {
763 let mut try_send = self.acontrol.get_queue_size() < FRAME_QUEUE_LEN && self.vcontrol.get_queue_size() < FRAME_QUEUE_LEN;
764 if !self.vcontrol.try_send_queued() && self.vcontrol.is_filled(FRAME_QUEUE_LEN) {
767 if !self.acontrol.try_send_queued() {
770 while has_data && try_send {
771 match dmx.get_frame() {
772 Err(DemuxerError::EOF) => {
773 self.vcontrol.try_send_video(PktSendEvent::End);
774 self.acontrol.try_send_audio(PktSendEvent::End);
778 println!("demuxer error {:?}", err);
779 if err == DemuxerError::IOError {
780 self.vcontrol.try_send_video(PktSendEvent::End);
781 self.acontrol.try_send_audio(PktSendEvent::End);
786 let streamno = pkt.get_stream().get_id();
787 if self.has_video && streamno == self.video_str {
788 debug_log!(self; {" sending video packet"});
789 self.vcontrol.try_send_video(PktSendEvent::Packet(pkt));
790 if self.vcontrol.is_filled(FRAME_QUEUE_LEN) {
793 } else if self.has_audio && streamno == self.audio_str {
794 debug_log!(self; {" sending audio packet"});
795 self.acontrol.try_send_audio(PktSendEvent::Packet(pkt));
796 if self.acontrol.get_queue_size() >= FRAME_QUEUE_LEN {
803 self.vcontrol.fill(&mut disp_q);
804 let mut sleep_time = 25;
805 debug_log!(self; {format!(" time {}", self.tkeep.get_cur_time())});
807 debug_log!(self; {format!(" disp queue {}-{}, {}-{} vqueue fill {}", disp_q.first_ts, disp_q.last_ts, disp_q.start, disp_q.end, self.vcontrol.get_queue_size())});
808 let ret = try_display(&mut disp_q, &mut canvas, &mut self.osd, &self.tkeep);
809 if let Some(next_time) = ret {
810 sleep_time = sleep_time.min(next_time);
814 let time_left = self.acontrol.get_time_left();
815 debug_log!(self; {format!(" audio left {}", time_left)});
816 sleep_time = sleep_time.min(time_left);
818 debug_log!(self; {format!(" sleep {}ms", sleep_time)});
819 if last_disp.elapsed().as_millis() >= 10 {
820 let c_time = self.tkeep.get_cur_time();
823 print!(" {} {}% \r", format_time(c_time), self.acontrol.get_volume());
825 print!(" {} {} {}% {:3} {:6}\r", format_time(c_time), if self.vcontrol.is_yuv() { 'Y' } else { 'R' }, self.acontrol.get_volume(), (disp_q.end + disp_q.len - disp_q.start) % disp_q.len, self.acontrol.get_fill());
827 std::io::stdout().flush().unwrap();
828 last_disp = Instant::now();
831 if self.has_video && !self.vcontrol.is_video_end() {
834 if self.has_audio && !self.acontrol.is_audio_end() {
840 thread::sleep(Duration::from_millis(sleep_time));
842 thread::sleep(Duration::from_millis(20));
845 let (xpos, ypos) = canvas.into_window().position();
846 self.xpos = Some(xpos);
847 self.ypos = Some(ypos);
849 std::mem::swap(&mut self.vcontrol, &mut new_vcontrol);
850 new_vcontrol.finish();
851 std::mem::swap(&mut self.acontrol, &mut new_acontrol);
852 new_acontrol.finish();
857 let args: Vec<String> = env::args().collect();
860 println!("usage: nihav-player file1 file2 ...");
864 let mut player = Player::new();
866 let mut aiter = args.iter().skip(1);
867 let mut seek_time = NATimePoint::None;
868 while let Some(arg) = aiter.next() {
870 "-an" => { player.play_audio = false; },
871 "-ae" => { player.play_audio = true; },
872 "-vn" => { player.play_video = false; },
873 "-ve" => { player.play_video = true; },
875 if let Some(arg) = aiter.next() {
876 if let Ok(time) = arg.parse::<NATimePoint>() {
879 println!("wrong seek time");
880 seek_time = NATimePoint::None;
885 if let Some(arg) = aiter.next() {
886 if let Ok(vol) = arg.parse::<usize>() {
887 player.volume = vol.min(MAX_VOLUME);
889 println!("wrong volume");
897 player.debug = false;
900 player.use_mt = true;
903 player.use_mt = false;
906 if let Some(arg) = aiter.next() {
907 if let Ok(val) = arg.parse::<usize>() {
908 player.vthreads = val.max(1);
910 println!("wrong number of threads");
915 player.play(arg, seek_time);
916 if player.end { break; }
917 seek_time = NATimePoint::None;