]> git.nihav.org Git - nihav-player.git/commitdiff
videoplayer: use explicit conversion from DecodingState to u8
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 10 Feb 2026 17:23:54 +0000 (18:23 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 10 Feb 2026 17:23:54 +0000 (18:23 +0100)
videoplayer/src/main.rs

index 658a55ccf6ae9fd82b509246c243de250644fd03..71cdf4bd1983e3e512bfebfde8aae65fd45e68e5 100644 (file)
@@ -51,6 +51,19 @@ enum DecodingState {
     End,
 }
 
+impl From<DecodingState> for u8 {
+    fn from(val: DecodingState) -> Self {
+        match val {
+            DecodingState::Normal => 0,
+            DecodingState::Waiting => 1,
+            DecodingState::Flush => 2,
+            DecodingState::Prefetch => 3,
+            DecodingState::End => 4,
+            DecodingState::Error => 5,
+        }
+    }
+}
+
 impl From<u8> for DecodingState {
     fn from(val: u8) -> Self {
         match val {
@@ -75,7 +88,7 @@ impl DecoderState {
         }
     }
     fn set_state(&self, state: DecodingState) {
-        self.state.store(state as u8, Ordering::Release);
+        self.state.store(state.into(), Ordering::Release);
     }
     fn get_state(&self) -> DecodingState {
         self.state.load(Ordering::Acquire).into()