introduce option handling for decoders
[nihav.git] / nihav-commonfmt / src / codecs / pcm.rs
index 7967b34fca800376104e3380d53faae62cd81f45..b4ded8746bccb11a8f63e392b18bc6f7af40a8de 100644 (file)
@@ -25,10 +25,10 @@ fn get_default_chmap(nch: u8) -> NAChannelMap {
 fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) -> u64 {
     if duration == None {
         let size_bits = (data_size as u64) * 8;
-        let blk_size = (ainfo.get_channels() as u64) * (ainfo.get_format().get_bits() as u64);
+        let blk_size = u64::from(ainfo.get_channels()) * u64::from(ainfo.get_format().get_bits());
         size_bits / blk_size
     } else {
-        duration.unwrap() as u64
+        duration.unwrap()
     }
 }
 
@@ -56,8 +56,16 @@ impl NADecoder for PCMDecoder {
             Err(DecoderError::InvalidData)
         }
     }
+    fn flush(&mut self) {
+    }
+}
+
+impl NAOptionHandler for PCMDecoder {
+    fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
+    fn set_options(&mut self, _options: &[NAOption]) { }
+    fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
 }
 
-pub fn get_decoder() -> Box<dyn NADecoder> {
+pub fn get_decoder() -> Box<dyn NADecoder + Send> {
     Box::new(PCMDecoder::new())
 }