From 4a44ddc7035700d6f6b5c558e7cce38a06bf3508 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Tue, 25 Jun 2024 10:40:32 +0200 Subject: [PATCH] Skip processing of output render callbacks with 0 frames Speculative fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1902989. --- src/backend/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 3917171..556acfe 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -729,6 +729,14 @@ extern "C" fn audiounit_output_callback( assert!(!user_ptr.is_null()); let stm = unsafe { &mut *(user_ptr as *mut AudioUnitStream) }; + if output_frames == 0 { + cubeb_alog!( + "({:p}) output callback empty.", + stm as *const AudioUnitStream + ); + return NO_ERR; + } + let out_buffer_list_ref = unsafe { &mut (*out_buffer_list) }; assert_eq!(out_buffer_list_ref.mNumberBuffers, 1); let buffers = unsafe { @@ -879,6 +887,7 @@ extern "C" fn audiounit_output_callback( output_frames ); + assert_ne!(output_frames, 0); let outframes = stm.core_stream_data.resampler.fill( input_buffer, if input_buffer.is_null() {