Skip to content

Commit

Permalink
coreaudio: simplify flush
Browse files Browse the repository at this point in the history
The semaphore was needed by the previous atomic circular buffer
implementation.
  • Loading branch information
tguillem authored and jbkempf committed Dec 2, 2022
1 parent 370f785 commit c41a355
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
35 changes: 3 additions & 32 deletions modules/audio_output/coreaudio_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ ca_Open(audio_output_t *p_aout)

assert(p_sys->tinfo.denom != 0 && p_sys->tinfo.numer != 0);

vlc_sem_init(&p_sys->flush_sem, 0);
lock_init(p_sys);
p_sys->p_out_chain = NULL;
p_sys->pp_out_last = &p_sys->p_out_chain;
Expand Down Expand Up @@ -155,13 +154,6 @@ ca_Render(audio_output_t *p_aout, uint64_t host_time,

lock_lock(p_sys);

if (p_sys->b_do_flush)
{
ca_ClearOutBuffers(p_aout);
/* Signal that the renderer is flushed */
p_sys->b_do_flush = false;
vlc_sem_post(&p_sys->flush_sem);
}

if (p_sys->b_paused)
goto drop;
Expand Down Expand Up @@ -256,24 +248,16 @@ ca_Flush(audio_output_t *p_aout)
{
struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;

lock_lock(p_sys);

assert(!p_sys->b_do_flush);
if (p_sys->b_paused)
ca_ClearOutBuffers(p_aout);
else
{
p_sys->b_do_flush = true;
lock_unlock(p_sys);
vlc_sem_wait(&p_sys->flush_sem);
lock_lock(p_sys);
}
lock_lock(p_sys);

p_sys->started = false;
p_sys->i_out_size = 0;
p_sys->i_total_bytes = 0;
p_sys->first_play_date = VLC_TICK_INVALID;
p_sys->timing_report_last_written_bytes = 0;

ca_ClearOutBuffers(p_aout);
lock_unlock(p_sys);

p_sys->b_played = false;
Expand Down Expand Up @@ -385,21 +369,8 @@ ca_SetAliveState(audio_output_t *p_aout, bool alive)
struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;

lock_lock(p_sys);

bool b_sem_post = false;
p_sys->b_paused = !alive;
if (!alive && p_sys->b_do_flush)
{
ca_ClearOutBuffers(p_aout);
p_sys->b_played = false;
p_sys->b_do_flush = false;
b_sem_post = true;
}

lock_unlock(p_sys);

if (b_sem_post)
vlc_sem_post(&p_sys->flush_sem);
}

void ca_SetDeviceLatency(audio_output_t *p_aout, vlc_tick_t i_dev_latency_ticks)
Expand Down
3 changes: 0 additions & 3 deletions modules/audio_output/coreaudio_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct aout_sys_common
bool started;
bool b_paused;
bool b_muted;
bool b_do_flush;

bool b_played;
block_t *p_out_chain;
Expand All @@ -71,8 +70,6 @@ struct aout_sys_common
/* Number of bytes to write before sending a timing report */
size_t timing_report_delay_bytes;

vlc_sem_t flush_sem;

union lock
{
#pragma clang diagnostic push
Expand Down

0 comments on commit c41a355

Please sign in to comment.