Skip to content

Commit 437ade2

Browse files
committed
CSDK-2402 always call device completion callbacks
1 parent a4296ae commit 437ade2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/media/virtual_speaker_device.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,19 @@ pub(crate) unsafe extern "C" fn on_read_frames(
173173
if let Some(completion) = completion {
174174
let bytes_per_sample = 2;
175175
let num_bytes = num_frames * speaker.channels() as usize * bytes_per_sample;
176+
let empty_bytes: [u8; 0] = [];
176177

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+
};
178183

179184
let args = PyTuple::new_bound(py, [py_bytes]);
180185

181186
if let Err(error) = completion.call1(py, args) {
182187
error.write_unraisable_bound(py, None);
183188
}
184-
}
189+
};
185190
})
186191
}

0 commit comments

Comments
 (0)