From 850221793f9b762219f85b678499d1fbaa5994e8 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sun, 8 Mar 2026 03:03:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20audio=20=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=8A=B6=E6=80=81=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E7=BB=99=E5=A4=96=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/audio.c | 9 +++++---- src/audio.h | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/audio.c b/src/audio.c index 34694c0..7bb91bc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -25,6 +25,7 @@ struct pulse_context_t { pa_cvolume volume; pulse_t pulse; uint32_t index; + bool inited; }; static void clean_pulse_context(pulse_context_t *context, bool full_cleanup); @@ -49,7 +50,7 @@ pulse_context_t *init_pulse(GMainContext *context, pulse_notify_t callback) { } void change_pulse_volume(pulse_context_t *context, int step) { - if (!context->pulse.inited || !step || step > 100 || step < -100) return; + if (!context->inited || !step || step > 100 || step < -100) return; pa_cvolume vol = context->volume; if (step > 0) { @@ -69,7 +70,7 @@ void change_pulse_volume(pulse_context_t *context, int step) { } void toggle_pulse_mute(pulse_context_t *context) { - if (!context->pulse.inited) return; + if (!context->inited) return; pa_context *ctx = context->context; uint32_t index = context->index; @@ -92,7 +93,7 @@ void clean_pulse_context(pulse_context_t *context, bool full_cleanup) { pa_context_unref(context->context); context->context = nullptr; } - context->pulse.inited = false; + context->inited = false; if (full_cleanup && context->loop) { pa_glib_mainloop_free(context->loop); context->loop = nullptr; @@ -146,7 +147,7 @@ void sink_info_callback(pa_context *context, const pa_sink_info *info, int eol, if (eol != 0 || !info) return; pulse_context_t *ctx = userdata; - ctx->pulse.inited = true; + ctx->inited = true; ctx->volume = info->volume; ctx->index = info->index; parse_sink(info, &ctx->pulse); diff --git a/src/audio.h b/src/audio.h index 1c01a2f..18f5bf8 100644 --- a/src/audio.h +++ b/src/audio.h @@ -8,8 +8,7 @@ typedef struct pulse_context_t pulse_context_t; typedef struct pulse_t { int volume_percent; bool mute; - bool inited; - char device_name[254]; + char device_name[255]; } pulse_t; typedef void (*pulse_notify_t)(pulse_t *pulse);