@@ -169,16 +169,14 @@ fn build_input_stream(
169
169
data : Arc < Mutex < Vec < i16 > > > ,
170
170
last_peak : Arc < AtomicU16 > ,
171
171
) -> Result < cpal:: Stream , String > {
172
- let data_cb = data. clone ( ) ;
173
- let last_peak_cb = last_peak. clone ( ) ;
174
172
match config. sample_format ( ) {
175
173
cpal:: SampleFormat :: F32 => device
176
174
. build_input_stream (
177
175
& config. clone ( ) . into ( ) ,
178
176
move |input : & [ f32 ] , _| {
179
177
let peak = peak_f32 ( input) ;
180
- last_peak_cb . store ( peak, Ordering :: Relaxed ) ;
181
- if let Ok ( mut buf) = data_cb . lock ( ) {
178
+ last_peak . store ( peak, Ordering :: Relaxed ) ;
179
+ if let Ok ( mut buf) = data . lock ( ) {
182
180
for & s in input {
183
181
buf. push ( f32_to_i16 ( s) ) ;
184
182
}
@@ -193,8 +191,8 @@ fn build_input_stream(
193
191
& config. clone ( ) . into ( ) ,
194
192
move |input : & [ i16 ] , _| {
195
193
let peak = peak_i16 ( input) ;
196
- last_peak_cb . store ( peak, Ordering :: Relaxed ) ;
197
- if let Ok ( mut buf) = data_cb . lock ( ) {
194
+ last_peak . store ( peak, Ordering :: Relaxed ) ;
195
+ if let Ok ( mut buf) = data . lock ( ) {
198
196
buf. extend_from_slice ( input) ;
199
197
}
200
198
} ,
@@ -206,9 +204,9 @@ fn build_input_stream(
206
204
. build_input_stream (
207
205
& config. clone ( ) . into ( ) ,
208
206
move |input : & [ u16 ] , _| {
209
- if let Ok ( mut buf) = data_cb . lock ( ) {
207
+ if let Ok ( mut buf) = data . lock ( ) {
210
208
let peak = convert_u16_to_i16_and_peak ( input, & mut buf) ;
211
- last_peak_cb . store ( peak, Ordering :: Relaxed ) ;
209
+ last_peak . store ( peak, Ordering :: Relaxed ) ;
212
210
}
213
211
} ,
214
212
move |err| error ! ( "audio input error: {err}" ) ,
0 commit comments