improve error handling in video decoding a bit
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 18 Jun 2023 14:16:54 +0000 (16:16 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 18 Jun 2023 14:16:54 +0000 (16:16 +0200)
videoplayer/src/videodec.rs

index d30f45fbd8cfafe67067625c4d90e0f4e53b58b7..1d70112902d0f0a12f44f3666de94d3e8374f995 100644 (file)
@@ -113,17 +113,20 @@ impl VideoDecoder {
                                 },
                                 (Err(err), id) => {
                                     reord.drop_frame(id);
-                                    panic!("frame {} decoding error {:?}", id, err);
+                                    println!("frame {} decoding error {:?}", id, err);
                                 },
                             };
                         }
                         match vdec.queue_pkt(&mut self.dec.dsupp, &pkt, queue_id) {
                             Ok(true) => {},
-                            Ok(false) => panic!("still can't queue frame!"),
-                            Err(err) => panic!("queueing error {:?}", err),
+                            Ok(false) => {
+                                println!("still can't queue frame!");
+                                VDEC_STATE.set_state(DecodingState::Error);
+                            },
+                            Err(err) => println!("queueing error {:?}", err),
                         };
                     },
-                    Err(err) => panic!("queueing error {:?}", err),
+                    Err(err) => println!("queueing error {:?}", err),
                 };
                 while let Some(frm) = reord.get_frame() {
                     let bt = frm.get_buffer();
@@ -156,7 +159,7 @@ impl VideoDecoder {
                         },
                         (Err(err), id) => {
                             reord.drop_frame(id);
-                            panic!("frame {} decoding error {:?}", id, err);
+                            println!("frame {} decoding error {:?}", id, err);
                         },
                     };
                 }
@@ -168,7 +171,7 @@ impl VideoDecoder {
                         (Err(DecoderError::NoFrame), _) => {},
                         (Err(err), id) => {
                             reord.drop_frame(id);
-                            panic!("frame {} decoding error {:?}", id, err);
+                            println!("frame {} decoding error {:?}", id, err);
                         },
                     };
                 }