@@ -38,26 +38,30 @@ impl InputStream {
38
38
fract : 0.0 ,
39
39
} ;
40
40
41
- let err_callback = |err| panic ! ( "Error in default audio output device stream: {err}" ) ;
41
+ let err_callback = |err| panic ! ( "Error in default audio input device stream: {err}" ) ;
42
42
let stream = match supported_input_config. sample_format ( ) {
43
43
SampleFormat :: U16 => input_device. build_input_stream (
44
44
& supported_input_config. config ( ) ,
45
45
move |data : & [ u16 ] , _| input_data. fill ( data) ,
46
46
err_callback,
47
+ None ,
47
48
) ,
48
49
SampleFormat :: I16 => input_device. build_input_stream (
49
50
& supported_input_config. config ( ) ,
50
51
move |data : & [ i16 ] , _| input_data. fill ( data) ,
51
52
err_callback,
53
+ None ,
52
54
) ,
53
55
SampleFormat :: F32 => input_device. build_input_stream (
54
56
& supported_input_config. config ( ) ,
55
57
move |data : & [ f32 ] , _| input_data. fill ( data) ,
56
58
err_callback,
59
+ None ,
57
60
) ,
61
+ _ => panic ! ( "Unsupported audio input sample format" ) ,
58
62
}
59
63
. ok ( ) ?;
60
- stream. play ( ) . expect ( "Couldn 't start audio output stream" ) ;
64
+ stream. play ( ) . expect ( "couldn 't start audio input stream" ) ;
61
65
62
66
Some ( InputStream {
63
67
_stream : stream,
@@ -86,7 +90,7 @@ struct InputData {
86
90
}
87
91
88
92
impl InputData {
89
- fn fill < T : Sample > ( & mut self , data : & [ T ] ) {
93
+ fn fill < T : Sample > ( & mut self , data : & [ T ] ) where f64 : cpal :: FromSample < T > {
90
94
if let Some ( interp) = self . interp_rx . try_iter ( ) . last ( ) {
91
95
self . interp = interp;
92
96
}
@@ -95,7 +99,7 @@ impl InputData {
95
99
for input_samples in data. chunks ( self . channels as usize ) {
96
100
let mut input_sample = 0.0 ;
97
101
for sample in input_samples {
98
- input_sample += sample. to_f32 ( ) as f64 ;
102
+ input_sample += sample. to_sample :: < f64 > ( ) ;
99
103
}
100
104
self . interp
101
105
. push_input_sample ( [ input_sample / self . channels as f64 ] ) ;
0 commit comments