From 06f88dfb3a86e5d037d885319fbf93fc46d95371 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Wed, 10 Apr 2024 01:12:40 -0400 Subject: [PATCH] ao: rename playthread to ao_thread "playthread" is a confusing name which doesn't describe what it really is. Rename it to ao_thread, and ao_wakeup_playthread to ao_wakeup, in the same style as VO threads. This makes call stack function names less confusing. --- audio/out/ao_audiotrack.c | 4 ++-- audio/out/ao_pulse.c | 4 ++-- audio/out/ao_sndio.c | 2 +- audio/out/buffer.c | 20 ++++++++++---------- audio/out/internal.h | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/audio/out/ao_audiotrack.c b/audio/out/ao_audiotrack.c index aa1b13cb29..db1da9c407 100644 --- a/audio/out/ao_audiotrack.c +++ b/audio/out/ao_audiotrack.c @@ -547,7 +547,7 @@ error: return -1; } -static MP_THREAD_VOID playthread(void *arg) +static MP_THREAD_VOID ao_thread(void *arg) { struct ao *ao = arg; struct priv *p = ao->priv; @@ -766,7 +766,7 @@ static int init(struct ao *ao) goto error; } - if (mp_thread_create(&p->thread, playthread, ao)) { + if (mp_thread_create(&p->thread, ao_thread, ao)) { MP_ERR(ao, "pthread creation failed\n"); goto error; } diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index 68e7a71494..5c86855d71 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -118,7 +118,7 @@ static void stream_request_cb(pa_stream *s, size_t length, void *userdata) { struct ao *ao = userdata; struct priv *priv = ao->priv; - ao_wakeup_playthread(ao); + ao_wakeup(ao); pa_threaded_mainloop_signal(priv->mainloop, 0); } @@ -135,7 +135,7 @@ static void underflow_cb(pa_stream *s, void *userdata) struct priv *priv = ao->priv; priv->playing = false; priv->underrun_signalled = true; - ao_wakeup_playthread(ao); + ao_wakeup(ao); pa_threaded_mainloop_signal(priv->mainloop, 0); } diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c index a766eb9696..309ea4ab74 100644 --- a/audio/out/ao_sndio.c +++ b/audio/out/ao_sndio.c @@ -303,7 +303,7 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state) state->free_samples, state->queued_samples, state->delay); p->playing = false; state->playing = p->playing; - ao_wakeup_playthread(ao); + ao_wakeup(ao); } else { state->playing = p->playing; } diff --git a/audio/out/buffer.c b/audio/out/buffer.c index c9e5d3e2f2..97f7ea147e 100644 --- a/audio/out/buffer.c +++ b/audio/out/buffer.c @@ -41,7 +41,7 @@ struct buffer_state { mp_mutex lock; mp_cond wakeup; - // Playthread sleep + // AO thread sleep mp_mutex pt_lock; mp_cond pt_wakeup; @@ -83,9 +83,9 @@ struct buffer_state { bool terminate; // exit thread }; -static MP_THREAD_VOID playthread(void *arg); +static MP_THREAD_VOID ao_thread(void *arg); -void ao_wakeup_playthread(struct ao *ao) +void ao_wakeup(struct ao *ao) { struct buffer_state *p = ao->buffer_state; mp_mutex_lock(&p->pt_lock); @@ -352,7 +352,7 @@ void ao_reset(struct ao *ao) ao->driver->reset(ao); if (wakeup) - ao_wakeup_playthread(ao); + ao_wakeup(ao); } // Initiate playback. This moves from the stop/underrun state to actually @@ -379,7 +379,7 @@ void ao_start(struct ao *ao) if (do_start) ao->driver->start(ao); - ao_wakeup_playthread(ao); + ao_wakeup(ao); } void ao_set_paused(struct ao *ao, bool paused, bool eof) @@ -448,7 +448,7 @@ void ao_set_paused(struct ao *ao, bool paused, bool eof) } if (wakeup) - ao_wakeup_playthread(ao); + ao_wakeup(ao); } // Whether audio is playing. This means that there is still data in the buffers, @@ -503,7 +503,7 @@ void ao_drain(struct ao *ao) static void wakeup_filters(void *ctx) { struct ao *ao = ctx; - ao_wakeup_playthread(ao); + ao_wakeup(ao); } void ao_uninit(struct ao *ao) @@ -578,7 +578,7 @@ bool init_buffer_post(struct ao *ao) mp_filter_graph_set_wakeup_cb(p->filter_root, wakeup_filters, ao); p->thread_valid = true; - if (mp_thread_create(&p->thread, playthread, ao)) { + if (mp_thread_create(&p->thread, ao_thread, ao)) { p->thread_valid = false; return false; } @@ -701,7 +701,7 @@ eof: return true; } -static MP_THREAD_VOID playthread(void *arg) +static MP_THREAD_VOID ao_thread(void *arg) { struct ao *ao = arg; struct buffer_state *p = ao->buffer_state; @@ -748,6 +748,6 @@ void ao_unblock(struct ao *ao) mp_mutex_lock(&p->lock); p->initial_unblocked = true; mp_mutex_unlock(&p->lock); - ao_wakeup_playthread(ao); + ao_wakeup(ao); } } diff --git a/audio/out/internal.h b/audio/out/internal.h index 3a2e5ae554..51429b9c06 100644 --- a/audio/out/internal.h +++ b/audio/out/internal.h @@ -159,7 +159,7 @@ struct ao_driver { bool (*set_pause)(struct ao *ao, bool paused); // pull based: start the audio callback // push based: start playing queued data - // AO should call ao_wakeup_playthread() if a period boundary + // AO should call ao_wakeup() if a period boundary // is crossed, or playback stops due to external reasons // (including underruns or device removal) // must set mp_pcm_state.playing; unset on error/underrun/end @@ -231,7 +231,7 @@ bool ao_can_convert_inplace(struct ao_convert_fmt *fmt); bool ao_need_conversion(struct ao_convert_fmt *fmt); void ao_convert_inplace(struct ao_convert_fmt *fmt, void **data, int num_samples); -void ao_wakeup_playthread(struct ao *ao); +void ao_wakeup(struct ao *ao); int ao_read_data_converted(struct ao *ao, struct ao_convert_fmt *fmt, void **data, int samples, int64_t out_time_ns);