File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,20 @@ impl Source for Microphone {
181181 self . config . sample_rate
182182 }
183183
184+ // TODO: use cpal::SampleFormat::bits_per_sample() when cpal v0.17 is released
185+ fn bits_per_sample ( & self ) -> Option < u32 > {
186+ let bits = match self . config . sample_format {
187+ cpal:: SampleFormat :: I8 | cpal:: SampleFormat :: U8 => 8 ,
188+ cpal:: SampleFormat :: I16 | cpal:: SampleFormat :: U16 => 16 ,
189+ cpal:: SampleFormat :: I24 => 24 ,
190+ cpal:: SampleFormat :: I32 | cpal:: SampleFormat :: U32 | cpal:: SampleFormat :: F32 => 32 ,
191+ cpal:: SampleFormat :: I64 | cpal:: SampleFormat :: U64 | cpal:: SampleFormat :: F64 => 64 ,
192+ _ => return None ,
193+ } ;
194+
195+ Some ( bits)
196+ }
197+
184198 fn total_duration ( & self ) -> Option < std:: time:: Duration > {
185199 None
186200 }
You can’t perform that action at this time.
0 commit comments