[vlc-commits] [Git][videolan/vlc][master] 2 commits: coreaudio: rename total_frames to total_bytes

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Nov 23 06:22:04 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
64755991 by Thomas Guillem at 2022-11-23T06:01:04+00:00
coreaudio: rename total_frames to total_bytes

Since it's in bytes.

- - - - -
76397ea3 by Thomas Guillem at 2022-11-23T06:01:04+00:00
coreaudio: set play non-blocking

Fixes #27548

- - - - -


2 changed files:

- modules/audio_output/coreaudio_common.c
- modules/audio_output/coreaudio_common.h


Changes:

=====================================
modules/audio_output/coreaudio_common.c
=====================================
@@ -230,7 +230,7 @@ ca_Render(audio_output_t *p_aout, uint64_t i_host_time,
         p_sys->pp_out_last = &p_sys->p_out_chain;
     p_sys->i_out_size -= i_copied;
 
-    p_sys->i_total_frames += i_copied;
+    p_sys->i_total_bytes += i_copied;
 
     /* Pad with 0 */
     if (i_requested > 0)
@@ -252,7 +252,7 @@ ca_Render(audio_output_t *p_aout, uint64_t i_host_time,
      || i_host_ticks - p_sys->i_last_latency_ticks >= VLC_TICK_FROM_SEC(1))
     {
         vlc_tick_t frames_tick = FramesToTicks(p_sys,
-                                    BytesToFrames(p_sys, p_sys->i_total_frames))
+                                    BytesToFrames(p_sys, p_sys->i_total_bytes))
                                + p_sys->i_dev_latency_ticks;
 
         aout_TimingReport(p_aout, i_host_ticks, frames_tick);
@@ -300,7 +300,7 @@ ca_Flush(audio_output_t *p_aout)
 
     p_sys->i_render_host_time = p_sys->i_first_render_host_time = 0;
     p_sys->i_last_latency_ticks = VLC_TICK_INVALID;
-    p_sys->i_total_frames = 0;
+    p_sys->i_total_bytes = 0;
     lock_unlock(p_sys);
 
     p_sys->b_played = false;
@@ -356,57 +356,8 @@ ca_Play(audio_output_t * p_aout, block_t * p_block, vlc_tick_t date)
             = mach_absolute_time() + TickToHostTime(p_sys, first_render_delay);
     }
 
-    do
-    {
-        const size_t i_avalaible_bytes =
-            __MIN(p_block->i_buffer, p_sys->i_out_max_size - p_sys->i_out_size);
-
-        if (unlikely(i_avalaible_bytes != p_block->i_buffer))
-        {
-            /* Not optimal but unlikely code path. */
-
-            lock_unlock(p_sys);
-
-            block_t *p_new = block_Alloc(i_avalaible_bytes);
-            if (!p_new)
-            {
-                block_Release(p_block);
-                return;
-            }
-
-            memcpy(p_new->p_buffer, p_block->p_buffer, i_avalaible_bytes);
-
-            p_block->p_buffer += i_avalaible_bytes;
-            p_block->i_buffer -= i_avalaible_bytes;
-
-            lock_lock(p_sys);
-
-            block_ChainLastAppend(&p_sys->pp_out_last, p_new);
-            p_sys->i_out_size += i_avalaible_bytes;
-
-            if (p_sys->b_paused)
-            {
-                lock_unlock(p_sys);
-                block_Release(p_block);
-                return;
-            }
-
-            /* 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;
-
-            lock_unlock(p_sys);
-            vlc_tick_sleep(i_sleep_ticks);
-            lock_lock(p_sys);
-        }
-        else
-        {
-            block_ChainLastAppend(&p_sys->pp_out_last, p_block);
-            p_sys->i_out_size += i_avalaible_bytes;
-            p_block = NULL;
-        }
-    } while (p_block != NULL);
+    p_sys->i_out_size += p_block->i_buffer;
+    block_ChainLastAppend(&p_sys->pp_out_last, p_block);
 
     size_t i_underrun_size = p_sys->i_underrun_size;
     p_sys->i_underrun_size = 0;
@@ -432,7 +383,7 @@ ca_Initialize(audio_output_t *p_aout, const audio_sample_format_t *fmt,
     p_sys->b_muted = false;
     p_sys->i_render_host_time = p_sys->i_first_render_host_time = 0;
     p_sys->i_last_latency_ticks = VLC_TICK_INVALID;
-    p_sys->i_total_frames = 0;
+    p_sys->i_total_bytes = 0;
 
     p_sys->i_rate = fmt->i_rate;
     p_sys->i_bytes_per_frame = fmt->i_bytes_per_frame;
@@ -440,21 +391,6 @@ ca_Initialize(audio_output_t *p_aout, const audio_sample_format_t *fmt,
 
     p_sys->i_dev_latency_ticks = i_dev_latency_ticks;
 
-    /* setup circular buffer */
-    size_t i_audiobuffer_size = fmt->i_rate * fmt->i_bytes_per_frame
-                              / p_sys->i_frame_length;
-    if (fmt->channel_type == AUDIO_CHANNEL_TYPE_AMBISONICS)
-    {
-        /* lower latency: 200 ms of buffering. XXX: Decrease when VLC's core
-         * can handle lower audio latency */
-        p_sys->i_out_max_size = i_audiobuffer_size / 5;
-    }
-    else
-    {
-        /* 2 seconds of buffering */
-        p_sys->i_out_max_size = i_audiobuffer_size * 2;
-    }
-
     ca_ClearOutBuffers(p_aout);
     p_sys->b_played = false;
 
@@ -466,7 +402,6 @@ ca_Uninitialize(audio_output_t *p_aout)
 {
     struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
     ca_ClearOutBuffers(p_aout);
-    p_sys->i_out_max_size = 0;
     p_sys->chans_to_reorder = 0;
 }
 


=====================================
modules/audio_output/coreaudio_common.h
=====================================
@@ -56,7 +56,6 @@ struct aout_sys_common
     bool                b_muted;
     bool                b_do_flush;
 
-    size_t              i_out_max_size;
     size_t              i_out_size;
     bool                b_played;
     block_t             *p_out_chain;
@@ -64,7 +63,7 @@ struct aout_sys_common
     uint64_t            i_render_host_time;
     uint64_t            i_first_render_host_time;
     vlc_tick_t          i_last_latency_ticks;
-    uint64_t            i_total_frames;
+    uint64_t            i_total_bytes;
 
     vlc_sem_t           flush_sem;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2a31cef61dec875d783cac04d08e7e326afafcc6...76397ea351daefd31062fcc21c14d3e8ee6d246e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2a31cef61dec875d783cac04d08e7e326afafcc6...76397ea351daefd31062fcc21c14d3e8ee6d246e
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list