File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -173,14 +173,19 @@ pub(crate) unsafe extern "C" fn on_read_frames(
173
173
if let Some ( completion) = completion {
174
174
let bytes_per_sample = 2 ;
175
175
let num_bytes = num_frames * speaker. channels ( ) as usize * bytes_per_sample;
176
+ let empty_bytes: [ u8 ; 0 ] = [ ] ;
176
177
177
- let py_bytes = unsafe { PyBytes :: bound_from_ptr ( py, frames as * const u8 , num_bytes) } ;
178
+ let py_bytes = if num_bytes > 0 {
179
+ unsafe { PyBytes :: bound_from_ptr ( py, frames as * const u8 , num_bytes) }
180
+ } else {
181
+ PyBytes :: new_bound ( py, & empty_bytes)
182
+ } ;
178
183
179
184
let args = PyTuple :: new_bound ( py, [ py_bytes] ) ;
180
185
181
186
if let Err ( error) = completion. call1 ( py, args) {
182
187
error. write_unraisable_bound ( py, None ) ;
183
188
}
184
- }
189
+ } ;
185
190
} )
186
191
}
You can’t perform that action at this time.
0 commit comments