File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 101101use core:: fmt;
102102use std:: sync:: atomic:: { AtomicBool , Ordering } ;
103103use std:: sync:: Arc ;
104+ use std:: { f32, f64} ;
104105use std:: { thread, time:: Duration } ;
105106
106107use crate :: common:: assert_error_traits;
@@ -198,6 +199,21 @@ impl Source for Microphone {
198199 fn total_duration ( & self ) -> Option < std:: time:: Duration > {
199200 None
200201 }
202+
203+ fn bits_per_sample ( & self ) -> Option < u32 > {
204+ let bits = match self . config . sample_format {
205+ cpal:: SampleFormat :: I8 | cpal:: SampleFormat :: U8 => 8 ,
206+ cpal:: SampleFormat :: I16 | cpal:: SampleFormat :: U16 => 16 ,
207+ cpal:: SampleFormat :: I24 => 24 ,
208+ cpal:: SampleFormat :: I32 | cpal:: SampleFormat :: U32 => 32 ,
209+ cpal:: SampleFormat :: I64 | cpal:: SampleFormat :: U64 => 64 ,
210+ cpal:: SampleFormat :: F32 => f32:: MANTISSA_DIGITS ,
211+ cpal:: SampleFormat :: F64 => f64:: MANTISSA_DIGITS ,
212+ _ => return None ,
213+ } ;
214+
215+ Some ( bits)
216+ }
201217}
202218
203219impl Iterator for Microphone {
You can’t perform that action at this time.
0 commit comments