]> git.nihav.org Git - nihav-player.git/blobdiff - videoplayer/src/main.rs
videoplayer: work around SDL window title bug
[nihav-player.git] / videoplayer / src / main.rs
index 2389e1f7f4d783ecd0cdcab0c655517b5294fa8b..89deb7c910e748d6542ed7470fd3374e9ed5e4c3 100644 (file)
@@ -35,8 +35,9 @@ mod osd;
 use osd::*;
 
 #[repr(u8)]
-#[derive(Clone,Copy,Debug,PartialEq)]
+#[derive(Clone,Copy,Debug,PartialEq,Default)]
 enum DecodingState {
+    #[default]
     Normal,
     Waiting,
     Flush,
@@ -45,10 +46,6 @@ enum DecodingState {
     End,
 }
 
-impl Default for DecodingState {
-    fn default() -> Self { DecodingState::Normal }
-}
-
 impl From<u8> for DecodingState {
     fn from(val: u8) -> Self {
         match val {
@@ -553,7 +550,6 @@ impl Player {
                 println!("failed to open {}", name);
                 return;
             };
-        let dmx_fact;
         let mut fr = FileReader::new_read(&mut file);
         let mut br = ByteReader::new(&mut fr);
         let res = detect::detect_format(name, &mut br);
@@ -579,7 +575,7 @@ impl Player {
             println!("error finding {} demuxer", dmx_name);
             return;
         }
-        dmx_fact = ret.unwrap();
+        let dmx_fact = ret.unwrap();
         br.seek(SeekFrom::Start(0)).expect("should be able to seek to the start");
         let ret = create_demuxer(dmx_fact, &mut br);
         if ret.is_err() {
@@ -726,7 +722,10 @@ impl Player {
 
         let fname = path.file_name();
         let wname = if let Some(fname) = fname {
-                "NihAV player - ".to_owned() + fname.to_str().expect("should be able to set window title")
+                // workaround for libSDL2 workaround for non-UTF8 windowing systems
+                // see https://github.com/libsdl-org/SDL/pull/4290 for detais
+                let nname = fname.to_str().expect("should be able to set window title").replace('\u{2013}', "-");
+                "NihAV player - ".to_owned() + &nname
             } else {
                 "NihAV player".to_owned()
             };