From e1071472c55193032aa4c1403317844005f9d0fc Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Wed, 7 Aug 2024 14:25:56 +0200 Subject: [PATCH] Handle data callbacks of size zero The client side does not allow CallbackData::Req of size zero. This handles it on the server side by returning early. The background for this is https://bugzilla.mozilla.org/show_bug.cgi?id=1907367 where something is causing data callbacks of size zero and tripping an assertion, but we have not reproduced and an audit is not conclusive as to where the root cause is. --- server/src/server.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/server.rs b/server/src/server.rs index 96a8fc3..d9b8299 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -261,6 +261,11 @@ impl ServerStreamCallbacks { return cubeb::ffi::CUBEB_ERROR.try_into().unwrap(); } + if nframes == 0 { + // Optimization: skip the RPC call when there are no frames. + return 0; + } + let r = self.data_callback_rpc.call(CallbackReq::Data { nframes, input_frame_size: self.input_frame_size as usize,