[vlc-commits] [Git][videolan/vlc][master] coreaudio: fix sleep duration when the buffer is full

Thomas Guillem gitlab at videolan.org
Thu May 6 08:32:46 UTC 2021



Thomas Guillem pushed to branch master at VideoLAN / VLC


Commits:
1d02d748 by Thomas Guillem at 2021-05-06T08:15:56+00:00
coreaudio: fix sleep duration when the buffer is full

The previous calculation was wrong and could lead to two potential
issues:
 - Too much wake/sleep because the block remaining data is very small
 - Too long sleep, if the block is longer than the buffer size, that
   could lead to underrun

To fix this issue, use the same sleep calculation than wasapi.

- - - - -


1 changed file:

- modules/audio_output/coreaudio_common.c


Changes:

=====================================
modules/audio_output/coreaudio_common.c
=====================================
@@ -377,12 +377,13 @@ ca_Play(audio_output_t * p_aout, block_t * p_block, vlc_tick_t date)
                 return;
             }
 
-            const vlc_tick_t i_frame_ticks =
-                FramesToTicks(p_sys, BytesToFrames(p_sys, p_block->i_buffer));
+            /* The render buffer is full, Wait for the renderer to play half
+             * the data. */
+            const vlc_tick_t i_sleep_ticks =
+                FramesToTicks(p_sys, BytesToFrames(p_sys, p_sys->i_out_max_size)) / 2;
 
-            /* Wait for the render buffer to play the remaining data */
             lock_unlock(p_sys);
-            vlc_tick_sleep(i_frame_ticks);
+            vlc_tick_sleep(i_sleep_ticks);
             lock_lock(p_sys);
         }
         else



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1d02d748ee36202a805063b1e6a919042a9d60d7

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1d02d748ee36202a805063b1e6a919042a9d60d7
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list