From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563224984; cv=none; d=zoho.com; s=zohoarc; b=d887+2Xvm165TdIqwEcIzZ6QqEzg2ZpOautB5Z/S0HyFDIL6YscMyf1ZQUxRvXUhgYlPOTpCqaDbKHE6Crth/8y5JB3KL83RB9jXwy61ZP3a+ZllOp0BWZy2Z9y9VEHS+DCNWAJ5dx5kbtB9Ou7UzzVM14AukFeLAWJQVl0QjII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563224984; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N04kGAyyPqX8q8BYYYbKhgnzmzt+O2LAdu0HcQqLcxc=; b=eVxd229uMPSvkLaGHc6t0J8HtcoF5PhIiE8+T1XvqiNsrr9gDBbqDN1v6TQmy6L4TCJKz3CRxbANUjT05hAsO653RZNtvSjm2TbvME2+GPF2iE9Or0Rg3sLdH2xsvLlcWPFiJZ+Ww2GL5a/E+OedFisdUNFSIVAti5peDKI3MPI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563224984263609.000537072936; Mon, 15 Jul 2019 14:09:44 -0700 (PDT) Received: from localhost ([::1]:43808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8EA-0004F5-Pp for importer@patchew.org; Mon, 15 Jul 2019 17:09:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42194) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Ct-0007y8-92 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cr-0004gk-CI for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:23 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34839) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cr-0004g0-4f for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:21 -0400 Received: by mail-wr1-x441.google.com with SMTP id y4so18606343wrm.2 for ; Mon, 15 Jul 2019 14:08:20 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N04kGAyyPqX8q8BYYYbKhgnzmzt+O2LAdu0HcQqLcxc=; b=BUT1ObT0++OlrJZjx89DBF/kXGT1JF5rhOLZOZVEA8hffZsZSM+Su7xmvyTMriw94g w3BV3f90a4IUngZSmj7vjV//625iMUkaFQJ6EHGVJ6oBUMMgp18DjhMLBxx15f8tsl9L 6pqHVFq+9O3J29HhELf3iR0PXo9o0wQfXsw29svjK9gVrwUCeCfMD5SfdL95TABIJiuz 88Lh1eJj2QrzWvwl556xcpbBzWJeJyXzwY25O8vKY0r1vCEOX5NAFGoN8EMSQ9Tk/484 AYRgI+b+k4Dyu1QqAB4fpZcw/U3wMaK20xrU9Neqn1SsAuNC6pblYPApAUZJdCEq9tZC W2ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N04kGAyyPqX8q8BYYYbKhgnzmzt+O2LAdu0HcQqLcxc=; b=CJSu1+VMJQu2/teWgjNSGbEMQB4/bLdXRR+3ulgJsLIWXiO0SdBMNcbak8sPL81NVK Rte1d3ihG2coc3Om4LeqP4oVJTZFiK1a/tRszubcegM3TO890/djpZjz0zZxuUUjrqIU O3kkGGJP2JJExEEVv2Z6kVly/r3eq3VJCAwXwCbR/na+lhrlz6TKjASRpFzyRspBM3oN /DAWpl5j1mAzQ1Clsw/dKdIxq/BP+OaIzyG999CR3/i4tyZ+0BSE62z/cHaeZXp5AKQR 813c5wdbix/UbybS1MYjQa0SvkPmiiIqrNeMwQgPlOyTQSP8WZG8wgHZ+Pls2PveNBDb B4Nw== X-Gm-Message-State: APjAAAWfwT9W+UOLwu97HS/uouGUq/TndBrx4V6IWFcHNLRHd3pYSGWL 4hY4qpaA6ZVpfk6LHo+FKRO0SzhJ X-Google-Smtp-Source: APXvYqyAlKrCZwT1P6Wb7mlXc+IfAFGaXCh5SOpnTsezjmJL046fN9o9Bf7RUJo1Ljp/7kRnDlsvZQ== X-Received: by 2002:a5d:48cf:: with SMTP id p15mr12120214wrs.151.1563224899003; Mon, 15 Jul 2019 14:08:19 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:03 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v2 01/14] audio: reduce glob_audio_state usage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Remove glob_audio_state from functions, where possible without breaking the API. This means that most static functions in audio.c now take an AudioState pointer instead of implicitly using glob_audio_state. Also included a pointer in SWVoice*, HWVoice* structs, so that functions dealing them can know the audio state without having to pass it around separately. This is required in order to support multiple simultaneous audio backends (added in a later commit). Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 8 ++++++ audio/audio_template.h | 46 ++++++++++++++++---------------- audio/audio.c | 59 +++++++++++++++++++----------------------- 3 files changed, 57 insertions(+), 56 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 3f14842709..8164696b2c 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -49,9 +49,11 @@ struct audio_pcm_info { int swap_endianness; }; =20 +typedef struct AudioState AudioState; typedef struct SWVoiceCap SWVoiceCap; =20 typedef struct HWVoiceOut { + AudioState *s; int enabled; int poll_mode; int pending_disable; @@ -73,6 +75,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; =20 typedef struct HWVoiceIn { + AudioState *s; int enabled; int poll_mode; struct audio_pcm_info info; @@ -94,6 +97,7 @@ typedef struct HWVoiceIn { =20 struct SWVoiceOut { QEMUSoundCard *card; + AudioState *s; struct audio_pcm_info info; t_sample *conv; int64_t ratio; @@ -111,6 +115,7 @@ struct SWVoiceOut { =20 struct SWVoiceIn { QEMUSoundCard *card; + AudioState *s; int active; struct audio_pcm_info info; int64_t ratio; @@ -188,6 +193,9 @@ typedef struct AudioState { int nb_hw_voices_in; int vm_running; int64_t period_ticks; + + bool timer_running; + uint64_t timer_last; } AudioState; =20 extern const struct mixeng_volume nominal_volume; diff --git a/audio/audio_template.h b/audio/audio_template.h index 1232bb54db..c721fed75d 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -36,9 +36,9 @@ #define HWBUF hw->conv_buf #endif =20 -static void glue (audio_init_nb_voices_, TYPE) (struct audio_driver *drv) +static void glue(audio_init_nb_voices_, TYPE)(AudioState *s, + struct audio_driver *drv) { - AudioState *s =3D &glob_audio_state; int max_voices =3D glue (drv->max_voices_, TYPE); int voice_size =3D glue (drv->voice_size_, TYPE); =20 @@ -183,8 +183,8 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw) =20 static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) { - AudioState *s =3D &glob_audio_state; HW *hw =3D *hwp; + AudioState *s =3D hw->s; =20 if (!hw->sw_head.lh_first) { #ifdef DAC @@ -199,15 +199,14 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) } } =20 -static HW *glue (audio_pcm_hw_find_any_, TYPE) (HW *hw) +static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioState *s, HW *hw) { - AudioState *s =3D &glob_audio_state; return hw ? hw->entries.le_next : glue (s->hw_head_, TYPE).lh_first; } =20 -static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE) (HW *hw) +static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *h= w) { - while ((hw =3D glue (audio_pcm_hw_find_any_, TYPE) (hw))) { + while ((hw =3D glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) { if (hw->enabled) { return hw; } @@ -215,12 +214,10 @@ static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE= ) (HW *hw) return NULL; } =20 -static HW *glue (audio_pcm_hw_find_specific_, TYPE) ( - HW *hw, - struct audsettings *as - ) +static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioState *s, HW *hw, + struct audsettings *as) { - while ((hw =3D glue (audio_pcm_hw_find_any_, TYPE) (hw))) { + while ((hw =3D glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) { if (audio_pcm_info_eq (&hw->info, as)) { return hw; } @@ -228,10 +225,10 @@ static HW *glue (audio_pcm_hw_find_specific_, TYPE) ( return NULL; } =20 -static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as) +static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s, + struct audsettings *as) { HW *hw; - AudioState *s =3D &glob_audio_state; struct audio_driver *drv =3D s->drv; =20 if (!glue (s->nb_hw_voices_, TYPE)) { @@ -255,6 +252,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct a= udsettings *as) return NULL; } =20 + hw->s =3D s; hw->pcm_ops =3D drv->pcm_ops; hw->ctl_caps =3D drv->ctl_caps; =20 @@ -328,33 +326,33 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYP= E)(Audiodev *dev) abort(); } =20 -static HW *glue (audio_pcm_hw_add_, TYPE) (struct audsettings *as) +static HW *glue(audio_pcm_hw_add_, TYPE)(AudioState *s, struct audsettings= *as) { HW *hw; - AudioState *s =3D &glob_audio_state; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 if (pdo->fixed_settings) { - hw =3D glue (audio_pcm_hw_add_new_, TYPE) (as); + hw =3D glue(audio_pcm_hw_add_new_, TYPE)(s, as); if (hw) { return hw; } } =20 - hw =3D glue (audio_pcm_hw_find_specific_, TYPE) (NULL, as); + hw =3D glue(audio_pcm_hw_find_specific_, TYPE)(s, NULL, as); if (hw) { return hw; } =20 - hw =3D glue (audio_pcm_hw_add_new_, TYPE) (as); + hw =3D glue(audio_pcm_hw_add_new_, TYPE)(s, as); if (hw) { return hw; } =20 - return glue (audio_pcm_hw_find_any_, TYPE) (NULL); + return glue(audio_pcm_hw_find_any_, TYPE)(s, NULL); } =20 -static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( +static SW *glue(audio_pcm_create_voice_pair_, TYPE)( + AudioState *s, const char *sw_name, struct audsettings *as ) @@ -362,7 +360,6 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( SW *sw; HW *hw; struct audsettings hw_as; - AudioState *s =3D &glob_audio_state; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 if (pdo->fixed_settings) { @@ -378,8 +375,9 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( sw_name ? sw_name : "unknown", sizeof (*sw)); goto err1; } + sw->s =3D s; =20 - hw =3D glue (audio_pcm_hw_add_, TYPE) (&hw_as); + hw =3D glue(audio_pcm_hw_add_, TYPE)(s, &hw_as); if (!hw) { goto err2; } @@ -476,7 +474,7 @@ SW *glue (AUD_open_, TYPE) ( } } else { - sw =3D glue (audio_pcm_create_voice_pair_, TYPE) (name, as); + sw =3D glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as); if (!sw) { dolog ("Failed to create voice `%s'\n", name); return NULL; diff --git a/audio/audio.c b/audio/audio.c index 05adf7ffeb..8d2f580788 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -399,12 +399,10 @@ static void noop_conv (struct st_sample *dst, const v= oid *src, int samples) (void) samples; } =20 -static CaptureVoiceOut *audio_pcm_capture_find_specific ( - struct audsettings *as - ) +static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioState *s, + struct audsettings= *as) { CaptureVoiceOut *cap; - AudioState *s =3D &glob_audio_state; =20 for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { if (audio_pcm_info_eq (&cap->hw.info, as)) { @@ -481,7 +479,7 @@ static void audio_detach_capture (HWVoiceOut *hw) =20 static int audio_attach_capture (HWVoiceOut *hw) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D hw->s; CaptureVoiceOut *cap; =20 audio_detach_capture (hw); @@ -789,19 +787,15 @@ static void audio_pcm_print_info (const char *cap, st= ruct audio_pcm_info *info) /* * Timer */ - -static bool audio_timer_running; -static uint64_t audio_timer_last; - -static int audio_is_timer_needed (void) +static int audio_is_timer_needed(AudioState *s) { HWVoiceIn *hwi =3D NULL; HWVoiceOut *hwo =3D NULL; =20 - while ((hwo =3D audio_pcm_hw_find_any_enabled_out (hwo))) { + while ((hwo =3D audio_pcm_hw_find_any_enabled_out(s, hwo))) { if (!hwo->poll_mode) return 1; } - while ((hwi =3D audio_pcm_hw_find_any_enabled_in (hwi))) { + while ((hwi =3D audio_pcm_hw_find_any_enabled_in(s, hwi))) { if (!hwi->poll_mode) return 1; } return 0; @@ -809,18 +803,18 @@ static int audio_is_timer_needed (void) =20 static void audio_reset_timer (AudioState *s) { - if (audio_is_timer_needed ()) { + if (audio_is_timer_needed(s)) { timer_mod_anticipate_ns(s->ts, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->period_ticks); - if (!audio_timer_running) { - audio_timer_running =3D true; - audio_timer_last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + if (!s->timer_running) { + s->timer_running =3D true; + s->timer_last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); trace_audio_timer_start(s->period_ticks / SCALE_MS); } } else { timer_del(s->ts); - if (audio_timer_running) { - audio_timer_running =3D false; + if (s->timer_running) { + s->timer_running =3D false; trace_audio_timer_stop(); } } @@ -832,11 +826,11 @@ static void audio_timer (void *opaque) AudioState *s =3D opaque; =20 now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - diff =3D now - audio_timer_last; + diff =3D now - s->timer_last; if (diff > s->period_ticks * 3 / 2) { trace_audio_timer_delayed(diff / SCALE_MS); } - audio_timer_last =3D now; + s->timer_last =3D now; =20 audio_run("timer"); audio_reset_timer(s); @@ -890,7 +884,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) =20 hw =3D sw->hw; if (sw->active !=3D on) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D sw->s; SWVoiceOut *temp_sw; SWVoiceCap *sc; =20 @@ -937,7 +931,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) =20 hw =3D sw->hw; if (sw->active !=3D on) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D sw->s; SWVoiceIn *temp_sw; =20 if (on) { @@ -1060,7 +1054,7 @@ static void audio_run_out (AudioState *s) HWVoiceOut *hw =3D NULL; SWVoiceOut *sw; =20 - while ((hw =3D audio_pcm_hw_find_any_enabled_out (hw))) { + while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { int played; int live, free, nb_live, cleanup_required, prev_rpos; =20 @@ -1165,7 +1159,7 @@ static void audio_run_in (AudioState *s) { HWVoiceIn *hw =3D NULL; =20 - while ((hw =3D audio_pcm_hw_find_any_enabled_in (hw))) { + while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { SWVoiceIn *sw; int captured =3D 0, min; =20 @@ -1271,8 +1265,8 @@ static int audio_driver_init(AudioState *s, struct au= dio_driver *drv, s->drv_opaque =3D drv->init(dev); =20 if (s->drv_opaque) { - audio_init_nb_voices_out (drv); - audio_init_nb_voices_in (drv); + audio_init_nb_voices_out(s, drv); + audio_init_nb_voices_in(s, drv); s->drv =3D drv; return 0; } @@ -1293,11 +1287,11 @@ static void audio_vm_change_state_handler (void *op= aque, int running, int op =3D running ? VOICE_ENABLE : VOICE_DISABLE; =20 s->vm_running =3D running; - while ((hwo =3D audio_pcm_hw_find_any_enabled_out (hwo))) { + while ((hwo =3D audio_pcm_hw_find_any_enabled_out(s, hwo))) { hwo->pcm_ops->ctl_out(hwo, op); } =20 - while ((hwi =3D audio_pcm_hw_find_any_enabled_in (hwi))) { + while ((hwi =3D audio_pcm_hw_find_any_enabled_in(s, hwi))) { hwi->pcm_ops->ctl_in(hwi, op); } audio_reset_timer (s); @@ -1317,7 +1311,7 @@ void audio_cleanup(void) HWVoiceIn *hwi, *hwin; =20 is_cleaning_up =3D true; - QLIST_FOREACH_SAFE(hwo, &glob_audio_state.hw_head_out, entries, hwon) { + QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) { SWVoiceCap *sc; =20 if (hwo->enabled) { @@ -1336,7 +1330,7 @@ void audio_cleanup(void) QLIST_REMOVE(hwo, entries); } =20 - QLIST_FOREACH_SAFE(hwi, &glob_audio_state.hw_head_in, entries, hwin) { + QLIST_FOREACH_SAFE(hwi, &s->hw_head_in, entries, hwin) { if (hwi->enabled) { hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE); } @@ -1532,7 +1526,7 @@ CaptureVoiceOut *AUD_add_capture ( cb->ops =3D *ops; cb->opaque =3D cb_opaque; =20 - cap =3D audio_pcm_capture_find_specific (as); + cap =3D audio_pcm_capture_find_specific(s, as); if (cap) { QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); return cap; @@ -1544,6 +1538,7 @@ CaptureVoiceOut *AUD_add_capture ( cap =3D g_malloc0(sizeof(*cap)); =20 hw =3D &cap->hw; + hw->s =3D s; QLIST_INIT (&hw->sw_head); QLIST_INIT (&cap->cb_head); =20 @@ -1564,7 +1559,7 @@ CaptureVoiceOut *AUD_add_capture ( QLIST_INSERT_HEAD (&s->cap_head, cap, entries); QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); =20 - QLIST_FOREACH(hw, &glob_audio_state.hw_head_out, entries) { + QLIST_FOREACH(hw, &s->hw_head_out, entries) { audio_attach_capture (hw); } return cap; --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563224939; cv=none; d=zoho.com; s=zohoarc; b=dUrpllErcgxHIO1WL7uf4V/krTxgNuEIjQEf4vvEofyJdgJhYFkUquU5gJfbUsJIfTGE6qntHK4y8HZ8oHjJEgdYBcpjLqaGafGhnQNfL/6VNMlYjJtQKjXnEN6LnKyf2Xte3Flxc0txRhkLezZ2YE/FdQI49j3Rhxz7U0r+uPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563224939; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9EOsiPzupC9z3cs4OAkQhKC9rm1e4IxaFYIyQRaOKTQ=; b=iDl5B1LPS6l8DDTReS4R6BTBcF4GiQgUPz9hzzNmltJQaxR76Lj2LAGR/XMnvNqUva2BpvbIIcpk6feHL8qiZvwbAQOyfx+Ohaf+S/3DitgX+UufJ9GltzcQDcUZIZPrgPNzXKnIcsIgWMGlcn4hUWttTToRkrRGTt6GbuZ94To= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563224939328916.938831673242; Mon, 15 Jul 2019 14:08:59 -0700 (PDT) Received: from localhost ([::1]:43784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8DR-00015M-S6 for importer@patchew.org; Mon, 15 Jul 2019 17:08:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42192) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Ct-0007y7-7f for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cr-0004gx-HM for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:23 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:41104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cr-0004gS-9L for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:21 -0400 Received: by mail-wr1-x443.google.com with SMTP id c2so15388838wrm.8 for ; Mon, 15 Jul 2019 14:08:21 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9EOsiPzupC9z3cs4OAkQhKC9rm1e4IxaFYIyQRaOKTQ=; b=krk6iapGlGo/qI9C2tVUenIxzRE3PFfjd1SvRsaXrFMBGvpIhYtccCNQ6W+TmNQDnB 6OBVEC/n0mc1qXI8SxTQ1+V4j2PuMewXjj9muPJGOVL/9vWZ5L0uUyapqVmr2pH339MX uc1JNul1RICLK8SvEELWyU2qaygLcviUW4SZuG+CrTbILBJmhCvcRf6UmDpZGDWRRZcO k1oI3/GNl0DbA4uDzEKmMDjDtg9S4kKTue+a9/uJ859olWbqvZTvvneJtunVl7qeCw92 gqEGmVS8AcQN4hCBJMD02x3JsIBFG/GeBto7ai0/FJTn+GDLc/GmMLRs3qzpzQS4bjBQ IZgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9EOsiPzupC9z3cs4OAkQhKC9rm1e4IxaFYIyQRaOKTQ=; b=IQQwVPfKpFw7UVh2AZVKCQRMuVJbakzFJrgkPurq3vCasEaRFGVZPLgPA9A38qkeTx z6EYzfRyLPIt8UfLubFCI8w/7CQ8xu56Vx+ppCaRj66r2qZQ+RXN0t5m9RjTVy7PsArk J+tumMVGp9yP8wJ51dlap+VgLAauyIWUoBlMPR7dh9JjFHdHBfMElKltHwcQeTF1nCYx JOvHsneTV6kZMUblxLCceGbLIR/btzsXE14WtWI2GFeE3hQ8qb00qOWYdhJjXEU/i3/j Zxs2NhcHROJvWr8YTryJ0o114nwMlu5DrsW/qfFU0Vpk5nK68UVEEjv4Jco62udJVJMy 1rJQ== X-Gm-Message-State: APjAAAWFGBO5C9Uji0JXuuNcb2jzE0bTBQUhNjQCt/0q95gyJdWLLW1X 2/RDklwVOZsnTIFSrTUOJ21PMjlC X-Google-Smtp-Source: APXvYqwE4ZW4pXdv713Kqr6SnUgGEq5OU6LQQ++w0vSlaredEcNVGUU0NrtitLh6aIBkVj12/VbUkw== X-Received: by 2002:a5d:6a84:: with SMTP id s4mr30438188wru.125.1563224899901; Mon, 15 Jul 2019 14:08:19 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:04 +0200 Message-Id: <090b3d94b6fd0d35a319b8092e68eb673285f661.1563224628.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v2 02/14] audio: basic support for multi backend audio X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Dr. David Alan Gilbert" , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Audio functions no longer access glob_audio_state, instead they get an AudioState as a parameter. This is required in order to support multiple backends. glob_audio_state is also gone, and replaced with a tailq so we can store more than one states. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- Notes: Changes from v1: =20 * Moved wav_capture/vnc audiodev param to a separate commit audio/audio.h | 12 +++-- audio/audio_int.h | 2 + audio/audio_template.h | 2 +- audio/audio.c | 102 +++++++++++++++++++++++++++++++---------- audio/wavcapture.c | 6 +-- monitor/misc.c | 2 +- ui/vnc.c | 2 +- 7 files changed, 95 insertions(+), 33 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index 64b0f761bc..ad2457f4de 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -78,8 +78,10 @@ typedef struct SWVoiceOut SWVoiceOut; typedef struct CaptureVoiceOut CaptureVoiceOut; typedef struct SWVoiceIn SWVoiceIn; =20 +typedef struct AudioState AudioState; typedef struct QEMUSoundCard { char *name; + AudioState *state; QLIST_ENTRY (QEMUSoundCard) entries; } QEMUSoundCard; =20 @@ -92,7 +94,8 @@ void AUD_log (const char *cap, const char *fmt, ...) GCC_= FMT_ATTR(2, 3); =20 void AUD_register_card (const char *name, QEMUSoundCard *card); void AUD_remove_card (QEMUSoundCard *card); -CaptureVoiceOut *AUD_add_capture ( +CaptureVoiceOut *AUD_add_capture( + AudioState *s, struct audsettings *as, struct audio_capture_ops *ops, void *opaque @@ -160,8 +163,8 @@ static inline void *advance (void *p, int incr) #define audio_MAX(a, b) ((a)<(b)?(b):(a)) #endif =20 -int wav_start_capture (CaptureState *s, const char *path, int freq, - int bits, int nchannels); +int wav_start_capture(AudioState *state, CaptureState *s, const char *path, + int freq, int bits, int nchannels); =20 bool audio_is_cleaning_up(void); void audio_cleanup(void); @@ -175,4 +178,7 @@ void audio_parse_option(const char *opt); void audio_init_audiodevs(void); void audio_legacy_help(void); =20 +AudioState *audio_state_by_name(const char *name); +const char *audio_get_id(QEMUSoundCard *card); + #endif /* QEMU_AUDIO_H */ diff --git a/audio/audio_int.h b/audio/audio_int.h index 8164696b2c..9f01f6ad00 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -196,6 +196,8 @@ typedef struct AudioState { =20 bool timer_running; uint64_t timer_last; + + QTAILQ_ENTRY(AudioState) list; } AudioState; =20 extern const struct mixeng_volume nominal_volume; diff --git a/audio/audio_template.h b/audio/audio_template.h index c721fed75d..54f07338e7 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -428,7 +428,7 @@ SW *glue (AUD_open_, TYPE) ( struct audsettings *as ) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D card->state; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 if (audio_bug(__func__, !card || !name || !callback_fn || !as)) { diff --git a/audio/audio.c b/audio/audio.c index 8d2f580788..4baa37caac 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -87,7 +87,8 @@ audio_driver *audio_driver_lookup(const char *name) return NULL; } =20 -static AudioState glob_audio_state; +static QTAILQ_HEAD(AudioStateHead, AudioState) audio_states =3D + QTAILQ_HEAD_INITIALIZER(audio_states); =20 const struct mixeng_volume nominal_volume =3D { .mute =3D 0, @@ -1236,11 +1237,14 @@ static void audio_run_capture (AudioState *s) =20 void audio_run (const char *msg) { - AudioState *s =3D &glob_audio_state; + AudioState *s; + + QTAILQ_FOREACH(s, &audio_states, list) { + audio_run_out(s); + audio_run_in(s); + audio_run_capture(s); + } =20 - audio_run_out (s); - audio_run_in (s); - audio_run_capture (s); #ifdef DEBUG_POLL { static double prevtime; @@ -1304,13 +1308,11 @@ bool audio_is_cleaning_up(void) return is_cleaning_up; } =20 -void audio_cleanup(void) +static void free_audio_state(AudioState *s) { - AudioState *s =3D &glob_audio_state; HWVoiceOut *hwo, *hwon; HWVoiceIn *hwi, *hwin; =20 - is_cleaning_up =3D true; QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) { SWVoiceCap *sc; =20 @@ -1347,6 +1349,17 @@ void audio_cleanup(void) qapi_free_Audiodev(s->dev); s->dev =3D NULL; } + g_free(s); +} + +void audio_cleanup(void) +{ + is_cleaning_up =3D true; + while (!QTAILQ_EMPTY(&audio_states)) { + AudioState *s =3D QTAILQ_FIRST(&audio_states); + QTAILQ_REMOVE(&audio_states, s, list); + free_audio_state(s); + } } =20 static const VMStateDescription vmstate_audio =3D { @@ -1373,28 +1386,33 @@ static AudiodevListEntry *audiodev_find( return NULL; } =20 -static int audio_init(Audiodev *dev) +/* + * if we have dev, this function was called because of an -audiodev argume= nt =3D> + * initialize a new state with it + * if dev =3D=3D NULL =3D> legacy implicit initialization, return the alre= ady created + * state or create a new one + */ +static AudioState *audio_init(Audiodev *dev) { + static bool atexit_registered; size_t i; int done =3D 0; const char *drvname =3D NULL; VMChangeStateEntry *e; - AudioState *s =3D &glob_audio_state; + AudioState *s; struct audio_driver *driver; /* silence gcc warning about uninitialized variable */ AudiodevListHead head =3D QSIMPLEQ_HEAD_INITIALIZER(head); =20 - if (s->drv) { - if (dev) { - dolog("Cannot create more than one audio backend, sorry\n"); - qapi_free_Audiodev(dev); - } - return -1; - } - if (dev) { /* -audiodev option */ drvname =3D AudiodevDriver_str(dev->driver); + } else if (!QTAILQ_EMPTY(&audio_states)) { + /* + * todo: check for -audiodev once we have normal audiodev selection + * support + */ + return QTAILQ_FIRST(&audio_states); } else { /* legacy implicit initialization */ head =3D audio_handle_legacy_opts(); @@ -1408,12 +1426,18 @@ static int audio_init(Audiodev *dev) dev =3D QSIMPLEQ_FIRST(&head)->dev; audio_validate_opts(dev, &error_abort); } + + s =3D g_malloc0(sizeof(AudioState)); s->dev =3D dev; =20 QLIST_INIT (&s->hw_head_out); QLIST_INIT (&s->hw_head_in); QLIST_INIT (&s->cap_head); - atexit(audio_cleanup); + if (!atexit_registered) { + atexit(audio_cleanup); + atexit_registered =3D true; + } + QTAILQ_INSERT_TAIL(&audio_states, s, list); =20 s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); =20 @@ -1478,7 +1502,7 @@ static int audio_init(Audiodev *dev) =20 QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); - return 0; + return s; } =20 void audio_free_audiodev_list(AudiodevListHead *head) @@ -1493,10 +1517,13 @@ void audio_free_audiodev_list(AudiodevListHead *hea= d) =20 void AUD_register_card (const char *name, QEMUSoundCard *card) { - audio_init(NULL); + if (!card->state) { + card->state =3D audio_init(NULL); + } + card->name =3D g_strdup (name); memset (&card->entries, 0, sizeof (card->entries)); - QLIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries); + QLIST_INSERT_HEAD(&card->state->card_head, card, entries); } =20 void AUD_remove_card (QEMUSoundCard *card) @@ -1506,16 +1533,21 @@ void AUD_remove_card (QEMUSoundCard *card) } =20 =20 -CaptureVoiceOut *AUD_add_capture ( +CaptureVoiceOut *AUD_add_capture( + AudioState *s, struct audsettings *as, struct audio_capture_ops *ops, void *cb_opaque ) { - AudioState *s =3D &glob_audio_state; CaptureVoiceOut *cap; struct capture_callback *cb; =20 + if (!s) { + /* todo: remove when we have normal audiodev selection support */ + s =3D audio_init(NULL); + } + if (audio_validate_settings (as)) { dolog ("Invalid settings were passed when trying to add capture\n"= ); audio_print_settings (as); @@ -1805,3 +1837,25 @@ int audio_buffer_bytes(AudiodevPerDirectionOptions *= pdo, return audio_buffer_samples(pdo, as, def_usecs) * audioformat_bytes_per_sample(as->fmt); } + +AudioState *audio_state_by_name(const char *name) +{ + AudioState *s; + QTAILQ_FOREACH(s, &audio_states, list) { + assert(s->dev); + if (strcmp(name, s->dev->id) =3D=3D 0) { + return s; + } + } + return NULL; +} + +const char *audio_get_id(QEMUSoundCard *card) +{ + if (card->state) { + assert(card->state->dev); + return card->state->dev->id; + } else { + return ""; + } +} diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 74320dfecc..81c5c19032 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -105,8 +105,8 @@ static struct capture_ops wav_capture_ops =3D { .info =3D wav_capture_info }; =20 -int wav_start_capture (CaptureState *s, const char *path, int freq, - int bits, int nchannels) +int wav_start_capture(AudioState *state, CaptureState *s, const char *path, + int freq, int bits, int nchannels) { WAVState *wav; uint8_t hdr[] =3D { @@ -171,7 +171,7 @@ int wav_start_capture (CaptureState *s, const char *pat= h, int freq, goto error_free; } =20 - cap =3D AUD_add_capture (&as, &ops, wav); + cap =3D AUD_add_capture(state, &as, &ops, wav); if (!cap) { error_report("Failed to add audio capture"); goto error_free; diff --git a/monitor/misc.c b/monitor/misc.c index 00338c002a..e393333a0e 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1156,7 +1156,7 @@ static void hmp_wavcapture(Monitor *mon, const QDict = *qdict) bits =3D has_bits ? bits : 16; nchannels =3D has_channels ? nchannels : 2; =20 - if (wav_start_capture (s, path, freq, bits, nchannels)) { + if (wav_start_capture(NULL, s, path, freq, bits, nchannels)) { monitor_printf(mon, "Failed to add wave capture\n"); g_free (s); return; diff --git a/ui/vnc.c b/ui/vnc.c index 38f92bfca3..140f364dda 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1222,7 +1222,7 @@ static void audio_add(VncState *vs) ops.destroy =3D audio_capture_destroy; ops.capture =3D audio_capture; =20 - vs->audio_cap =3D AUD_add_capture(&vs->as, &ops, vs); + vs->audio_cap =3D AUD_add_capture(NULL, &vs->as, &ops, vs); if (!vs->audio_cap) { error_report("Failed to add audio capture"); } --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563224938; cv=none; d=zoho.com; s=zohoarc; b=in/WPnU3orodw6TmF7a+vg9fBEC2wkD1rqVw9bJSP7X9ALkxIuQ76I7BEDjI4jTz6iGn5tQPeIJj2BQ74M2pP5Kcy5VtzjlkDXmuQABaOyqmK6YYwqz3aNv4I6pGt+WziH+BSX/0dUWHe9MXTDnl0/Mmu7kcEzD+JGT93jKh3hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563224938; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=s2tGSyvv00Yi1rKW6w+xYpFuKwqco4esCgAG5oDvlLQ=; b=WZbmDX304Xtk57VFdMTVGNGeI+9KHBrAj5sjo6N+BgxLz36uCZ4e6OJktrB0MaMzxZy8+B8gW3OeCtpvk5gNOI9jYF2h4ts++kFJYgFzQne1+NHHR7M8KBp4vRdX16TzwaCv+V+k8xnFlNuLbWNrRfbHN/cS/0rP6/VaUpXc8nE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563224938570869.0483817297209; Mon, 15 Jul 2019 14:08:58 -0700 (PDT) Received: from localhost ([::1]:43782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8DL-0000lK-Qr for importer@patchew.org; Mon, 15 Jul 2019 17:08:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42204) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Ct-0007y9-N0 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cs-0004hU-Cb for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:23 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cs-0004gu-6D for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:22 -0400 Received: by mail-wr1-x444.google.com with SMTP id c2so15388878wrm.8 for ; Mon, 15 Jul 2019 14:08:22 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s2tGSyvv00Yi1rKW6w+xYpFuKwqco4esCgAG5oDvlLQ=; b=BaYwlLQlsmL8w7XclIai0HT+ts//HzbW8yteAOnSKGslPnV8bbtHfP80cX6WyVL1GO U3n0KInkCiOit3SP8fzQSvfuGpY3PvElzEqQ6D6FCiXJxLEJSkY7VVyiTi8oLkIw2grw ZqXILjFayT+TuLbzwdPqxeCb8K9v65SMSTwwZsWcx3LSf1MsxlJzZwiMJkqu1MISywgp iRlXxom7f17GmzjXpGfJxRJ8omduqHu9EIBD0wyhuGY8qZKUTwWw0iu0PSVsgnhqQtCa k9PJBO4NhYXyKN3wBV5WsjFZ2UZcAJGBMAPykqX0RjBfo4+HMhiUJreku7ti1Q4QerZQ ufEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s2tGSyvv00Yi1rKW6w+xYpFuKwqco4esCgAG5oDvlLQ=; b=hfspZSPVvEc+IoUxNWj2Rp1zoSfa8jdiFQlvxEOBQfVvIzmUr2cDi91bmYo6B+IYQG E6N78rxuLBw7V2snyAoEcnKmzKMLTDDOnFy5H2mZleKKAUgnmZqJ6lB2hEHIssN7DrVj wdI9F6Okg2Ksyu3CY2ChkitcYzv38ZZtKxXrPX6WABgoNjQlIfdRbPTq54LlNiSpRgDZ YxyuBnyZOTnIFnS0qOJmTFZoy88KpDpDfH8BBe9dCfMIg1Acj/C8hknR0p4wkuPDOfPa PeokC1gobJMyD/YBa+XA0QgSccyz4KubRGL3lXOTOj+fOb1ZWnPoGI5ZqaKKHLsQTg+r tCew== X-Gm-Message-State: APjAAAWOdPWfsPDd74RGs7PpdJa4Y+5toNoL/wv57w6BrJRVpyPaVrDI kXKzX9qmsKNEOBjmTcnA7KI6Rl67 X-Google-Smtp-Source: APXvYqwFv5kXjbOEHdL+Ln2WzBq6Lxw+2D52rG4xz5IauYz1qGVzKBNS5HQHpS/t9/pBYe4kyrBOZQ== X-Received: by 2002:adf:ce88:: with SMTP id r8mr3822997wrn.42.1563224900885; Mon, 15 Jul 2019 14:08:20 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:05 +0200 Message-Id: <8245dab2e59b99b55f3f7773fd39dc920ae48951.1563224628.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v2 03/14] audio: add audiodev property to vnc and wav_capture X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Gerd Hoffmann , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- ui/vnc.h | 2 ++ monitor/misc.c | 12 +++++++++++- ui/vnc.c | 15 ++++++++++++++- hmp-commands.hx | 13 ++++++++----- qemu-options.hx | 6 ++++++ 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/ui/vnc.h b/ui/vnc.h index 2f84db3142..6f54653455 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -183,6 +183,8 @@ struct VncDisplay #ifdef CONFIG_VNC_SASL VncDisplaySASL sasl; #endif + + AudioState *audio_state; }; =20 typedef struct VncTight { diff --git a/monitor/misc.c b/monitor/misc.c index e393333a0e..f97810d370 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1148,7 +1148,17 @@ static void hmp_wavcapture(Monitor *mon, const QDict= *qdict) int bits =3D qdict_get_try_int(qdict, "bits", -1); int has_channels =3D qdict_haskey(qdict, "nchannels"); int nchannels =3D qdict_get_try_int(qdict, "nchannels", -1); + const char *audiodev =3D qdict_get_try_str(qdict, "audiodev"); CaptureState *s; + AudioState *as =3D NULL; + + if (audiodev) { + as =3D audio_state_by_name(audiodev); + if (!as) { + monitor_printf(mon, "Invalid audiodev specified\n"); + return; + } + } =20 s =3D g_malloc0 (sizeof (*s)); =20 @@ -1156,7 +1166,7 @@ static void hmp_wavcapture(Monitor *mon, const QDict = *qdict) bits =3D has_bits ? bits : 16; nchannels =3D has_channels ? nchannels : 2; =20 - if (wav_start_capture(NULL, s, path, freq, bits, nchannels)) { + if (wav_start_capture(as, s, path, freq, bits, nchannels)) { monitor_printf(mon, "Failed to add wave capture\n"); g_free (s); return; diff --git a/ui/vnc.c b/ui/vnc.c index 140f364dda..24f9be5b5d 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1222,7 +1222,7 @@ static void audio_add(VncState *vs) ops.destroy =3D audio_capture_destroy; ops.capture =3D audio_capture; =20 - vs->audio_cap =3D AUD_add_capture(NULL, &vs->as, &ops, vs); + vs->audio_cap =3D AUD_add_capture(vs->vd->audio_state, &vs->as, &ops, = vs); if (!vs->audio_cap) { error_report("Failed to add audio capture"); } @@ -3369,6 +3369,9 @@ static QemuOptsList qemu_vnc_opts =3D { },{ .name =3D "non-adaptive", .type =3D QEMU_OPT_BOOL, + },{ + .name =3D "audiodev", + .type =3D QEMU_OPT_STRING, }, { /* end of list */ } }, @@ -3806,6 +3809,7 @@ void vnc_display_open(const char *id, Error **errp) const char *saslauthz; int lock_key_sync =3D 1; int key_delay_ms; + const char *audiodev; =20 if (!vd) { error_setg(errp, "VNC display not active"); @@ -3991,6 +3995,15 @@ void vnc_display_open(const char *id, Error **errp) } vd->ledstate =3D 0; =20 + audiodev =3D qemu_opt_get(opts, "audiodev"); + if (audiodev) { + vd->audio_state =3D audio_state_by_name(audiodev); + if (!vd->audio_state) { + error_setg(errp, "Audiodev '%s' not found", audiodev); + goto fail; + } + } + device_id =3D qemu_opt_get(opts, "display"); if (device_id) { int head =3D qemu_opt_get_number(opts, "head", 0); diff --git a/hmp-commands.hx b/hmp-commands.hx index bfa5681dd2..fa7f009268 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -819,16 +819,19 @@ ETEXI =20 { .name =3D "wavcapture", - .args_type =3D "path:F,freq:i?,bits:i?,nchannels:i?", - .params =3D "path [frequency [bits [channels]]]", + .args_type =3D "path:F,freq:i?,bits:i?,nchannels:i?,audiodev:s?", + .params =3D "path [frequency [bits [channels [audiodev]]]]", .help =3D "capture audio to a wave file (default frequency= =3D44100 bits=3D16 channels=3D2)", .cmd =3D hmp_wavcapture, }, STEXI -@item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channel= s}]]] +@item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channel= s} [@var{audiodev}]]]] @findex wavcapture -Capture audio into @var{filename}. Using sample rate @var{frequency} -bits per sample @var{bits} and number of channels @var{channels}. +Capture audio into @var{filename} from @var{audiodev}, using sample rate +@var{frequency} bits per sample @var{bits} and number of channels +@var{channels}. When not using an -audiodev argument on command line, +@var{audiodev} must be omitted, otherwise is must specify a valid +audiodev. =20 Defaults: @itemize @minus diff --git a/qemu-options.hx b/qemu-options.hx index 9621e934c0..a308e5f5aa 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1978,6 +1978,12 @@ can help the device and guest to keep up and not los= e events in case events are arriving in bulk. Possible causes for the latter are flaky network connections, or scripts for automated testing. =20 +@item audiodev=3D@var{audiodev} + +Use the specified @var{audiodev} when the VNC client requests audio +transmission. When not using an -audiodev argument, this option must +be omitted, otherwise is must be present and specify a valid audiodev. + @end table ETEXI =20 --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563224980; cv=none; d=zoho.com; s=zohoarc; b=NQyX6WE+lDtGxA00isA5dSFNioKJmUVkmBK3S4xrSVrrWkO0bi9LGLqM8ExLHYb6qYyFYVlKskUKDxf4P/wc3OxvmRnvGjsAI+9YOaXcZFBMo9D/VeQ1fBhBJon5Rk+/TCLB2Zp9CadGYWMF9ISnQlTpEU986ZSjOlAhCMGPJVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563224980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=THYF8P8oP1LtFmW+vLVidPiCPGgRINpP2KqOOOP7jgY=; b=jslQaD0NDgFaHTJ94qUUuX/AUf86mTy5XpL3DL2Fz6JyzUwU7pkBlXKGm15wWipM+ZE/zpjKT6QB1UmAnTiagVmp1dVYwyzFF7JdM8UJbc9wp16V7jBLgX+E6IthPVfsjhpvBB4Li3WXkW2R/HR+iCqYn0nFv/3c+892eKh2+Gc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563224980679643.9233649170212; Mon, 15 Jul 2019 14:09:40 -0700 (PDT) Received: from localhost ([::1]:43804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8E4-0003s6-OU for importer@patchew.org; Mon, 15 Jul 2019 17:09:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42223) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Cv-0007ya-9G for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Ct-0004iZ-GS for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:25 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43199) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Ct-0004hl-8P for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:23 -0400 Received: by mail-wr1-x441.google.com with SMTP id p13so18551801wru.10 for ; Mon, 15 Jul 2019 14:08:23 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=THYF8P8oP1LtFmW+vLVidPiCPGgRINpP2KqOOOP7jgY=; b=tazWqc5WOqnWWOq9HxYZKWDsAxdUVwKtRjmOKaVY42w6MdJS6G//NQadtpNRZpy+gh DrdgN4EfTvMOwhTddXLFdKPk+yVQ7L3C6jdb43QBHqPplxqg/QqBZ/DdWyKao+D5N8X/ F8ZFQZuFAbmSiMOcPoTJQRLUmtRtZ/i1FxNzJ7ZKLxKGRVz6ub/FfhclSPeJtAVySyBg qUbscYCw/uZyizNm1vohozT2+R8PKvKvDSZ4eBh96K0giQOat3xaaV9ePPkehBH1UNPe 2JGtF1krOhPZQDBHJ3ZTuJSb7GnL6F7Enoel8TYrEIX+baDA4TsdwZGrHLVaOCMbZuGr KvjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=THYF8P8oP1LtFmW+vLVidPiCPGgRINpP2KqOOOP7jgY=; b=ImlTU2QlKV/+u+qTlToXJgi4I+JO2J5DP1yDZ5WKnyurBykl8H4qedpPFUu/vk4gDW 0PnZX2CUYXGTIXYdEr5uOv0QQ58Oqtw4PN+PkJrrKnsIOcKy3+qW7vRb4gvd3Fz8v67Q ej3C+YZmiBnHYvzPbr8rAUzx066KLq6E+lhRp14V1/uH3quQxiwPnniPK32DYEsCFNv9 eHZxKZVYBQbMPLsVmWwdGUl/0g58gegUK/bQqogQ3Jlu19r7wkMWLUoVEQynQur2nApI anNPkbvd9ZgRFFXZPiMAow45i5mKPQVSxMTN0QSve7dK1kJXkOI1YpoJ3b18mAaJnsrt D8oQ== X-Gm-Message-State: APjAAAVyFwR+xc3B6/sRk72orN6fVq4hNb8rBRNPZOsHx94D1b4bk0JP YJhdWD56xk7v8E3VwlnK43gueRKo4nM= X-Google-Smtp-Source: APXvYqwBMh+NqwkPJOC7KAYOWthYy2Ni3h97uoMhg1DAgNgfXYPxHs1OiUggtpurMVX3CK0u6YTATQ== X-Received: by 2002:a5d:4941:: with SMTP id r1mr29648149wrs.225.1563224901897; Mon, 15 Jul 2019 14:08:21 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:06 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v2 04/14] audio: add audiodev properties to frontends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Michael Walle , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Finally add audiodev=3D options to audio frontends so users can specify which backend to use when multiple backends exist. Not specifying an audiodev=3D option currently causes the first audiodev to be used, this is fixed in the next commit. Example usage: -audiodev pa,id=3Dfoo -device AC97,audiodev=3Dfoo Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.h | 3 ++ include/hw/qdev-properties.h | 3 ++ hw/audio/ac97.c | 1 + hw/audio/adlib.c | 1 + hw/audio/cs4231a.c | 1 + hw/audio/es1370.c | 7 +++- hw/audio/gus.c | 1 + hw/audio/hda-codec.c | 1 + hw/audio/milkymist-ac97.c | 6 ++++ hw/audio/pcspk.c | 1 + hw/audio/pl041.c | 1 + hw/audio/sb16.c | 1 + hw/audio/wm8750.c | 6 ++++ hw/core/qdev-properties-system.c | 57 ++++++++++++++++++++++++++++++++ hw/usb/dev-audio.c | 1 + 15 files changed, 90 insertions(+), 1 deletion(-) diff --git a/audio/audio.h b/audio/audio.h index ad2457f4de..c0722a5cda 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -181,4 +181,7 @@ void audio_legacy_help(void); AudioState *audio_state_by_name(const char *name); const char *audio_get_id(QEMUSoundCard *card); =20 +#define DEFINE_AUDIO_PROPERTIES(_s, _f) \ + DEFINE_PROP_AUDIODEV("audiodev", _s, _f) + #endif /* QEMU_AUDIO_H */ diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 1eae5ab056..de0b2c8423 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -35,6 +35,7 @@ extern const PropertyInfo qdev_prop_blocksize; extern const PropertyInfo qdev_prop_pci_host_devaddr; extern const PropertyInfo qdev_prop_uuid; extern const PropertyInfo qdev_prop_arraylen; +extern const PropertyInfo qdev_prop_audiodev; extern const PropertyInfo qdev_prop_link; extern const PropertyInfo qdev_prop_off_auto_pcibar; extern const PropertyInfo qdev_prop_pcie_link_speed; @@ -236,6 +237,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width; + type_check(QemuUUID, typeof_field(_state, _field)), \ .set_default =3D true, \ } +#define DEFINE_PROP_AUDIODEV(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard) =20 #define DEFINE_PROP_END_OF_LIST() \ {} diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index fb98da2678..0d8e524233 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -1409,6 +1409,7 @@ static int ac97_init (PCIBus *bus) } =20 static Property ac97_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(AC97LinkState, card), DEFINE_PROP_UINT32 ("use_broken_id", AC97LinkState, use_broken_id, 0), DEFINE_PROP_END_OF_LIST (), }; diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index 7dd9a89b89..df2e781788 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -299,6 +299,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) } =20 static Property adlib_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(AdlibState, card), DEFINE_PROP_UINT32 ("iobase", AdlibState, port, 0x220), DEFINE_PROP_UINT32 ("freq", AdlibState, freq, 44100), DEFINE_PROP_END_OF_LIST (), diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 7216b41cc1..e3ea830b47 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -689,6 +689,7 @@ static int cs4231a_init (ISABus *bus) } =20 static Property cs4231a_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(CSState, card), DEFINE_PROP_UINT32 ("iobase", CSState, port, 0x534), DEFINE_PROP_UINT32 ("irq", CSState, irq, 9), DEFINE_PROP_UINT32 ("dma", CSState, dma, 3), diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 260c142b70..7589671d20 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -887,6 +887,11 @@ static int es1370_init (PCIBus *bus) return 0; } =20 +static Property es1370_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(ES1370State, card), + DEFINE_PROP_END_OF_LIST(), +}; + static void es1370_class_init (ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS (klass); @@ -903,6 +908,7 @@ static void es1370_class_init (ObjectClass *klass, void= *data) dc->desc =3D "ENSONIQ AudioPCI ES1370"; dc->vmsd =3D &vmstate_es1370; dc->reset =3D es1370_on_reset; + dc->props =3D es1370_properties; } =20 static const TypeInfo es1370_info =3D { @@ -923,4 +929,3 @@ static void es1370_register_types (void) } =20 type_init (es1370_register_types) - diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 9ab51631d9..566864bc9e 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -297,6 +297,7 @@ static int GUS_init (ISABus *bus) } =20 static Property gus_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(GUSState, card), DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100), DEFINE_PROP_UINT32 ("iobase", GUSState, port, 0x240), DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7), diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 84639b5424..967a10f189 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -840,6 +840,7 @@ static const VMStateDescription vmstate_hda_audio =3D { }; =20 static Property hda_audio_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(HDAAudioState, card), DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0), DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true), DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer, true), diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index bf6a5a6b96..4835229326 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -329,6 +329,11 @@ static const VMStateDescription vmstate_milkymist_ac97= =3D { } }; =20 +static Property milkymist_ac97_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(MilkymistAC97State, card), + DEFINE_PROP_END_OF_LIST(), +}; + static void milkymist_ac97_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -336,6 +341,7 @@ static void milkymist_ac97_class_init(ObjectClass *klas= s, void *data) dc->realize =3D milkymist_ac97_realize; dc->reset =3D milkymist_ac97_reset; dc->vmsd =3D &vmstate_milkymist_ac97; + dc->props =3D milkymist_ac97_properties; } =20 static const TypeInfo milkymist_ac97_info =3D { diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index a7b3ab0c2b..01127304c2 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -209,6 +209,7 @@ static const VMStateDescription vmstate_spk =3D { }; =20 static Property pcspk_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(PCSpkState, card), DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1), DEFINE_PROP_BOOL("migrate", PCSpkState, migrate, true), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/audio/pl041.c b/hw/audio/pl041.c index 59c6ce1f2e..ce430a7821 100644 --- a/hw/audio/pl041.c +++ b/hw/audio/pl041.c @@ -622,6 +622,7 @@ static const VMStateDescription vmstate_pl041 =3D { }; =20 static Property pl041_device_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(PL041State, codec.card), /* Non-compact FIFO depth property */ DEFINE_PROP_UINT32("nc_fifo_depth", PL041State, fifo_depth, DEFAULT_FIFO_DEPTH), diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index a2db06a2bb..6b604979cf 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1421,6 +1421,7 @@ static int SB16_init (ISABus *bus) } =20 static Property sb16_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(SB16State, card), DEFINE_PROP_UINT32 ("version", SB16State, ver, 0x0405), /* 4.5 */ DEFINE_PROP_UINT32 ("iobase", SB16State, port, 0x220), DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5), diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index 81f83eea88..dfb4156ff4 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -701,6 +701,11 @@ void wm8750_set_bclk_in(void *opaque, int new_hz) wm8750_clk_update(s, 1); } =20 +static Property wm8750_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(WM8750State, card), + DEFINE_PROP_END_OF_LIST(), +}; + static void wm8750_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -711,6 +716,7 @@ static void wm8750_class_init(ObjectClass *klass, void = *data) sc->recv =3D wm8750_rx; sc->send =3D wm8750_tx; dc->vmsd =3D &vmstate_wm8750; + dc->props =3D wm8750_properties; } =20 static const TypeInfo wm8750_info =3D { diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index ba412dd2ca..bf9974370c 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -11,6 +11,7 @@ */ =20 #include "qemu/osdep.h" +#include "audio/audio.h" #include "net/net.h" #include "hw/qdev.h" #include "qapi/error.h" @@ -353,6 +354,62 @@ const PropertyInfo qdev_prop_netdev =3D { }; =20 =20 +/* --- audiodev --- */ +static void get_audiodev(Object *obj, Visitor *v, const char* name, + void *opaque, Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + QEMUSoundCard *card =3D qdev_get_prop_ptr(dev, prop); + char *p =3D g_strdup(audio_get_id(card)); + + visit_type_str(v, name, &p, errp); + g_free(p); +} + +static void set_audiodev(Object *obj, Visitor *v, const char* name, + void *opaque, Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + QEMUSoundCard *card =3D qdev_get_prop_ptr(dev, prop); + AudioState *state; + Error *local_err =3D NULL; + int err =3D 0; + char *str; + + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + + visit_type_str(v, name, &str, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + state =3D audio_state_by_name(str); + + if (!state) { + err =3D -ENOENT; + goto out; + } + card->state =3D state; + +out: + error_set_from_qdev_prop_error(errp, err, dev, prop, str); + g_free(str); +} + +const PropertyInfo qdev_prop_audiodev =3D { + .name =3D "str", + .description =3D "ID of an audiodev to use as a backend", + /* release done on shutdown */ + .get =3D get_audiodev, + .set =3D set_audiodev, +}; + void qdev_prop_set_drive(DeviceState *dev, const char *name, BlockBackend *value, Error **errp) { diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 718ab53cbb..1b1cf91132 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -666,6 +666,7 @@ static const VMStateDescription vmstate_usb_audio =3D { }; =20 static Property usb_audio_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(USBAudioState, card), DEFINE_PROP_UINT32("debug", USBAudioState, debug, 0), DEFINE_PROP_UINT32("buffer", USBAudioState, buffer, 32 * USBAUDIO_PACKET_SIZE), --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563224982; cv=none; d=zoho.com; s=zohoarc; b=e4YHwmQZSrXrBHcgxP5IfBQGxEhVVr8QPL5OkBroseEEa7ZutJN/+YlH/R9BuyZCT0jaXDyJF3nd49LnFSvj8wPXmGiPqxNEeZBpkGSZqvoYE6T30cfwOnSNmvFhv8gkkQEiTMyydxekAnb2+FjQgFC8Cbhv6WJ/Kk7x+Z1QBmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563224982; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7EZH5IfkX2pnYWoHFzvFapZGwW2NZseYkfCZKLdSXEg=; b=jqjwn8EYV7G8xcZdn7hoZUhI55mfKJ7dgFXr6xYO4/1rSNslUuBdpSqIgXdaZvRLypsiiSuVrisjxf8DqAvRIM18xlg85yzY6sD5XQc/gHng7wFpufcyIv0lRRl7RI2oXi3KhLpDoSUErARZy6spvAI3Xd/sAHE9Mcs6RPK9fQM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563224982601729.9803140567532; Mon, 15 Jul 2019 14:09:42 -0700 (PDT) Received: from localhost ([::1]:43802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8E5-0003r9-LW for importer@patchew.org; Mon, 15 Jul 2019 17:09:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42241) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Cw-00082d-K9 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cu-0004jK-DF for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:26 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cu-0004ip-3b for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:24 -0400 Received: by mail-wr1-x442.google.com with SMTP id c2so15388944wrm.8 for ; Mon, 15 Jul 2019 14:08:24 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7EZH5IfkX2pnYWoHFzvFapZGwW2NZseYkfCZKLdSXEg=; b=uek/ckS1815Tgia1joCvU/MANyISkqWVpOMaobkklqwDn75y57zn2GAq46JZu9pQtV ZUCKdZHrs8j/HBImt9yvUabMyRW8tcbX9KDN/ZPdpwCT8ILcMD/hbVz/bHw2lWWm1oNV tGsrVFejKOAuoGMjo5o5dkJfxsq7tF3RdNxiThvo0KnI1/2aFiGVoAAeRHV1VHGgHUi9 08EgfqZBeUOn+kR8733PXPDrlBcNfgAH8TfJg2A5DDK7wotFpF4zkJQUgW/0aCwQwjaj +zELpOyt3BXO7coxY3PjIdWVJ0OeUypyZXatozcNLXbXvoKHtLcmc+XgfOIdrI3MMi06 P+sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7EZH5IfkX2pnYWoHFzvFapZGwW2NZseYkfCZKLdSXEg=; b=KSsGFI59SZQUEHKToBE6mjfcEkkQ1R+Ij0gQ/0vebMYkmxtAGFtriXwyEEEOqgb0K4 v9n/rKYuNzwDYNrryx5Jf3yb5K7+G/HsffYSKmN13XIcYs+h/NuQh+nAy9WF536Qfg6Z GFlN4904EH3mQH+k18BB/AFmhRG4R9HI+4EPpWSZtd9+/EMFKfCAW1v+ojMFNdCr1iZE tXP+0ibm5iOzqu+ck99y2fUkXnF8u613P/YwbaNFXTFlV8Gu8Fn3ogRBILmj66XghvOZ cuFHuZVwxnC8x8fSUJHRtFVv332bC2sXk/dW4HNorStbqs3PLz5NuyerjbLMVoiAMOpd DhzQ== X-Gm-Message-State: APjAAAXqIVxOp018lqFEvQpFf0pA/AsHXe5LhHR/2gb60nfceqpGOnlL tm2m6E/Lu/xCPfX17Zz5FYZf6/ql X-Google-Smtp-Source: APXvYqyVsyL5diTLsX6vCvGYx86ih6SdWpX1y3ooug3IdzmKLnCQm2UzdT/BBfkqFHYRscPCetioSg== X-Received: by 2002:a5d:528d:: with SMTP id c13mr30293702wrv.247.1563224902782; Mon, 15 Jul 2019 14:08:22 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:07 +0200 Message-Id: <548bbfbc250beeec922ab1abdeda56b8ef18a247.1563224628.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v2 05/14] paaudio: prepare for multiple audiodev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Have a pool of refcounted connections per server, so if the user creates multiple audiodevs to the same pa server, it will use a single connection. = (It will still create different streams, so the user can manage those streams separately in pulseaudio.) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/paaudio.c | 329 +++++++++++++++++++++++++++--------------------- 1 file changed, 188 insertions(+), 141 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 5fc886bb33..cc3a34c2ea 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -11,10 +11,21 @@ #include "audio_int.h" #include "audio_pt_int.h" =20 -typedef struct { - Audiodev *dev; +typedef struct PAConnection { + char *server; + int refcount; + QTAILQ_ENTRY(PAConnection) list; + pa_threaded_mainloop *mainloop; pa_context *context; +} PAConnection; + +static QTAILQ_HEAD(PAConnectionHead, PAConnection) pa_conns =3D + QTAILQ_HEAD_INITIALIZER(pa_conns); + +typedef struct { + Audiodev *dev; + PAConnection *conn; } paaudio; =20 typedef struct { @@ -45,7 +56,7 @@ typedef struct { int samples; } PAVoiceIn; =20 -static void qpa_audio_fini(void *opaque); +static void qpa_conn_fini(PAConnection *c); =20 static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...) { @@ -108,11 +119,11 @@ static inline int PA_STREAM_IS_GOOD(pa_stream_state_t= x) =20 static int qpa_simple_read (PAVoiceIn *p, void *data, size_t length, int *= rerror) { - paaudio *g =3D p->g; + PAConnection *c =3D p->g->conn; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); =20 while (length > 0) { size_t l; @@ -121,11 +132,11 @@ static int qpa_simple_read (PAVoiceIn *p, void *data,= size_t length, int *rerror int r; =20 r =3D pa_stream_peek (p->stream, &p->read_data, &p->read_lengt= h); - CHECK_SUCCESS_GOTO (g, rerror, r =3D=3D 0, unlock_and_fail); + CHECK_SUCCESS_GOTO(c, rerror, r =3D=3D 0, unlock_and_fail); =20 if (!p->read_data) { - pa_threaded_mainloop_wait (g->mainloop); - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + pa_threaded_mainloop_wait(c->mainloop); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); } else { p->read_index =3D 0; } @@ -148,53 +159,53 @@ static int qpa_simple_read (PAVoiceIn *p, void *data,= size_t length, int *rerror p->read_length =3D 0; p->read_index =3D 0; =20 - CHECK_SUCCESS_GOTO (g, rerror, r =3D=3D 0, unlock_and_fail); + CHECK_SUCCESS_GOTO(c, rerror, r =3D=3D 0, unlock_and_fail); } } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return 0; =20 unlock_and_fail: - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return -1; } =20 static int qpa_simple_write (PAVoiceOut *p, const void *data, size_t lengt= h, int *rerror) { - paaudio *g =3D p->g; + PAConnection *c =3D p->g->conn; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); =20 while (length > 0) { size_t l; int r; =20 while (!(l =3D pa_stream_writable_size (p->stream))) { - pa_threaded_mainloop_wait (g->mainloop); - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + pa_threaded_mainloop_wait(c->mainloop); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); } =20 - CHECK_SUCCESS_GOTO (g, rerror, l !=3D (size_t) -1, unlock_and_fail= ); + CHECK_SUCCESS_GOTO(c, rerror, l !=3D (size_t) -1, unlock_and_fail); =20 if (l > length) { l =3D length; } =20 r =3D pa_stream_write (p->stream, data, l, NULL, 0LL, PA_SEEK_RELA= TIVE); - CHECK_SUCCESS_GOTO (g, rerror, r >=3D 0, unlock_and_fail); + CHECK_SUCCESS_GOTO(c, rerror, r >=3D 0, unlock_and_fail); =20 data =3D (const uint8_t *) data + l; length -=3D l; } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return 0; =20 unlock_and_fail: - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return -1; } =20 @@ -432,13 +443,13 @@ static AudioFormat pa_to_audfmt (pa_sample_format_t f= mt, int *endianness) =20 static void context_state_cb (pa_context *c, void *userdata) { - paaudio *g =3D userdata; + PAConnection *conn =3D userdata; =20 switch (pa_context_get_state(c)) { case PA_CONTEXT_READY: case PA_CONTEXT_TERMINATED: case PA_CONTEXT_FAILED: - pa_threaded_mainloop_signal (g->mainloop, 0); + pa_threaded_mainloop_signal(conn->mainloop, 0); break; =20 case PA_CONTEXT_UNCONNECTED: @@ -451,14 +462,14 @@ static void context_state_cb (pa_context *c, void *us= erdata) =20 static void stream_state_cb (pa_stream *s, void * userdata) { - paaudio *g =3D userdata; + PAConnection *c =3D userdata; =20 switch (pa_stream_get_state (s)) { =20 case PA_STREAM_READY: case PA_STREAM_FAILED: case PA_STREAM_TERMINATED: - pa_threaded_mainloop_signal (g->mainloop, 0); + pa_threaded_mainloop_signal(c->mainloop, 0); break; =20 case PA_STREAM_UNCONNECTED: @@ -469,13 +480,13 @@ static void stream_state_cb (pa_stream *s, void * use= rdata) =20 static void stream_request_cb (pa_stream *s, size_t length, void *userdata) { - paaudio *g =3D userdata; + PAConnection *c =3D userdata; =20 - pa_threaded_mainloop_signal (g->mainloop, 0); + pa_threaded_mainloop_signal(c->mainloop, 0); } =20 static pa_stream *qpa_simple_new ( - paaudio *g, + PAConnection *c, const char *name, pa_stream_direction_t dir, const char *dev, @@ -486,50 +497,48 @@ static pa_stream *qpa_simple_new ( { int r; pa_stream *stream; + pa_stream_flags_t flags; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - stream =3D pa_stream_new (g->context, name, ss, map); + stream =3D pa_stream_new(c->context, name, ss, map); if (!stream) { goto fail; } =20 - pa_stream_set_state_callback (stream, stream_state_cb, g); - pa_stream_set_read_callback (stream, stream_request_cb, g); - pa_stream_set_write_callback (stream, stream_request_cb, g); + pa_stream_set_state_callback(stream, stream_state_cb, c); + pa_stream_set_read_callback(stream, stream_request_cb, c); + pa_stream_set_write_callback(stream, stream_request_cb, c); + + flags =3D + PA_STREAM_INTERPOLATE_TIMING +#ifdef PA_STREAM_ADJUST_LATENCY + | PA_STREAM_ADJUST_LATENCY +#endif + | PA_STREAM_AUTO_TIMING_UPDATE; =20 if (dir =3D=3D PA_STREAM_PLAYBACK) { - r =3D pa_stream_connect_playback (stream, dev, attr, - PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY - |PA_STREAM_ADJUST_LATENCY -#endif - |PA_STREAM_AUTO_TIMING_UPDATE, NUL= L, NULL); + r =3D pa_stream_connect_playback(stream, dev, attr, flags, NULL, N= ULL); } else { - r =3D pa_stream_connect_record (stream, dev, attr, - PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY - |PA_STREAM_ADJUST_LATENCY -#endif - |PA_STREAM_AUTO_TIMING_UPDATE); + r =3D pa_stream_connect_record(stream, dev, attr, flags); } =20 if (r < 0) { goto fail; } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); =20 return stream; =20 fail: - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); =20 if (stream) { pa_stream_unref (stream); } =20 - *rerror =3D pa_context_errno (g->context); + *rerror =3D pa_context_errno(c->context); =20 return NULL; } @@ -545,6 +554,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, paaudio *g =3D pa->g =3D drv_opaque; AudiodevPaOptions *popts =3D &g->dev->u.pa; AudiodevPaPerDirectionOptions *ppdo =3D popts->out; + PAConnection *c =3D g->conn; =20 ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; @@ -558,7 +568,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.endianness); =20 pa->stream =3D qpa_simple_new ( - g, + c, "qemu", PA_STREAM_PLAYBACK, ppdo->has_name ? ppdo->name : NULL, @@ -612,6 +622,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) paaudio *g =3D pa->g =3D drv_opaque; AudiodevPaOptions *popts =3D &g->dev->u.pa; AudiodevPaPerDirectionOptions *ppdo =3D popts->in; + PAConnection *c =3D g->conn; =20 ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; @@ -625,7 +636,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.endianness); =20 pa->stream =3D qpa_simple_new ( - g, + c, "qemu", PA_STREAM_RECORD, ppdo->has_name ? ppdo->name : NULL, @@ -714,7 +725,7 @@ static int qpa_ctl_out (HWVoiceOut *hw, int cmd, ...) PAVoiceOut *pa =3D (PAVoiceOut *) hw; pa_operation *op; pa_cvolume v; - paaudio *g =3D pa->g; + PAConnection *c =3D pa->g->conn; =20 #ifdef PA_CHECK_VERSION /* macro is present in 0.9.16+ */ pa_cvolume_init (&v); /* function is present in 0.9.13+ */ @@ -734,28 +745,29 @@ static int qpa_ctl_out (HWVoiceOut *hw, int cmd, ...) v.values[0] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= l) / UINT32_MAX; v.values[1] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= r) / UINT32_MAX; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - op =3D pa_context_set_sink_input_volume (g->context, + op =3D pa_context_set_sink_input_volume(c->context, pa_stream_get_index (pa->stream), &v, NULL, NULL); - if (!op) - qpa_logerr (pa_context_errno (g->context), - "set_sink_input_volume() failed\n"); - else - pa_operation_unref (op); + if (!op) { + qpa_logerr(pa_context_errno(c->context), + "set_sink_input_volume() failed\n"); + } else { + pa_operation_unref(op); + } =20 - op =3D pa_context_set_sink_input_mute (g->context, + op =3D pa_context_set_sink_input_mute(c->context, pa_stream_get_index (pa->stream), sw->vol.mute, NULL, NULL); if (!op) { - qpa_logerr (pa_context_errno (g->context), - "set_sink_input_mute() failed\n"); + qpa_logerr(pa_context_errno(c->context), + "set_sink_input_mute() failed\n"); } else { - pa_operation_unref (op); + pa_operation_unref(op); } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); } } return 0; @@ -766,7 +778,7 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...) PAVoiceIn *pa =3D (PAVoiceIn *) hw; pa_operation *op; pa_cvolume v; - paaudio *g =3D pa->g; + PAConnection *c =3D pa->g->conn; =20 #ifdef PA_CHECK_VERSION pa_cvolume_init (&v); @@ -786,29 +798,29 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...) v.values[0] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= l) / UINT32_MAX; v.values[1] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= r) / UINT32_MAX; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - op =3D pa_context_set_source_output_volume (g->context, - pa_stream_get_index (pa->stream), + op =3D pa_context_set_source_output_volume(c->context, + pa_stream_get_index(pa->stream), &v, NULL, NULL); if (!op) { - qpa_logerr (pa_context_errno (g->context), - "set_source_output_volume() failed\n"); + qpa_logerr(pa_context_errno(c->context), + "set_source_output_volume() failed\n"); } else { pa_operation_unref(op); } =20 - op =3D pa_context_set_source_output_mute (g->context, + op =3D pa_context_set_source_output_mute(c->context, pa_stream_get_index (pa->stream), sw->vol.mute, NULL, NULL); if (!op) { - qpa_logerr (pa_context_errno (g->context), - "set_source_output_mute() failed\n"); + qpa_logerr(pa_context_errno(c->context), + "set_source_output_mute() failed\n"); } else { pa_operation_unref (op); } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); } } return 0; @@ -828,11 +840,75 @@ static int qpa_validate_per_direction_opts(Audiodev *= dev, return 1; } =20 +/* common */ +static void *qpa_conn_init(const char *server) +{ + PAConnection *c =3D g_malloc0(sizeof(PAConnection)); + QTAILQ_INSERT_TAIL(&pa_conns, c, list); + + c->mainloop =3D pa_threaded_mainloop_new(); + if (!c->mainloop) { + goto fail; + } + + c->context =3D pa_context_new(pa_threaded_mainloop_get_api(c->mainloop= ), + server); + if (!c->context) { + goto fail; + } + + pa_context_set_state_callback(c->context, context_state_cb, c); + + if (pa_context_connect(c->context, server, 0, NULL) < 0) { + qpa_logerr(pa_context_errno(c->context), + "pa_context_connect() failed\n"); + goto fail; + } + + pa_threaded_mainloop_lock(c->mainloop); + + if (pa_threaded_mainloop_start(c->mainloop) < 0) { + goto unlock_and_fail; + } + + for (;;) { + pa_context_state_t state; + + state =3D pa_context_get_state(c->context); + + if (state =3D=3D PA_CONTEXT_READY) { + break; + } + + if (!PA_CONTEXT_IS_GOOD(state)) { + qpa_logerr(pa_context_errno(c->context), + "Wrong context state\n"); + goto unlock_and_fail; + } + + /* Wait until the context is ready */ + pa_threaded_mainloop_wait(c->mainloop); + } + + pa_threaded_mainloop_unlock(c->mainloop); + return c; + +unlock_and_fail: + pa_threaded_mainloop_unlock(c->mainloop); +fail: + AUD_log (AUDIO_CAP, "Failed to initialize PA context"); + qpa_conn_fini(c); + return NULL; +} + static void *qpa_audio_init(Audiodev *dev) { paaudio *g; AudiodevPaOptions *popts =3D &dev->u.pa; const char *server; + PAConnection *c; + + assert(dev->driver =3D=3D AUDIODEV_DRIVER_PA); =20 if (!popts->has_server) { char pidfile[64]; @@ -849,93 +925,64 @@ static void *qpa_audio_init(Audiodev *dev) } } =20 - assert(dev->driver =3D=3D AUDIODEV_DRIVER_PA); - - g =3D g_malloc(sizeof(paaudio)); - server =3D popts->has_server ? popts->server : NULL; - if (!qpa_validate_per_direction_opts(dev, popts->in)) { - goto fail; + return NULL; } if (!qpa_validate_per_direction_opts(dev, popts->out)) { - goto fail; + return NULL; } =20 + g =3D g_malloc0(sizeof(paaudio)); + server =3D popts->has_server ? popts->server : NULL; + g->dev =3D dev; - g->mainloop =3D NULL; - g->context =3D NULL; =20 - g->mainloop =3D pa_threaded_mainloop_new (); - if (!g->mainloop) { - goto fail; - } - - g->context =3D pa_context_new (pa_threaded_mainloop_get_api (g->mainlo= op), - server); - if (!g->context) { - goto fail; - } - - pa_context_set_state_callback (g->context, context_state_cb, g); - - if (pa_context_connect(g->context, server, 0, NULL) < 0) { - qpa_logerr (pa_context_errno (g->context), - "pa_context_connect() failed\n"); - goto fail; - } - - pa_threaded_mainloop_lock (g->mainloop); - - if (pa_threaded_mainloop_start (g->mainloop) < 0) { - goto unlock_and_fail; - } - - for (;;) { - pa_context_state_t state; - - state =3D pa_context_get_state (g->context); - - if (state =3D=3D PA_CONTEXT_READY) { + QTAILQ_FOREACH(c, &pa_conns, list) { + if (server =3D=3D NULL || c->server =3D=3D NULL ? + server =3D=3D c->server : + strcmp(server, c->server) =3D=3D 0) { + g->conn =3D c; break; } - - if (!PA_CONTEXT_IS_GOOD (state)) { - qpa_logerr (pa_context_errno (g->context), - "Wrong context state\n"); - goto unlock_and_fail; - } - - /* Wait until the context is ready */ - pa_threaded_mainloop_wait (g->mainloop); + } + if (!g->conn) { + g->conn =3D qpa_conn_init(server); + } + if (!g->conn) { + g_free(g); + return NULL; } =20 - pa_threaded_mainloop_unlock (g->mainloop); - + ++g->conn->refcount; return g; +} =20 -unlock_and_fail: - pa_threaded_mainloop_unlock (g->mainloop); -fail: - AUD_log (AUDIO_CAP, "Failed to initialize PA context"); - qpa_audio_fini(g); - return NULL; +static void qpa_conn_fini(PAConnection *c) +{ + if (c->mainloop) { + pa_threaded_mainloop_stop(c->mainloop); + } + + if (c->context) { + pa_context_disconnect(c->context); + pa_context_unref(c->context); + } + + if (c->mainloop) { + pa_threaded_mainloop_free(c->mainloop); + } + + QTAILQ_REMOVE(&pa_conns, c, list); + g_free(c); } =20 static void qpa_audio_fini (void *opaque) { paaudio *g =3D opaque; + PAConnection *c =3D g->conn; =20 - if (g->mainloop) { - pa_threaded_mainloop_stop (g->mainloop); - } - - if (g->context) { - pa_context_disconnect (g->context); - pa_context_unref (g->context); - } - - if (g->mainloop) { - pa_threaded_mainloop_free (g->mainloop); + if (--c->refcount =3D=3D 0) { + qpa_conn_fini(c); } =20 g_free(g); --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225025; cv=none; d=zoho.com; s=zohoarc; b=iF32UUZAGYznrIiN4My5LoKSwdpCezhB/uVtyDeHJ4lEwnZHb9LSbj5JHgeQSZCH7m9tEHq/ObxxKU8n9dRToAjhxkhWgzpA6bdOjj+wqdoKoPEpAJAphXpHU3HLz0sfimXBbL7dO32ZDzhBlWxhzqo55c32d7FUoh5dXdcHSxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225025; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PksipMVzAiiMTAlABLCmlNruZKZ2bg95M8Q+Ha0hlqQ=; b=ZrEGfXZrlupg7/iUMa4J4puGMuqHbBYJiPOoBvBXCBMSpJ7/+kPly8MY6J5LyTlS0V6A6mLgOWrWacjiTf4dY+uj5R4LTG7LzXa1OWd0L54kxRDCRx7X0nOY+X+Rjbjm62BvCSwKGKEyPV0oRPiImSJbHAmn8gCk0wCqvzXfM1s= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156322502533222.61132097447978; Mon, 15 Jul 2019 14:10:25 -0700 (PDT) Received: from localhost ([::1]:43828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Ep-0007MK-UT for importer@patchew.org; Mon, 15 Jul 2019 17:10:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42253) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Cx-00086R-Ej for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cv-0004jx-AV for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:27 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:52562) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cv-0004jH-3j for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:25 -0400 Received: by mail-wm1-x341.google.com with SMTP id s3so16558785wms.2 for ; Mon, 15 Jul 2019 14:08:25 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PksipMVzAiiMTAlABLCmlNruZKZ2bg95M8Q+Ha0hlqQ=; b=G5bFZKNhY9vNYOs2xPB+aVEMZvpUnswTKrN51d9DHyefk7viQkCb2nxqysyCX+nATh daBob80lswoa+g8Z1EhLkCzfWg/fCAU3Vk/S0k+l0AtyMhzs03HqK1ZlfZ2fsMtlQ3mE bh5WrPSknf0XVBiJtycYfS3V1fmUWihm8CCVujIOXus9CWU9UTGrv76y1psKP0X7zpJA 6cBCCVawjNMmHmv1sr94fv2WwkGyULvDBKm9UcvF93KsV+G9CRNer7d2R4DifXu/ehBV Q7Ef/sU61zqVI9I4Dks2HSpriJJ8Mn+n4OtqYK6jI18bY9DrixenAcPmBEKE8AfupD15 fmjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PksipMVzAiiMTAlABLCmlNruZKZ2bg95M8Q+Ha0hlqQ=; b=OuBlszEzBjUqz46tKE8kO6ZOByus7z4xYcvUt5MzstaFKD2XqK6+dGsel6X+wUFKOW Nir2Qvyx31WmagpAAbSKETxXVkV1rMrfFiu+R3mz83uaEGhGsgC9m6w/PL08W5P3/zBy A1nFukoFSdhiGJEN4ufY/4riGdjGPwmPDFL8b4ya6GGH6iu1vvTgqhAeoiJ0MO8ygGZ/ p38OU3tBtAfmworfaoCapdWtRmBaf/RJemiOjfwnQHTiF71+k3p3MGopI5jWrI9vpGKC SpXVYfX+gQ5/rRTnQLYe8EkOrr3P4Yw11xigEqvUjqvrxyXuUOrQGYQdqzRkPvj6+Qgk r5Yg== X-Gm-Message-State: APjAAAWE4d+hdocYmY7iv2wqcG2Ea9gB7CbsgTqJsGhsdJKqbOMiSWPv JjjDHQpgFc3CQCt1mhfcpSu0eYTh X-Google-Smtp-Source: APXvYqwsAGBInWetcdh5UZ0Sz/lcEFWwVg7j2nSVabiv40I7RbTm8O/qq6iygWG04n09pckGeSDe1A== X-Received: by 2002:a1c:cb43:: with SMTP id b64mr26681580wmg.86.1563224903735; Mon, 15 Jul 2019 14:08:23 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:08 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v2 06/14] audio: audiodev= parameters no longer optional when -audiodev present X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This means you should probably stop using -soundhw (as it doesn't allow you to specify any options) and add the device manually with -device. The exception is pcspk, it's currently not possible to manually add it. To use it with audiodev, use something like this: -audiodev id=3Dfoo,... -global isa-pcspk.audiodev=3Dfoo -soundhw pcspk Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- Notes: Changes from v1: =20 * Split off paaudio changes to a different commit. audio/audio.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 4baa37caac..d131958194 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -101,6 +101,8 @@ const struct mixeng_volume nominal_volume =3D { #endif }; =20 +static bool legacy_config =3D true; + #ifdef AUDIO_IS_FLAWLESS_AND_NO_CHECKS_ARE_REQURIED #error No its not #else @@ -1392,7 +1394,7 @@ static AudiodevListEntry *audiodev_find( * if dev =3D=3D NULL =3D> legacy implicit initialization, return the alre= ady created * state or create a new one */ -static AudioState *audio_init(Audiodev *dev) +static AudioState *audio_init(Audiodev *dev, const char *name) { static bool atexit_registered; size_t i; @@ -1406,12 +1408,13 @@ static AudioState *audio_init(Audiodev *dev) =20 if (dev) { /* -audiodev option */ + legacy_config =3D false; drvname =3D AudiodevDriver_str(dev->driver); } else if (!QTAILQ_EMPTY(&audio_states)) { - /* - * todo: check for -audiodev once we have normal audiodev selection - * support - */ + if (!legacy_config) { + dolog("You must specify an audiodev=3D for the device %s\n", n= ame); + exit(1); + } return QTAILQ_FIRST(&audio_states); } else { /* legacy implicit initialization */ @@ -1518,7 +1521,7 @@ void audio_free_audiodev_list(AudiodevListHead *head) void AUD_register_card (const char *name, QEMUSoundCard *card) { if (!card->state) { - card->state =3D audio_init(NULL); + card->state =3D audio_init(NULL, name); } =20 card->name =3D g_strdup (name); @@ -1544,8 +1547,11 @@ CaptureVoiceOut *AUD_add_capture( struct capture_callback *cb; =20 if (!s) { - /* todo: remove when we have normal audiodev selection support */ - s =3D audio_init(NULL); + if (!legacy_config) { + dolog("You must specify audiodev when trying to capture\n"); + return NULL; + } + s =3D audio_init(NULL, NULL); } =20 if (audio_validate_settings (as)) { @@ -1776,7 +1782,7 @@ void audio_init_audiodevs(void) AudiodevListEntry *e; =20 QSIMPLEQ_FOREACH(e, &audiodevs, next) { - audio_init(e->dev); + audio_init(e->dev, NULL); } } =20 --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225032; cv=none; d=zoho.com; s=zohoarc; b=jyHPJcV8K8zBVKB16JptJDQqKs8zSsxM/dUsgFhoxUKDniOliRwYTG3nFcArjv9M6rHpqQSd0OyHZRyCeo8pvG2Lrf4oMb+UzYFLrljri3wtcPoGfLD8XQVUUC92Pij5BgU+8vqb/XsvPx0svwcxtiBx0VT8SpK5M7+gZVvdLwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225032; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SQdS/4gPbCHrpQ6QHLwZkQ1izi38pwhpM703vz5qgTE=; b=JC5T0LmHttab4zM+hBSRFHSgEaai+QBUyvW4s0Wxk01w99dCVNIdH6U6T1xQVz87qxGGqbCEPYQfq6pGyox8lCdu4/gJr4eI1Rhcg7B3OmUGmkK+6t2D8ecUJeLYMtqfTmPfVucAXlWqiFx/84SUb2NCBonqIzH21iFUVN0tJa8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15632250326186.698320695639836; Mon, 15 Jul 2019 14:10:32 -0700 (PDT) Received: from localhost ([::1]:43832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Ex-0007sH-73 for importer@patchew.org; Mon, 15 Jul 2019 17:10:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42246) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Cw-00084C-SQ for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cv-0004kO-V7 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:26 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38833) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cv-0004jl-Or for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:25 -0400 Received: by mail-wr1-x444.google.com with SMTP id g17so18585716wrr.5 for ; Mon, 15 Jul 2019 14:08:25 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SQdS/4gPbCHrpQ6QHLwZkQ1izi38pwhpM703vz5qgTE=; b=NeeklbMOPknojBBnqgNy+O5xmyEnrAy8xqqEN1N4c2U/XHg7aHw7we7U7ZXLN+gu3J 1mvw0qifjaiolVJaYcqwP/tVQhuqfoOb9MFqtQA+G/B+7RJTKXboVGu2/v5H87lCxBHt ZLtLXM3YopjpMrf0g+NgVj9GZbT4IvriUVM1QIpZOOFCG1dzyjrdeT5rY14QXjD1nZgj BP6EJNtfpSLbU74AaQKTpNHA/4plhAPhyM1Xj39SeZcVeSWgvJNj+qq9CnvyY6MudD5Y a5x+UcVwB5I7m70eB34ju5Xiz4KKMM8yUxlcK8XeKrbHUCfiR5MMXmvv3J0ei0mXXCOQ GVLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SQdS/4gPbCHrpQ6QHLwZkQ1izi38pwhpM703vz5qgTE=; b=uVmpfUXr+bx+E9/LzIiVhqCBlUXWUIQYPjhfE0q4kCV+KqPDr/PpsQ4w+Erd/WOtOu HdjRICoIsggAXmu/3RPTP0QQNQJvPKNaE7OMDy/US65nmxkiMaEsoGUkbHMzmvIiF7up 4VLnuNa+S95rjLn6qYeD60NdxnPDGHRCdPlfqJE/d8nPCPu/3IGiRH1qeTOPJ+mxN5BL wVTt+mrGXwCudVNW+whbo9DyR/bAPgS6QWQR0aFUQJ0QUdTPhCZA3bX3eFdPtPE3d1gJ Mw0p7MobQSkc9AxvibR+BdlDJjvLO6SvY29nqr/yD+tuHDFZI0ybxvdTcWz/tmgmlnZr peDQ== X-Gm-Message-State: APjAAAUlMT+IfyQM9ltGuPqfUOgcqLKlSsYMxuIEPpnqldGrCH15ssIV ICzydJXDAsT8ePTwpvpLU2StyEZG X-Google-Smtp-Source: APXvYqxV3HKQ+7L5f/MQTywQ5q6tI+uolGSV7P7XBJnvGgIjhT6fnmAS8nXLVbtSiJ+P5D20rXWkdQ== X-Received: by 2002:a5d:618d:: with SMTP id j13mr30468323wru.195.1563224904680; Mon, 15 Jul 2019 14:08:24 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:09 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v2 07/14] paaudio: do not move stream when sink/source name is specified X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Unless we disable stream moving, pulseaudio can easily move the stream on connect, effectively ignoring the source/sink specified by the user. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/paaudio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index cc3a34c2ea..24d98b344a 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -517,6 +517,11 @@ static pa_stream *qpa_simple_new ( #endif | PA_STREAM_AUTO_TIMING_UPDATE; =20 + if (dev) { + /* don't move the stream if the user specified a sink/source */ + flags |=3D PA_STREAM_DONT_MOVE; + } + if (dir =3D=3D PA_STREAM_PLAYBACK) { r =3D pa_stream_connect_playback(stream, dev, attr, flags, NULL, N= ULL); } else { --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225070; cv=none; d=zoho.com; s=zohoarc; b=VzBTdvyjN8GvYH9kuR+eO0HGZ2LwxlaBIwqpflOi2l+uauz0ysPeOGb6B1HL5PsJsEEd5QQeu0B4jVjpjkWSpCAooJM45yR8adOOvi0eaIpEDq+azNO6ETrTR+jHEA2YW4qe24zPJwzGISUTLL6cnZyfUM7bf9nWI5ncoXzqfyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225070; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rslzC2c2WDwNlJOxHo//ed6lLff8LJfI6lnQMj5SLIg=; b=W8Yy20NMtTdxjcGHQ81qbUgjXuZYwOZbUrAo8qhvVIExgjjurgVuT3JQsSG8RaGrRvHcatw8lk32qWMA33peZ4IDWoNCHJQUvwk4hqaoctYQcXjgYYl+zPDUMRuXTegy5VImTjawyEQUqe268UnLUcWZM3p/Xs+seuoBjVCOMj4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563225070889678.5762063396887; Mon, 15 Jul 2019 14:11:10 -0700 (PDT) Received: from localhost ([::1]:43854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8FZ-0002Qq-8D for importer@patchew.org; Mon, 15 Jul 2019 17:11:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42260) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Cx-000895-Um for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cw-0004kp-PL for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:27 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:53614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cw-0004kT-Iu for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:26 -0400 Received: by mail-wm1-x341.google.com with SMTP id x15so16554789wmj.3 for ; Mon, 15 Jul 2019 14:08:26 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rslzC2c2WDwNlJOxHo//ed6lLff8LJfI6lnQMj5SLIg=; b=gvZ2rAGwGYll66L2uA/1QnS11iJaBCA1qJo2e6uYzKPGd9S4ILkJDKaP0pMCSioonI F1Hd7Z8eLaHJgQPLg4f5FRIkTfJS4nl4kw1QKFRDDs9rPDcibxJmnJJbfhMts0A/ZPhp gqZBAmzTWTtMCA42th908CWCsv/mPVk4/5cw0zOOWFVvun0Z02gYth/v+EL1VTFDJsOs RVFha5twiN8cbhvl6uk8SXhqu/DxgNyyJpeAwiXRd71LNlNjjbQVNbFkQKVjNcVEJJtV Bx7fh/Gw2Q2xSi99wwwe6pZq2v8/pFr+93ag/ZYU/b73WMywAAw5LfY7ArksrNy/xpN5 ImtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rslzC2c2WDwNlJOxHo//ed6lLff8LJfI6lnQMj5SLIg=; b=d4TSwLQd2QuDo/nGqHDqGmiO9t3GyrjZPjlV7zXpL7X+ERj9Na9kb4ploxYQ1OvT0Q oH+g+h3Dpy7eLyj+bVhQZQTzaENW2KRVL8KndJBxfBQ+IovjcpMGRUvoLCEMVFB7zMDn GOvWITUaDYk/CjnTIONqZmtHKUjVQk3Frdowzv1UInrYSgtc8J5J7OZTS/YaLUn+6BtZ 4SE+dL5EIduFLd4MAUw5o+1OySFvzRPQ0V5Ne4TkPQRP7Phe4Ec4U/Ogv4Mj3heyZov9 ug8KqBX+B/1chr9gx5vvdFI1VZx+9qTzDdTVnkUN8OoD4INl4FSseAEZ37q0CVBjiL+f a41w== X-Gm-Message-State: APjAAAVwRD9CPik539crVzdLqraF+guZ8QhY6frgBFGOqKdqEUv/BOVp Tvd3ODyfS+d3bcm6oJPUHAcNGH9g X-Google-Smtp-Source: APXvYqyOJUlXNNtbK2wCK55UL6/Stg6cgrvIWf9da4mbsh/Ed0s2mNhLODx5DIW8lrwhiJCzrIUvnA== X-Received: by 2002:a1c:f61a:: with SMTP id w26mr27552781wmc.75.1563224905483; Mon, 15 Jul 2019 14:08:25 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:10 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v2 08/14] paaudio: properly disconnect streams in fini_* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Currently this needs a workaround due to bug #247 in pulseaudio. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/paaudio.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 24d98b344a..1d68173636 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -685,6 +685,27 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) return -1; } =20 +static void qpa_simple_disconnect(PAConnection *c, pa_stream *stream) +{ + int err; + + pa_threaded_mainloop_lock(c->mainloop); + /* + * wait until actually connects. workaround pa bug #247 + * https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/247 + */ + while (pa_stream_get_state(stream) =3D=3D PA_STREAM_CREATING) { + pa_threaded_mainloop_wait(c->mainloop); + } + + err =3D pa_stream_disconnect(stream); + if (err !=3D 0) { + dolog("Failed to disconnect! err=3D%d\n", err); + } + pa_stream_unref(stream); + pa_threaded_mainloop_unlock(c->mainloop); +} + static void qpa_fini_out (HWVoiceOut *hw) { void *ret; @@ -696,7 +717,7 @@ static void qpa_fini_out (HWVoiceOut *hw) audio_pt_join(&pa->pt, &ret, __func__); =20 if (pa->stream) { - pa_stream_unref (pa->stream); + qpa_simple_disconnect(pa->g->conn, pa->stream); pa->stream =3D NULL; } =20 @@ -716,7 +737,7 @@ static void qpa_fini_in (HWVoiceIn *hw) audio_pt_join(&pa->pt, &ret, __func__); =20 if (pa->stream) { - pa_stream_unref (pa->stream); + qpa_simple_disconnect(pa->g->conn, pa->stream); pa->stream =3D NULL; } =20 --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225074; cv=none; d=zoho.com; s=zohoarc; b=JkUtTUzU817CmV+iUjzOKOXckE3xdpW3QHMcoFPIHS6sLqA1njPWnT/Q7VDWcrv4KKvgiyn5ufvz0xODUejnCNqO2x6RMPh0dQf4TffCc/sq+72j0TFOMUAL1T8XQEfqvNFfixyoMoGUhSEKd7h5b2/XwXPrbyyLeFi/gQNXh0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225074; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ru3Fc2G+kcIWGOZ/7Fgkew5rnlD64ppzaeIJGRveV5c=; b=ol9O77H3yX06nT6wRDJNP5T3WpuRqPcGHHMQxMZCkXZGkAdRILkPQM2b6UFLorYNYOIc5cxjm6n3dXIA7zx2QbH+GjymW/nE56T36NO0UPcWRp6L3biUi9rPabKYD9RKDhyyPWzBH4YdW1ITR/KQ1b2DBuAF+KlwR+5RLxCY5zk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563225074301918.0927971315476; Mon, 15 Jul 2019 14:11:14 -0700 (PDT) Received: from localhost ([::1]:43856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Fc-0002ZW-TB for importer@patchew.org; Mon, 15 Jul 2019 17:11:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42314) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8D2-0008Rq-FQ for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cz-0004mf-Fs for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:32 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:43366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cy-0004lC-5q for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:29 -0400 Received: by mail-wr1-x432.google.com with SMTP id p13so18551976wru.10 for ; Mon, 15 Jul 2019 14:08:28 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ru3Fc2G+kcIWGOZ/7Fgkew5rnlD64ppzaeIJGRveV5c=; b=Tii21MtN6cRMSfoIrQ4hv5jwVkw4Mti11tXBxFJVkdOXuQ9RT+KH3MJ92eJOhIdBc5 kp11WzHt3JCusyUCwyJSzQ0C1b0i1aXtISIMrNoB4W/yoUxl5KPkNKDUPWPLVKnb1PUF xntLItYutRH3HzYiygdAKfhD9RHC0zdfDA/Ml79sPf9ZXa0mcVFS9N/atGZDlmBDNYum K2FCY5VInM9gMSnG/MuRbBJw9Gs3/nj9+88ow69SO9nDn8pzH5B/zBwyWjfeedOfJfnc D5E+wLB+1JLEQscc1JoL0EUsFVHseL0ZRpp/aNC5ezmS/NmFhtARHtH2483gdus/4eDH C+yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ru3Fc2G+kcIWGOZ/7Fgkew5rnlD64ppzaeIJGRveV5c=; b=YJTUqiju1uNIi30Fqj8/pI+x0W8LJREICEhNU3C13B0xEzI3J2wWfD3vSPtz7aRGCY TJX0+Es28NhW1aZGr3Ac9xuZ/cz4j6yxcM9p4K5I3g1VJgW+wOXDc3t2sWPpqOqOgSJ6 Wqz8H8lc8cAKS6MgEbrcBcWm8/2Avq27mkkBUn9gvq1OkhUugK4uKcwqRm2a9gtZXaON eYIPCE5cyjy0R/+nekh/woyggj3wovjfVcNh10xLSMQl8jj+i78izNb0XH5TpU1dZj78 eii7iK4BjSWH0RuJhPzkSFMDKF0qn7IkpSIEhl5qOJ1L8uf+wr56q3HfRzNLHLvzw7Q1 DlAA== X-Gm-Message-State: APjAAAXl6GKcjO/YQzGX5xAUBu41QfzWYdOpmsuxJjO+rCv2Y+NVTQOC SBGtMIbN+/VM+m27yc6ok7brFYJ//5k= X-Google-Smtp-Source: APXvYqx2JWzuVvJ7s9o465wWMMTmBuCp10wcRr10dD98GaYXMjhWAYz4mZLNM7I9aEg8Hj5EJNIspw== X-Received: by 2002:a5d:6783:: with SMTP id v3mr30734127wru.318.1563224906549; Mon, 15 Jul 2019 14:08:26 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:11 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [PATCH v2 09/14] audio: remove audio_MIN, audio_MAX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Walle , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) There's already a MIN and MAX macro in include/qemu/osdep.h, use them instead. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.h | 17 ----------------- audio/alsaaudio.c | 6 +++--- audio/audio.c | 20 ++++++++++---------- audio/coreaudio.c | 2 +- audio/dsoundaudio.c | 2 +- audio/noaudio.c | 10 +++++----- audio/ossaudio.c | 6 +++--- audio/paaudio.c | 12 ++++++------ audio/sdlaudio.c | 6 +++--- audio/spiceaudio.c | 10 +++++----- audio/wavaudio.c | 4 ++-- hw/audio/ac97.c | 10 +++++----- hw/audio/adlib.c | 4 ++-- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 16 ++++++++-------- hw/audio/milkymist-ac97.c | 8 ++++---- hw/audio/pcspk.c | 2 +- hw/audio/sb16.c | 2 +- hw/audio/wm8750.c | 4 ++-- 21 files changed, 70 insertions(+), 87 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index c0722a5cda..4a95758516 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -146,23 +146,6 @@ static inline void *advance (void *p, int incr) return (d + incr); } =20 -#ifdef __GNUC__ -#define audio_MIN(a, b) ( __extension__ ({ \ - __typeof (a) ta =3D a; \ - __typeof (b) tb =3D b; \ - ((ta)>(tb)?(tb):(ta)); \ -})) - -#define audio_MAX(a, b) ( __extension__ ({ \ - __typeof (a) ta =3D a; \ - __typeof (b) tb =3D b; \ - ((ta)<(tb)?(tb):(ta)); \ -})) -#else -#define audio_MIN(a, b) ((a)>(b)?(b):(a)) -#define audio_MAX(a, b) ((a)<(b)?(b):(a)) -#endif - int wav_start_capture(AudioState *state, CaptureState *s, const char *path, int freq, int bits, int nchannels); =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 3745c823ad..6b9e0f06af 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -634,7 +634,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) =20 while (alsa->pending) { int left_till_end_samples =3D hw->samples - alsa->wpos; - int len =3D audio_MIN (alsa->pending, left_till_end_samples); + int len =3D MIN (alsa->pending, left_till_end_samples); char *src =3D advance (alsa->pcm_buf, alsa->wpos << hw->info.shift= ); =20 while (len) { @@ -697,7 +697,7 @@ static int alsa_run_out (HWVoiceOut *hw, int live) return 0; } =20 - decr =3D audio_MIN (live, avail); + decr =3D MIN (live, avail); decr =3D audio_pcm_hw_clip_out (hw, alsa->pcm_buf, decr, alsa->pending= ); alsa->pending +=3D decr; alsa_write_pending (alsa); @@ -915,7 +915,7 @@ static int alsa_run_in (HWVoiceIn *hw) } } =20 - decr =3D audio_MIN (dead, avail); + decr =3D MIN (dead, avail); if (!decr) { return 0; } diff --git a/audio/audio.c b/audio/audio.c index d131958194..cb0222ab4a 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -533,7 +533,7 @@ static int audio_pcm_hw_find_min_in (HWVoiceIn *hw) =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active) { - m =3D audio_MIN (m, sw->total_hw_samples_acquired); + m =3D MIN (m, sw->total_hw_samples_acquired); } } return m; @@ -553,14 +553,14 @@ int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_= buf, int live, int pending) { int left =3D hw->samples - pending; - int len =3D audio_MIN (left, live); + int len =3D MIN (left, live); int clipped =3D 0; =20 while (len) { struct st_sample *src =3D hw->mix_buf + hw->rpos; uint8_t *dst =3D advance (pcm_buf, hw->rpos << hw->info.shift); int samples_till_end_of_buf =3D hw->samples - hw->rpos; - int samples_to_clip =3D audio_MIN (len, samples_till_end_of_buf); + int samples_to_clip =3D MIN (len, samples_till_end_of_buf); =20 hw->clip (dst, src, samples_to_clip); =20 @@ -614,7 +614,7 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int si= ze) } =20 swlim =3D (live * sw->ratio) >> 32; - swlim =3D audio_MIN (swlim, samples); + swlim =3D MIN (swlim, samples); =20 while (swlim) { src =3D hw->conv_buf + rpos; @@ -662,7 +662,7 @@ static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, i= nt *nb_livep) =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active || !sw->empty) { - m =3D audio_MIN (m, sw->total_hw_samples_mixed); + m =3D MIN (m, sw->total_hw_samples_mixed); nb_live +=3D 1; } } @@ -725,7 +725,7 @@ int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int = size) =20 dead =3D hwsamples - live; swlim =3D ((int64_t) dead << 32) / sw->ratio; - swlim =3D audio_MIN (swlim, samples); + swlim =3D MIN (swlim, samples); if (swlim) { sw->conv (sw->buf, buf, swlim); =20 @@ -737,7 +737,7 @@ int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int = size) while (swlim) { dead =3D hwsamples - live; left =3D hwsamples - wpos; - blck =3D audio_MIN (dead, left); + blck =3D MIN (dead, left); if (!blck) { break; } @@ -1029,7 +1029,7 @@ static void audio_capture_mix_and_clear (HWVoiceOut *= hw, int rpos, int samples) n =3D samples; while (n) { int till_end_of_hw =3D hw->samples - rpos2; - int to_write =3D audio_MIN (till_end_of_hw, n); + int to_write =3D MIN (till_end_of_hw, n); int bytes =3D to_write << hw->info.shift; int written; =20 @@ -1047,7 +1047,7 @@ static void audio_capture_mix_and_clear (HWVoiceOut *= hw, int rpos, int samples) } } =20 - n =3D audio_MIN (samples, hw->samples - rpos); + n =3D MIN (samples, hw->samples - rpos); mixeng_clear (hw->mix_buf + rpos, n); mixeng_clear (hw->mix_buf, samples - n); } @@ -1203,7 +1203,7 @@ static void audio_run_capture (AudioState *s) rpos =3D hw->rpos; while (live) { int left =3D hw->samples - rpos; - int to_capture =3D audio_MIN (live, left); + int to_capture =3D MIN (live, left); struct st_sample *src; struct capture_callback *cb; =20 diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 4bec6c8c5c..f0ab4014a8 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -413,7 +413,7 @@ static int coreaudio_run_out (HWVoiceOut *hw, int live) core->live); } =20 - decr =3D audio_MIN (core->decr, live); + decr =3D MIN (core->decr, live); core->decr -=3D decr; =20 core->live =3D live - decr; diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 5da4c864c3..07260f881e 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -707,7 +707,7 @@ static int dsound_run_in (HWVoiceIn *hw) if (!len) { return 0; } - len =3D audio_MIN (len, dead); + len =3D MIN (len, dead); =20 err =3D dsound_lock_in ( dscb, diff --git a/audio/noaudio.c b/audio/noaudio.c index 9b195dc52c..14a0e4ab29 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -52,11 +52,11 @@ static int no_run_out (HWVoiceOut *hw, int live) now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ticks =3D now - no->old_ticks; bytes =3D muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_S= ECOND); - bytes =3D audio_MIN(bytes, INT_MAX); + bytes =3D MIN(bytes, INT_MAX); samples =3D bytes >> hw->info.shift; =20 no->old_ticks =3D now; - decr =3D audio_MIN (live, samples); + decr =3D MIN (live, samples); hw->rpos =3D (hw->rpos + decr) % hw->samples; return decr; } @@ -111,9 +111,9 @@ static int no_run_in (HWVoiceIn *hw) muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SEC= OND); =20 no->old_ticks =3D now; - bytes =3D audio_MIN (bytes, INT_MAX); + bytes =3D MIN (bytes, INT_MAX); samples =3D bytes >> hw->info.shift; - samples =3D audio_MIN (samples, dead); + samples =3D MIN (samples, dead); } return samples; } @@ -124,7 +124,7 @@ static int no_read (SWVoiceIn *sw, void *buf, int size) * useless resampling/mixing */ int samples =3D size >> sw->info.shift; int total =3D sw->hw->total_samples_captured - sw->total_hw_samples_ac= quired; - int to_clear =3D audio_MIN (samples, total); + int to_clear =3D MIN (samples, total); sw->total_hw_samples_acquired +=3D total; audio_pcm_info_clear_buf (&sw->info, buf, to_clear); return to_clear << sw->info.shift; diff --git a/audio/ossaudio.c b/audio/ossaudio.c index c0af065b6f..29139ef1f5 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -388,7 +388,7 @@ static void oss_write_pending (OSSVoiceOut *oss) int samples_written; ssize_t bytes_written; int samples_till_end =3D hw->samples - oss->wpos; - int samples_to_write =3D audio_MIN (oss->pending, samples_till_end= ); + int samples_to_write =3D MIN (oss->pending, samples_till_end); int bytes_to_write =3D samples_to_write << hw->info.shift; void *pcm =3D advance (oss->pcm_buf, oss->wpos << hw->info.shift); =20 @@ -437,7 +437,7 @@ static int oss_run_out (HWVoiceOut *hw, int live) =20 pos =3D hw->rpos << hw->info.shift; bytes =3D audio_ring_dist (cntinfo.ptr, pos, bufsize); - decr =3D audio_MIN (bytes >> hw->info.shift, live); + decr =3D MIN (bytes >> hw->info.shift, live); } else { err =3D ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &abinfo); @@ -456,7 +456,7 @@ static int oss_run_out (HWVoiceOut *hw, int live) return 0; } =20 - decr =3D audio_MIN (abinfo.bytes >> hw->info.shift, live); + decr =3D MIN (abinfo.bytes >> hw->info.shift, live); if (!decr) { return 0; } diff --git a/audio/paaudio.c b/audio/paaudio.c index 1d68173636..f3864e1d50 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -235,7 +235,7 @@ static void *qpa_thread_out (void *arg) } } =20 - decr =3D to_mix =3D audio_MIN(pa->live, pa->samples >> 5); + decr =3D to_mix =3D MIN(pa->live, pa->samples >> 5); rpos =3D pa->rpos; =20 if (audio_pt_unlock(&pa->pt, __func__)) { @@ -244,7 +244,7 @@ static void *qpa_thread_out (void *arg) =20 while (to_mix) { int error; - int chunk =3D audio_MIN (to_mix, hw->samples - rpos); + int chunk =3D MIN (to_mix, hw->samples - rpos); struct st_sample *src =3D hw->mix_buf + rpos; =20 hw->clip (pa->pcm_buf, src, chunk); @@ -282,7 +282,7 @@ static int qpa_run_out (HWVoiceOut *hw, int live) return 0; } =20 - decr =3D audio_MIN (live, pa->decr); + decr =3D MIN (live, pa->decr); pa->decr -=3D decr; pa->live =3D live - decr; hw->rpos =3D pa->rpos; @@ -327,7 +327,7 @@ static void *qpa_thread_in (void *arg) } } =20 - incr =3D to_grab =3D audio_MIN(pa->dead, pa->samples >> 5); + incr =3D to_grab =3D MIN(pa->dead, pa->samples >> 5); wpos =3D pa->wpos; =20 if (audio_pt_unlock(&pa->pt, __func__)) { @@ -336,7 +336,7 @@ static void *qpa_thread_in (void *arg) =20 while (to_grab) { int error; - int chunk =3D audio_MIN (to_grab, hw->samples - wpos); + int chunk =3D MIN (to_grab, hw->samples - wpos); void *buf =3D advance (pa->pcm_buf, wpos); =20 if (qpa_simple_read (pa, buf, @@ -375,7 +375,7 @@ static int qpa_run_in (HWVoiceIn *hw) =20 live =3D audio_pcm_hw_get_live_in (hw); dead =3D hw->samples - live; - incr =3D audio_MIN (dead, pa->incr); + incr =3D MIN (dead, pa->incr); pa->incr -=3D incr; pa->dead =3D dead - incr; hw->wpos =3D pa->wpos; diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index e7179ff1d4..42f7614124 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -193,10 +193,10 @@ static void sdl_callback (void *opaque, Uint8 *buf, i= nt len) =20 /* dolog ("in callback samples=3D%d live=3D%d\n", samples, sdl->live);= */ =20 - to_mix =3D audio_MIN(samples, sdl->live); + to_mix =3D MIN(samples, sdl->live); decr =3D to_mix; while (to_mix) { - int chunk =3D audio_MIN(to_mix, hw->samples - hw->rpos); + int chunk =3D MIN(to_mix, hw->samples - hw->rpos); struct st_sample *src =3D hw->mix_buf + hw->rpos; =20 /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */ @@ -236,7 +236,7 @@ static int sdl_run_out (HWVoiceOut *hw, int live) sdl->live); } =20 - decr =3D audio_MIN (sdl->decr, live); + decr =3D MIN (sdl->decr, live); sdl->decr -=3D decr; =20 sdl->live =3D live; diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 0ead5ae43a..6f4a0558f8 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -164,20 +164,20 @@ static int line_out_run (HWVoiceOut *hw, int live) } =20 decr =3D rate_get_samples (&hw->info, &out->rate); - decr =3D audio_MIN (live, decr); + decr =3D MIN (live, decr); =20 samples =3D decr; rpos =3D hw->rpos; while (samples) { int left_till_end_samples =3D hw->samples - rpos; - int len =3D audio_MIN (samples, left_till_end_samples); + int len =3D MIN (samples, left_till_end_samples); =20 if (!out->frame) { spice_server_playback_get_buffer (&out->sin, &out->frame, &out= ->fsize); out->fpos =3D out->frame; } if (out->frame) { - len =3D audio_MIN (len, out->fsize); + len =3D MIN (len, out->fsize); hw->clip (out->fpos, hw->mix_buf + rpos, len); out->fsize -=3D len; out->fpos +=3D len; @@ -295,7 +295,7 @@ static int line_in_run (HWVoiceIn *hw) } =20 delta_samp =3D rate_get_samples (&hw->info, &in->rate); - num_samples =3D audio_MIN (num_samples, delta_samp); + num_samples =3D MIN (num_samples, delta_samp); =20 ready =3D spice_server_record_get_samples (&in->sin, in->samples, num_= samples); samples =3D in->samples; @@ -305,7 +305,7 @@ static int line_in_run (HWVoiceIn *hw) ready =3D LINE_IN_SAMPLES; } =20 - num_samples =3D audio_MIN (ready, num_samples); + num_samples =3D MIN (ready, num_samples); =20 if (hw->wpos + num_samples > hw->samples) { len[0] =3D hw->samples - hw->wpos; diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 803b6cb1f3..bbf3f3b346 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -59,12 +59,12 @@ static int wav_run_out (HWVoiceOut *hw, int live) } =20 wav->old_ticks =3D now; - decr =3D audio_MIN (live, samples); + decr =3D MIN (live, samples); samples =3D decr; rpos =3D hw->rpos; while (samples) { int left_till_end_samples =3D hw->samples - rpos; - int convert_samples =3D audio_MIN (samples, left_till_end_samples); + int convert_samples =3D MIN (samples, left_till_end_samples); =20 src =3D hw->mix_buf + rpos; dst =3D advance (wav->pcm_buf, rpos << hw->info.shift); diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 0d8e524233..060bafdac3 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -964,7 +964,7 @@ static int write_audio (AC97LinkState *s, AC97BusMaster= Regs *r, uint32_t temp =3D r->picb << 1; uint32_t written =3D 0; int to_copy =3D 0; - temp =3D audio_MIN (temp, max); + temp =3D MIN (temp, max); =20 if (!temp) { *stop =3D 1; @@ -973,7 +973,7 @@ static int write_audio (AC97LinkState *s, AC97BusMaster= Regs *r, =20 while (temp) { int copied; - to_copy =3D audio_MIN (temp, sizeof (tmpbuf)); + to_copy =3D MIN (temp, sizeof (tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); copied =3D AUD_write (s->voice_po, tmpbuf, to_copy); dolog ("write_audio max=3D%x to_copy=3D%x copied=3D%x\n", @@ -1019,7 +1019,7 @@ static void write_bup (AC97LinkState *s, int elapsed) } =20 while (elapsed) { - int temp =3D audio_MIN (elapsed, sizeof (s->silence)); + int temp =3D MIN (elapsed, sizeof (s->silence)); while (temp) { int copied =3D AUD_write (s->voice_po, s->silence, temp); if (!copied) @@ -1040,7 +1040,7 @@ static int read_audio (AC97LinkState *s, AC97BusMaste= rRegs *r, int to_copy =3D 0; SWVoiceIn *voice =3D (r - s->bm_regs) =3D=3D MC_INDEX ? s->voice_mc : = s->voice_pi; =20 - temp =3D audio_MIN (temp, max); + temp =3D MIN (temp, max); =20 if (!temp) { *stop =3D 1; @@ -1049,7 +1049,7 @@ static int read_audio (AC97LinkState *s, AC97BusMaste= rRegs *r, =20 while (temp) { int acquired; - to_copy =3D audio_MIN (temp, sizeof (tmpbuf)); + to_copy =3D MIN (temp, sizeof (tmpbuf)); acquired =3D AUD_read (voice, tmpbuf, to_copy); if (!acquired) { *stop =3D 1; diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index df2e781788..1b32c4ff7f 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -195,7 +195,7 @@ static void adlib_callback (void *opaque, int free) return; } =20 - to_play =3D audio_MIN (s->left, samples); + to_play =3D MIN (s->left, samples); while (to_play) { written =3D write_audio (s, to_play); =20 @@ -210,7 +210,7 @@ static void adlib_callback (void *opaque, int free) } } =20 - samples =3D audio_MIN (samples, s->samples - s->pos); + samples =3D MIN (samples, s->samples - s->pos); if (!samples) { return; } diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index e3ea830b47..ca3af8a987 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -535,7 +535,7 @@ static int cs_write_audio (CSState *s, int nchan, int d= ma_pos, int copied; size_t to_copy; =20 - to_copy =3D audio_MIN (temp, left); + to_copy =3D MIN (temp, left); if (to_copy > sizeof (tmpbuf)) { to_copy =3D sizeof (tmpbuf); } @@ -578,7 +578,7 @@ static int cs_dma_read (void *opaque, int nchan, int dm= a_pos, int dma_len) till =3D (s->dregs[Playback_Lower_Base_Count] | (s->dregs[Playback_Upper_Base_Count] << 8)) << s->shift; till -=3D s->transferred; - copy =3D audio_MIN (till, copy); + copy =3D MIN (till, copy); } =20 if ((copy <=3D 0) || (dma_len <=3D 0)) { diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 7589671d20..50b144ded0 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -645,7 +645,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, int size =3D d->frame_cnt & 0xffff; int left =3D ((size - cnt + 1) << 2) + d->leftover; int transferred =3D 0; - int temp =3D audio_MIN (max, audio_MIN (left, csc_bytes)); + int temp =3D MIN (max, MIN (left, csc_bytes)); int index =3D d - &s->chan[0]; =20 addr +=3D (cnt << 2) + d->leftover; @@ -654,7 +654,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, while (temp) { int acquired, to_copy; =20 - to_copy =3D audio_MIN ((size_t) temp, sizeof (tmpbuf)); + to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); acquired =3D AUD_read (s->adc_voice, tmpbuf, to_copy); if (!acquired) break; @@ -672,7 +672,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, while (temp) { int copied, to_copy; =20 - to_copy =3D audio_MIN ((size_t) temp, sizeof (tmpbuf)); + to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); copied =3D AUD_write (voice, tmpbuf, to_copy); if (!copied) diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 566864bc9e..325efd8df7 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -117,7 +117,7 @@ static void GUS_callback (void *opaque, int free) GUSState *s =3D opaque; =20 samples =3D free >> s->shift; - to_play =3D audio_MIN (samples, s->left); + to_play =3D MIN (samples, s->left); =20 while (to_play) { int written =3D write_audio (s, to_play); @@ -132,7 +132,7 @@ static void GUS_callback (void *opaque, int free) net +=3D written; } =20 - samples =3D audio_MIN (samples, s->samples); + samples =3D MIN (samples, s->samples); if (samples) { gus_mixvoices (&s->emu, s->freq, samples, s->mixbuf); =20 @@ -192,7 +192,7 @@ static int GUS_read_DMA (void *opaque, int nchan, int d= ma_pos, int dma_len) ldebug ("read DMA %#x %d\n", dma_pos, dma_len); mode =3D k->has_autoinitialization(s->isa_dma, s->emu.gusdma); while (left) { - int to_copy =3D audio_MIN ((size_t) left, sizeof (tmpbuf)); + int to_copy =3D MIN ((size_t) left, sizeof (tmpbuf)); int copied; =20 ldebug ("left=3D%d to_copy=3D%d pos=3D%d\n", left, to_copy, pos); diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 967a10f189..c8f513d3ff 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -234,10 +234,10 @@ static void hda_audio_input_timer(void *opaque) goto out_timer; } =20 - int64_t to_transfer =3D audio_MIN(wpos - rpos, wanted_rpos - rpos); + int64_t to_transfer =3D MIN(wpos - rpos, wanted_rpos - rpos); while (to_transfer) { uint32_t start =3D (rpos & B_MASK); - uint32_t chunk =3D audio_MIN(B_SIZE - start, to_transfer); + uint32_t chunk =3D MIN(B_SIZE - start, to_transfer); int rc =3D hda_codec_xfer( &st->state->hda, st->stream, false, st->buf + start, chunk= ); if (!rc) { @@ -262,13 +262,13 @@ static void hda_audio_input_cb(void *opaque, int avai= l) int64_t wpos =3D st->wpos; int64_t rpos =3D st->rpos; =20 - int64_t to_transfer =3D audio_MIN(B_SIZE - (wpos - rpos), avail); + int64_t to_transfer =3D MIN(B_SIZE - (wpos - rpos), avail); =20 hda_timer_sync_adjust(st, -((wpos - rpos) + to_transfer - (B_SIZE >> 1= ))); =20 while (to_transfer) { uint32_t start =3D (uint32_t) (wpos & B_MASK); - uint32_t chunk =3D (uint32_t) audio_MIN(B_SIZE - start, to_transfe= r); + uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); uint32_t read =3D AUD_read(st->voice.in, st->buf + start, chunk); wpos +=3D read; to_transfer -=3D read; @@ -298,10 +298,10 @@ static void hda_audio_output_timer(void *opaque) goto out_timer; } =20 - int64_t to_transfer =3D audio_MIN(B_SIZE - (wpos - rpos), wanted_wpos = - wpos); + int64_t to_transfer =3D MIN(B_SIZE - (wpos - rpos), wanted_wpos - wpos= ); while (to_transfer) { uint32_t start =3D (wpos & B_MASK); - uint32_t chunk =3D audio_MIN(B_SIZE - start, to_transfer); + uint32_t chunk =3D MIN(B_SIZE - start, to_transfer); int rc =3D hda_codec_xfer( &st->state->hda, st->stream, true, st->buf + start, chunk); if (!rc) { @@ -326,7 +326,7 @@ static void hda_audio_output_cb(void *opaque, int avail) int64_t wpos =3D st->wpos; int64_t rpos =3D st->rpos; =20 - int64_t to_transfer =3D audio_MIN(wpos - rpos, avail); + int64_t to_transfer =3D MIN(wpos - rpos, avail); =20 if (wpos - rpos =3D=3D B_SIZE) { /* drop buffer, reset timer adjust */ @@ -341,7 +341,7 @@ static void hda_audio_output_cb(void *opaque, int avail) =20 while (to_transfer) { uint32_t start =3D (uint32_t) (rpos & B_MASK); - uint32_t chunk =3D (uint32_t) audio_MIN(B_SIZE - start, to_transfe= r); + uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); uint32_t written =3D AUD_write(st->voice.out, st->buf + start, chu= nk); rpos +=3D written; to_transfer -=3D written; diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index 4835229326..929b856587 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -184,7 +184,7 @@ static void ac97_in_cb(void *opaque, int avail_b) MilkymistAC97State *s =3D opaque; uint8_t buf[4096]; uint32_t remaining =3D s->regs[R_U_REMAINING]; - int temp =3D audio_MIN(remaining, avail_b); + int temp =3D MIN(remaining, avail_b); uint32_t addr =3D s->regs[R_U_ADDR]; int transferred =3D 0; =20 @@ -198,7 +198,7 @@ static void ac97_in_cb(void *opaque, int avail_b) while (temp) { int acquired, to_copy; =20 - to_copy =3D audio_MIN(temp, sizeof(buf)); + to_copy =3D MIN(temp, sizeof(buf)); acquired =3D AUD_read(s->voice_in, buf, to_copy); if (!acquired) { break; @@ -227,7 +227,7 @@ static void ac97_out_cb(void *opaque, int free_b) MilkymistAC97State *s =3D opaque; uint8_t buf[4096]; uint32_t remaining =3D s->regs[R_D_REMAINING]; - int temp =3D audio_MIN(remaining, free_b); + int temp =3D MIN(remaining, free_b); uint32_t addr =3D s->regs[R_D_ADDR]; int transferred =3D 0; =20 @@ -241,7 +241,7 @@ static void ac97_out_cb(void *opaque, int free_b) while (temp) { int copied, to_copy; =20 - to_copy =3D audio_MIN(temp, sizeof(buf)); + to_copy =3D MIN(temp, sizeof(buf)); cpu_physical_memory_read(addr, buf, to_copy); copied =3D AUD_write(s->voice_out, buf, to_copy); if (!copied) { diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 01127304c2..6bb1455c1b 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -103,7 +103,7 @@ static void pcspk_callback(void *opaque, int free) } =20 while (free > 0) { - n =3D audio_MIN(s->samples - s->play_pos, (unsigned int)free); + n =3D MIN(s->samples - s->play_pos, (unsigned int)free); n =3D AUD_write(s->voice, &s->sample_buf[s->play_pos], n); if (!n) break; diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 6b604979cf..5182eba8eb 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1168,7 +1168,7 @@ static int write_audio (SB16State *s, int nchan, int = dma_pos, int copied; size_t to_copy; =20 - to_copy =3D audio_MIN (temp, left); + to_copy =3D MIN (temp, left); if (to_copy > sizeof (tmpbuf)) { to_copy =3D sizeof (tmpbuf); } diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index dfb4156ff4..ab04bfa2c3 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -69,7 +69,7 @@ static inline void wm8750_in_load(WM8750State *s) { if (s->idx_in + s->req_in <=3D sizeof(s->data_in)) return; - s->idx_in =3D audio_MAX(0, (int) sizeof(s->data_in) - s->req_in); + s->idx_in =3D MAX(0, (int) sizeof(s->data_in) - s->req_in); AUD_read(*s->in[0], s->data_in + s->idx_in, sizeof(s->data_in) - s->idx_in); } @@ -100,7 +100,7 @@ static void wm8750_audio_out_cb(void *opaque, int free_= b) wm8750_out_flush(s); } else s->req_out =3D free_b - s->idx_out; -=20 + s->data_req(s->opaque, s->req_out >> 2, s->req_in >> 2); } =20 --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225064; cv=none; d=zoho.com; s=zohoarc; b=VFeP3chaMtYRf6qZxbTU97GvcbJyYAUPr4ZIeogeCAUypw6Ibz8WqjVf29s0k6sPmnURKhTKO8AMG9ora7jwtXQWdlTzJlJlibB1idnY9SEPRxhxfK6hRhj9Zn+oG7jiMEKmAD6u1IJf5hezO5qMyB9tLsf6twDs3JEoHx576bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225064; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6OHafAEHZIuHozFrMT2v5DQsOPGlwWydb4OAeYtBXa8=; b=Jt9Af917TwgjihVjWkdMz5nRf70iVGIBAsvKoHVxzOqd89MirK0VCEYJo8FHwAOafK/L18y917DQ1AFs/MjWlvg+m5ktGATyUvEnkkx1QE6RX3WSZw3q0AoU4xPUi8fMyg3kHRSxJrZ9asSaI+3jDbO9xwZzvs8EU90B1AGY3VQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563225064803914.2841617264046; Mon, 15 Jul 2019 14:11:04 -0700 (PDT) Received: from localhost ([::1]:43852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8FT-00023x-GE for importer@patchew.org; Mon, 15 Jul 2019 17:11:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42285) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8D0-0008Hx-4B for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cy-0004mI-Q9 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:30 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:53615) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cy-0004lV-Ja for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:28 -0400 Received: by mail-wm1-x342.google.com with SMTP id x15so16554856wmj.3 for ; Mon, 15 Jul 2019 14:08:28 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6OHafAEHZIuHozFrMT2v5DQsOPGlwWydb4OAeYtBXa8=; b=OwTg1hnSJRfvCPPeCtlJresK7A6FwCjI5zEHFdSG6iMhNApq2Cdv+59vZUePTWl4dD T70w5ArkzdTs0ruBUWZZQ/ShRTTBMR2W/REDIJ3EI4w++Cbv3ELxov8+T0C9UmLDTa6I V8E5N5rIpmiHf4KI72nSU90PCJB+7ydLzlQS5Y3dcUV6fnkE0yoGK6uWT6hHwch3jP3s dSQWfdCvvLZNy0Z+uQspjbRmVBIUsSb7FpZscWt7sj9H/Vt4mTeU4b960A+jyEfl0DJ1 kNaUauBRGEuoQ+yKaAQMsjOfFVwGT/Okzwkc1dTqY2CLaRZw3ZRtTGKDC/4K6JWRkSAh DGDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6OHafAEHZIuHozFrMT2v5DQsOPGlwWydb4OAeYtBXa8=; b=EkiGFgGbZcwXSZ52LTuwzRf1eReiT83FSefCpGctVUvFt6QxH2SfCCRBiW8EnICvtY AnUXCM395reErPcCki+k57Vj2y/un5TPbvrAiapcKhgdzpMs5RNlbGbKAZUl5PXQoDkO TGHJIh2b9Yx543gCJmDu6lPXni+NNhZTHqiYwkadOXFUeBSRF2yw2OVya7HH9m9Wx/Dk 8sNZ/ofjnk47+AXBBij7J6S06cAmJVTQRHYrFUZ8VYFiB1UXbJkQPrB+G9B87wLDzZBd /T0l41bwwkTIHm52UTHmgiCVY3naNGPe+ebIkYJw1n4QKpMeKFNRwxckugBB+H4Iazzj h1yw== X-Gm-Message-State: APjAAAX7cMJKVGy50RxzAh89RFKjrhTJoNVUtA+yn/Mux5ojaXRrD24L EJkhu+CpSvP69iVAxx2pF/5+93kt X-Google-Smtp-Source: APXvYqz5jTqXC5d0MHPzTkiqUZDjTOATOSYkDWPGU6o8CS4TFFJebGQgKprD1Sch0ykpt/vHVN7gIw== X-Received: by 2002:a1c:a1c1:: with SMTP id k184mr26997361wme.81.1563224907308; Mon, 15 Jul 2019 14:08:27 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:12 +0200 Message-Id: <7fc7c4f35e8c0ee4dcab05e70e168a62f2a8eef3.1563224628.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v2 10/14] audio: do not run each backend in audio_run X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) audio_run is called manually by alsa and oss backends when polling. In this case only the requesting backend should be run, not all of them. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 2 +- audio/alsaaudio.c | 7 +++++-- audio/audio.c | 14 +++++--------- audio/ossaudio.c | 12 ++++++------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 9f01f6ad00..7e00c1332e 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -221,7 +221,7 @@ int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_bu= f, int audio_bug (const char *funcname, int cond); void *audio_calloc (const char *funcname, int nmemb, size_t size); =20 -void audio_run (const char *msg); +void audio_run(AudioState *s, const char *msg); =20 #define VOICE_ENABLE 1 #define VOICE_DISABLE 2 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 6b9e0f06af..3daa7c8f8f 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -39,6 +39,7 @@ struct pollhlp { struct pollfd *pfds; int count; int mask; + AudioState *s; }; =20 typedef struct ALSAVoiceOut { @@ -199,11 +200,11 @@ static void alsa_poll_handler (void *opaque) break; =20 case SND_PCM_STATE_PREPARED: - audio_run ("alsa run (prepared)"); + audio_run(hlp->s, "alsa run (prepared)"); break; =20 case SND_PCM_STATE_RUNNING: - audio_run ("alsa run (running)"); + audio_run(hlp->s, "alsa run (running)"); break; =20 default: @@ -749,6 +750,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as, return -1; } =20 + alsa->pollhlp.s =3D hw->s; alsa->handle =3D handle; alsa->dev =3D dev; return 0; @@ -850,6 +852,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) return -1; } =20 + alsa->pollhlp.s =3D hw->s; alsa->handle =3D handle; alsa->dev =3D dev; return 0; diff --git a/audio/audio.c b/audio/audio.c index cb0222ab4a..07b35ffa03 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -835,7 +835,7 @@ static void audio_timer (void *opaque) } s->timer_last =3D now; =20 - audio_run("timer"); + audio_run(s, "timer"); audio_reset_timer(s); } =20 @@ -1237,15 +1237,11 @@ static void audio_run_capture (AudioState *s) } } =20 -void audio_run (const char *msg) +void audio_run(AudioState *s, const char *msg) { - AudioState *s; - - QTAILQ_FOREACH(s, &audio_states, list) { - audio_run_out(s); - audio_run_in(s); - audio_run_capture(s); - } + audio_run_out(s); + audio_run_in(s); + audio_run_capture(s); =20 #ifdef DEBUG_POLL { diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 29139ef1f5..456fba7480 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -110,28 +110,28 @@ static void oss_anal_close (int *fdp) =20 static void oss_helper_poll_out (void *opaque) { - (void) opaque; - audio_run ("oss_poll_out"); + AudioState *s =3D opaque; + audio_run(s, "oss_poll_out"); } =20 static void oss_helper_poll_in (void *opaque) { - (void) opaque; - audio_run ("oss_poll_in"); + AudioState *s =3D opaque; + audio_run(s, "oss_poll_in"); } =20 static void oss_poll_out (HWVoiceOut *hw) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; =20 - qemu_set_fd_handler (oss->fd, NULL, oss_helper_poll_out, NULL); + qemu_set_fd_handler(oss->fd, NULL, oss_helper_poll_out, hw->s); } =20 static void oss_poll_in (HWVoiceIn *hw) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; =20 - qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL); + qemu_set_fd_handler(oss->fd, oss_helper_poll_in, NULL, hw->s); } =20 static int oss_write (SWVoiceOut *sw, void *buf, int len) --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225023; cv=none; d=zoho.com; s=zohoarc; b=cHmQ+82L0IZyoffRJH+XizGrmPgDAiag/dvgFQcbjAHBzDd39YLi8wDBTElnIzvNmBJhTQA92uqGRw89VK0Y1n8C5QqSzuO2wP+LYvc7I7CUxyYPe0RK3R2DL++pua1afvsE5rpOncZupStpN33PDKkXIopm82jOVgD4C9MOTHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225023; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KkJvtrc3QrV2I7WYyibxflgUNfu3hfn3RhzurnFS0ws=; b=Q16IFuYaQG0Kp4SACOOPvJ+fh5lYWpyiyT2rFzs+3KcbYHk9R5OgTT5hmdsxq/sfV5YIYAqRCxF4sBIRb1yrTbfOqH0nsc+CeMUhulom47TZ/qGoZ2NqoJBFCKpvnSGdQGxjGFI0yDDdkbo7ub7jG51pBZuG39HtZ5MpsdXfgl0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563225023871824.5611419157397; Mon, 15 Jul 2019 14:10:23 -0700 (PDT) Received: from localhost ([::1]:43826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Eo-0007Bx-IT for importer@patchew.org; Mon, 15 Jul 2019 17:10:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42292) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8D1-0008N5-7H for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cz-0004mV-5U for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:31 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cy-0004m1-Ve for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:29 -0400 Received: by mail-wr1-x442.google.com with SMTP id f9so18541119wre.12 for ; Mon, 15 Jul 2019 14:08:28 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KkJvtrc3QrV2I7WYyibxflgUNfu3hfn3RhzurnFS0ws=; b=GDs0Qpy48j+fWFjAOJq+Z+M3HF7RS/rQA/oUG0yDaLj8EiQuEI+YFLt7FVFdejdCms MaMnELG75Nhtd6puW7yTjRQyb2qOOsLwrPM/hACfhVHd/h2AZXhKOG+pLA97ppxJbf3/ QQzwG7yxJFwyzRQMStIMJcoo1RRl9eyt44CZNE0GoyvOhfoeq5d8xF3o3VLbWPHcpLOh YvKr6jtZUiz1vHjZ4LSYWBqvF6maSYU0Wylhx/dRDqbejFYexi40g3mL+J33QVYQMnOS Gu42scSW5E7iUzMDzMQjDPloVkAain9CRaefdfFxVNV1o6VZSEvSqWh/JvIX82Mfuc3D TBCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KkJvtrc3QrV2I7WYyibxflgUNfu3hfn3RhzurnFS0ws=; b=ctOnGtaNqrw7zdy5pE8jrsxBMByg6F7C8TZyAaTsZJghFDWXU3adFv+icV9z17zpYK nt0AjExII7QWCoQm8zbllJYvAOO281Fb196gt03+MltDIOdborarGBNh7k4yBAw5+eKF LGNGlDBkMUOZ59+D3OWV22H9Ohqlg7n4bqGM4knnRJeb2MlB5u5WyGevpzyy3JKWcuaP vulkVbY33/Gl7xsMwtSNLbrehAAHeWxgviNXck1p3uclUVNWILld32W0thVkTUO5ssO4 nUyipBUrSPd0b9/E8k6JYNYWmk8uyPjRnS4Ji3jUgo8CArt/YB75bHk9/+4yj2cbUrmF SZeg== X-Gm-Message-State: APjAAAV/I1Mh8kB8g2wbu9+ImYInqN6w4kADj8rwvQwzSc/hEzwgoGRb jOuUAW84lromcUOe/GJGlylzw/S2 X-Google-Smtp-Source: APXvYqy8GIUMuqEr6cQ0g0AQPqxo0EKxob3kDirgMDYzaD9XCY70lK+67Ebrh/uaSJINzAGy4e38hg== X-Received: by 2002:adf:e28a:: with SMTP id v10mr31600071wri.178.1563224907943; Mon, 15 Jul 2019 14:08:27 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:13 +0200 Message-Id: <807236d168f1c69d19d62e4a3b0f5472fc0d7d26.1563224628.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v2 11/14] paaudio: fix playback glitches X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Pulseaudio normally assumes that when the server wants it, the client can generate the audio samples and send it right away. Unfortunately this is not the case with QEMU -- it's up to the emulated system when does it generate the samples. Buffering the samples and sending them from a background thread is just a workaround, that doesn't work too well. Instead enable pa's compatibility support and let pa worry about the details. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/paaudio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index f3864e1d50..c8ae1a6eca 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -512,10 +512,8 @@ static pa_stream *qpa_simple_new ( =20 flags =3D PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY - | PA_STREAM_ADJUST_LATENCY -#endif - | PA_STREAM_AUTO_TIMING_UPDATE; + | PA_STREAM_AUTO_TIMING_UPDATE + | PA_STREAM_EARLY_REQUESTS; =20 if (dev) { /* don't move the stream if the user specified a sink/source */ --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563224982; cv=none; d=zoho.com; s=zohoarc; b=WmpcQB9LpmLIe7iUr/B5J5N1PQFs+JNpNysBvuUfYN+wnwJw+MhY7G4dOHU3q08bDzyAZCM8lkQ23txgmGONUKmaQlyjG/KEOIKXf3dfdYNeUW/A+Q3mn2e6O0D5p4oz1PVFlKSQhbhsY0CQRwqY0hWd9rDwcLLuBIIW8Nl9RSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563224982; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VY86o4VDQLjRZx45nc8Bf0PJBI7xJZDkLJjCJv/44bI=; b=ZapSGuyfo0CJsSQr0Gs4DdtJASs1FhxzJRgztDJI7LUqv1LRlyg1i1GVthkIDCSmi2J0prdvpFzxO0N7vPEXtDFVnigjGXN1joNaMKwgp/xKtk1EaHQdfCOVg4q7gONtpEl+5daKaCuMKZfYGjxRrVxwWU2IzNYkpP2PW739yWI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156322498230680.36565925916614; Mon, 15 Jul 2019 14:09:42 -0700 (PDT) Received: from localhost ([::1]:43806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8E6-0003yA-U3 for importer@patchew.org; Mon, 15 Jul 2019 17:09:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42310) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8D2-0008Qg-5V for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8D0-0004n8-8X for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:32 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:44994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8D0-0004mb-1B for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:30 -0400 Received: by mail-wr1-x441.google.com with SMTP id p17so18551661wrf.11 for ; Mon, 15 Jul 2019 14:08:29 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VY86o4VDQLjRZx45nc8Bf0PJBI7xJZDkLJjCJv/44bI=; b=fuTZ3esQMHimJlEhJCfPgt52GyQo/UepZuqbXKZWkPu6XXaLEjO2ugAKcJPMuGZKre +JxAp/tzfzklp83FUrUaPEBiYOy9SSvQ9c/3UCH5YwYfPw5pUrjNKSm6BvTmwChmcqo7 zebncGfD0CtNARGG8X73jHDYxNhODa+/saiZqO21bza6E71a7ATS+6U82efLoR+NGZO+ +f2jWWj8cjrSA08YkVhXDPSgE8jXgRzuKf0g1lJfoPG26PxbyRlBLi73s2NZfogSoN// nr88/otjIyOxeen1N4B77U2ZoywD8RPs5LnWQyWQxjl+UsmTC2iHL+pxnIynhc21JDq5 xD7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VY86o4VDQLjRZx45nc8Bf0PJBI7xJZDkLJjCJv/44bI=; b=J1dZo68sO1SZpZb3wdJIXFsCxeGlefBKTN4F6w3BFNCx5XX8K/tps4f/2uQvd6ScUx eok38YCmxpfwEpJuRhhXw4ABAiPE4BKtHNj0+iof0JV8Ze6Rw5cVy8JmhwS7gNtoM2CA hldB+83WNikM7ZkO0APKA+TI5R4nsEq2xMusl/SqWEmPCaJgWImBkohiOW2N4F3ir2y+ tfJNdoWoOJnpsVuGxALoy9ozoIWcitQCpbY+BGsorZfW5174BKlHeqv526hnJpJldemk uko1Wb0A3MO3Kz0mhiT+JoT/2TTHWuc/TeIg8nNA5n7CJfbcE2dFikx1gYJRHtQtrWWu XM/A== X-Gm-Message-State: APjAAAVTmR01p2uI8iP7he8hfSrdJmBICPztweWbdCsg9F0hzjoUs4OL Ck4k8yp/eKSMFg0ZMy3GL2HqNjC7 X-Google-Smtp-Source: APXvYqw0zVW86Nq0MqGWyo8NfQX+r14wGYF4EFi9VHaIeufJpMSKYCWHQjryDBOdh0KU0OXFHVhUew== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr29981902wrn.244.1563224908767; Mon, 15 Jul 2019 14:08:28 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:14 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v2 12/14] audio: remove read and write pcm_ops X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) They just called audio_pcm_sw_read/write anyway, so it makes no sense to have them too. (The noaudio's read is the only exception, but it should work with the generic code too.) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_int.h | 5 ----- audio/alsaaudio.c | 12 ------------ audio/audio.c | 8 ++++---- audio/coreaudio.c | 6 ------ audio/dsoundaudio.c | 12 ------------ audio/noaudio.c | 19 ------------------- audio/ossaudio.c | 12 ------------ audio/paaudio.c | 12 ------------ audio/sdlaudio.c | 6 ------ audio/spiceaudio.c | 12 ------------ audio/wavaudio.c | 6 ------ 11 files changed, 4 insertions(+), 106 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 7e00c1332e..003b7ab8cc 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -150,13 +150,11 @@ struct audio_pcm_ops { int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opa= que); void (*fini_out)(HWVoiceOut *hw); int (*run_out) (HWVoiceOut *hw, int live); - int (*write) (SWVoiceOut *sw, void *buf, int size); int (*ctl_out) (HWVoiceOut *hw, int cmd, ...); =20 int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaq= ue); void (*fini_in) (HWVoiceIn *hw); int (*run_in) (HWVoiceIn *hw); - int (*read) (SWVoiceIn *sw, void *buf, int size); int (*ctl_in) (HWVoiceIn *hw, int cmd, ...); }; =20 @@ -210,11 +208,8 @@ audio_driver *audio_driver_lookup(const char *name); void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings = *as); void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len); =20 -int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len); int audio_pcm_hw_get_live_in (HWVoiceIn *hw); =20 -int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len); - int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, int live, int pending); =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 3daa7c8f8f..e9e3a4819c 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -270,11 +270,6 @@ static int alsa_poll_in (HWVoiceIn *hw) return alsa_poll_helper (alsa->handle, &alsa->pollhlp, POLLIN); } =20 -static int alsa_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness) { switch (fmt) { @@ -988,11 +983,6 @@ static int alsa_run_in (HWVoiceIn *hw) return read_samples; } =20 -static int alsa_read (SWVoiceIn *sw, void *buf, int size) -{ - return audio_pcm_sw_read (sw, buf, size); -} - static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...) { ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; @@ -1076,13 +1066,11 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { .init_out =3D alsa_init_out, .fini_out =3D alsa_fini_out, .run_out =3D alsa_run_out, - .write =3D alsa_write, .ctl_out =3D alsa_ctl_out, =20 .init_in =3D alsa_init_in, .fini_in =3D alsa_fini_in, .run_in =3D alsa_run_in, - .read =3D alsa_read, .ctl_in =3D alsa_ctl_in, }; =20 diff --git a/audio/audio.c b/audio/audio.c index 07b35ffa03..254499dfa1 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -594,7 +594,7 @@ static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw) } } =20 -int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size) +static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size) { HWVoiceIn *hw =3D sw->hw; int samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D 0; @@ -696,7 +696,7 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, i= nt *nb_live) /* * Soft voice (playback) */ -int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int size) +static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf, int size) { int hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, b= lck; int ret =3D 0, pos =3D 0, total =3D 0; @@ -854,7 +854,7 @@ int AUD_write (SWVoiceOut *sw, void *buf, int size) return 0; } =20 - return sw->hw->pcm_ops->write(sw, buf, size); + return audio_pcm_sw_write(sw, buf, size); } =20 int AUD_read (SWVoiceIn *sw, void *buf, int size) @@ -869,7 +869,7 @@ int AUD_read (SWVoiceIn *sw, void *buf, int size) return 0; } =20 - return sw->hw->pcm_ops->read(sw, buf, size); + return audio_pcm_sw_read(sw, buf, size); } =20 int AUD_get_buffer_size_out (SWVoiceOut *sw) diff --git a/audio/coreaudio.c b/audio/coreaudio.c index f0ab4014a8..091fe84a34 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -489,11 +489,6 @@ static OSStatus audioDeviceIOProc( return 0; } =20 -static int coreaudio_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) { @@ -692,7 +687,6 @@ static struct audio_pcm_ops coreaudio_pcm_ops =3D { .init_out =3D coreaudio_init_out, .fini_out =3D coreaudio_fini_out, .run_out =3D coreaudio_run_out, - .write =3D coreaudio_write, .ctl_out =3D coreaudio_ctl_out }; =20 diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 07260f881e..11594c3095 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -454,11 +454,6 @@ static int dsound_ctl_out (HWVoiceOut *hw, int cmd, ..= .) return 0; } =20 -static int dsound_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int dsound_run_out (HWVoiceOut *hw, int live) { int err; @@ -645,11 +640,6 @@ static int dsound_ctl_in (HWVoiceIn *hw, int cmd, ...) return 0; } =20 -static int dsound_read (SWVoiceIn *sw, void *buf, int len) -{ - return audio_pcm_sw_read (sw, buf, len); -} - static int dsound_run_in (HWVoiceIn *hw) { int err; @@ -856,13 +846,11 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { .init_out =3D dsound_init_out, .fini_out =3D dsound_fini_out, .run_out =3D dsound_run_out, - .write =3D dsound_write, .ctl_out =3D dsound_ctl_out, =20 .init_in =3D dsound_init_in, .fini_in =3D dsound_fini_in, .run_in =3D dsound_run_in, - .read =3D dsound_read, .ctl_in =3D dsound_ctl_in }; =20 diff --git a/audio/noaudio.c b/audio/noaudio.c index 14a0e4ab29..cbb02d9e49 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -61,11 +61,6 @@ static int no_run_out (HWVoiceOut *hw, int live) return decr; } =20 -static int no_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write(sw, buf, len); -} - static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_o= paque) { audio_pcm_init_info (&hw->info, as); @@ -118,18 +113,6 @@ static int no_run_in (HWVoiceIn *hw) return samples; } =20 -static int no_read (SWVoiceIn *sw, void *buf, int size) -{ - /* use custom code here instead of audio_pcm_sw_read() to avoid - * useless resampling/mixing */ - int samples =3D size >> sw->info.shift; - int total =3D sw->hw->total_samples_captured - sw->total_hw_samples_ac= quired; - int to_clear =3D MIN (samples, total); - sw->total_hw_samples_acquired +=3D total; - audio_pcm_info_clear_buf (&sw->info, buf, to_clear); - return to_clear << sw->info.shift; -} - static int no_ctl_in (HWVoiceIn *hw, int cmd, ...) { (void) hw; @@ -151,13 +134,11 @@ static struct audio_pcm_ops no_pcm_ops =3D { .init_out =3D no_init_out, .fini_out =3D no_fini_out, .run_out =3D no_run_out, - .write =3D no_write, .ctl_out =3D no_ctl_out, =20 .init_in =3D no_init_in, .fini_in =3D no_fini_in, .run_in =3D no_run_in, - .read =3D no_read, .ctl_in =3D no_ctl_in }; =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 456fba7480..b99edbec17 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -134,11 +134,6 @@ static void oss_poll_in (HWVoiceIn *hw) qemu_set_fd_handler(oss->fd, oss_helper_poll_in, NULL, hw->s); } =20 -static int oss_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int aud_to_ossfmt (AudioFormat fmt, int endianness) { switch (fmt) { @@ -788,11 +783,6 @@ static int oss_run_in (HWVoiceIn *hw) return read_samples; } =20 -static int oss_read (SWVoiceIn *sw, void *buf, int size) -{ - return audio_pcm_sw_read (sw, buf, size); -} - static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; @@ -855,13 +845,11 @@ static struct audio_pcm_ops oss_pcm_ops =3D { .init_out =3D oss_init_out, .fini_out =3D oss_fini_out, .run_out =3D oss_run_out, - .write =3D oss_write, .ctl_out =3D oss_ctl_out, =20 .init_in =3D oss_init_in, .fini_in =3D oss_fini_in, .run_in =3D oss_run_in, - .read =3D oss_read, .ctl_in =3D oss_ctl_in }; =20 diff --git a/audio/paaudio.c b/audio/paaudio.c index c8ae1a6eca..efb72ced30 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -295,11 +295,6 @@ static int qpa_run_out (HWVoiceOut *hw, int live) return decr; } =20 -static int qpa_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - /* capture */ static void *qpa_thread_in (void *arg) { @@ -388,11 +383,6 @@ static int qpa_run_in (HWVoiceIn *hw) return incr; } =20 -static int qpa_read (SWVoiceIn *sw, void *buf, int len) -{ - return audio_pcm_sw_read (sw, buf, len); -} - static pa_sample_format_t audfmt_to_pa (AudioFormat afmt, int endianness) { int format; @@ -1016,13 +1006,11 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { .init_out =3D qpa_init_out, .fini_out =3D qpa_fini_out, .run_out =3D qpa_run_out, - .write =3D qpa_write, .ctl_out =3D qpa_ctl_out, =20 .init_in =3D qpa_init_in, .fini_in =3D qpa_fini_in, .run_in =3D qpa_run_in, - .read =3D qpa_read, .ctl_in =3D qpa_ctl_in }; =20 diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 42f7614124..c7fd487e0e 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -217,11 +217,6 @@ static void sdl_callback (void *opaque, Uint8 *buf, in= t len) } } =20 -static int sdl_write_out (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int sdl_run_out (HWVoiceOut *hw, int live) { int decr; @@ -342,7 +337,6 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { .init_out =3D sdl_init_out, .fini_out =3D sdl_fini_out, .run_out =3D sdl_run_out, - .write =3D sdl_write_out, .ctl_out =3D sdl_ctl_out, }; =20 diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6f4a0558f8..6e7f13cffa 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -193,11 +193,6 @@ static int line_out_run (HWVoiceOut *hw, int live) return decr; } =20 -static int line_out_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int line_out_ctl (HWVoiceOut *hw, int cmd, ...) { SpiceVoiceOut *out =3D container_of (hw, SpiceVoiceOut, hw); @@ -326,11 +321,6 @@ static int line_in_run (HWVoiceIn *hw) return num_samples; } =20 -static int line_in_read (SWVoiceIn *sw, void *buf, int size) -{ - return audio_pcm_sw_read (sw, buf, size); -} - static int line_in_ctl (HWVoiceIn *hw, int cmd, ...) { SpiceVoiceIn *in =3D container_of (hw, SpiceVoiceIn, hw); @@ -378,13 +368,11 @@ static struct audio_pcm_ops audio_callbacks =3D { .init_out =3D line_out_init, .fini_out =3D line_out_fini, .run_out =3D line_out_run, - .write =3D line_out_write, .ctl_out =3D line_out_ctl, =20 .init_in =3D line_in_init, .fini_in =3D line_in_fini, .run_in =3D line_in_run, - .read =3D line_in_read, .ctl_in =3D line_in_ctl, }; =20 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index bbf3f3b346..17ab921cef 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -84,11 +84,6 @@ static int wav_run_out (HWVoiceOut *hw, int live) return decr; } =20 -static int wav_write_out (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - /* VICE code: Store number as little endian. */ static void le_store (uint8_t *buf, uint32_t val, int len) { @@ -240,7 +235,6 @@ static struct audio_pcm_ops wav_pcm_ops =3D { .init_out =3D wav_init_out, .fini_out =3D wav_fini_out, .run_out =3D wav_run_out, - .write =3D wav_write_out, .ctl_out =3D wav_ctl_out, }; =20 --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225100; cv=none; d=zoho.com; s=zohoarc; b=ApXEcsNeXBn/Wu8T5rMCgVRl3yMfyOMSkqf7vrvmWnyqMWqznrKjy7Wj//Pl2znxqn9Wlk2XwKUyFy7wI14ADPuHi+vQ8Rm0L1d8QBBoIn6ybxIRMDOXkiQgUmWZReTzmbp6FAzjdUdbVjIlYwawZnfja/yuYAM4VXFX64xnV5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225100; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aIu37KvQweuy5+WCYiKp8sjLXR2aWElS7r2AFXikGH8=; b=RKA1+K5nbO2/4I3UXp4o9tbcM60BrrHaOYUvOv8NFvkxWQhvzkuUqaZzXyVyMbwJSR5VXLs5fjDbQmEuJyQs7fEm9Zkv2DF7peZMC1BzhU+XFH7W1hoTXP78U8xGO/KLA70Ku7u2M879tQ+52PAjdq5dbiHfP9b8s9P+okxhK/Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563225100914829.2923418242743; Mon, 15 Jul 2019 14:11:40 -0700 (PDT) Received: from localhost ([::1]:43874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8G3-0004qt-Q6 for importer@patchew.org; Mon, 15 Jul 2019 17:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42343) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8D6-0000IW-UD for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8D2-0004ol-JT for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:36 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:34406) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8D2-0004np-7R for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:32 -0400 Received: by mail-wr1-x431.google.com with SMTP id 31so18621289wrm.1 for ; Mon, 15 Jul 2019 14:08:32 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aIu37KvQweuy5+WCYiKp8sjLXR2aWElS7r2AFXikGH8=; b=XpeGJDBTdy13SPcDGEGBq50VMjhv6iV8GmCbT+Ta6JUh6N623zxX55iilm6qFXs+Ki Fbh9mvha5bme5uQA4+KRz+eCs8Rr2vY2ssBtgjvoO5Njg0Ocx+OnxUPMc3rEnsbILU2X KiwwbBwKVpt+txjX4TgCZ/xFpf8zSV5FI+xt2CZ7qI1/aPdnDT64Tf4cncJwNYsHvVKr nLNHPbhtMZoydJ6uJkrSd22Dx57ZztuGjZ0+EPVVbBlE2W6r8qa5sj1M9EEcoimA9KQU Sxje8DTN4hdUjFueHuPxrrFfY1qt8JLuGjczjGLOpFgrlf5vxIOsp94CoshErL6epczc UE0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aIu37KvQweuy5+WCYiKp8sjLXR2aWElS7r2AFXikGH8=; b=pKWLfgPt0+d32RBvEEw4RpxzFAN5FsLqEeryodmlRy7XuZh5D0xPof7izxsiW9upGw AyiFV0wWlJqi6rOZQjkHjJ1r4A5ESPvaXPPjGUqcOgkSQa40670/Elo5Z3kNIif0YHlF 3oyv2BHPp3lQF4ZfTQ4goBbNhuyxEA2G6xg/UicRYoBy5JmQFS2w3s51uVS2NIo7DW2s K19NEWahJ//78QPQTLJPyUki8VX0Z1fdBMx32VfLQxrBHqzcThVu96IT/FOEO2wvVC7D UA7w0Ed2WF2xHPBU/PJshIcL1aKUAtE9ifpvYc2DnmhRTAij3VWPzenV2Iwb0SMCRmx3 guWQ== X-Gm-Message-State: APjAAAWcfKJOy+2W61UmxGa3uNJaBWwHvRQGRvLd2T/baqOpv9TXo1+k bYq/gjsneC4n4W84CwEt8abEcHA0KGg= X-Google-Smtp-Source: APXvYqw4T1ZoVJ8ZISTtdlz8YuenLK7aNCHxqSS+khapXkpkwzfBuFRTO4embfTYbocQP7FG9039Bg== X-Received: by 2002:adf:a344:: with SMTP id d4mr30747289wrb.237.1563224909953; Mon, 15 Jul 2019 14:08:29 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:15 +0200 Message-Id: <6dd484f94fd67356595dec42156ead40ea535687.1563224628.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [PATCH v2 13/14] audio: use size_t where makes sense X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Gerd Hoffmann , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio.h | 4 +- audio/audio_int.h | 26 +++---- audio/audio_template.h | 14 ++-- audio/mixeng.h | 9 +-- audio/rate_template.h | 2 +- include/sysemu/replay.h | 4 +- audio/alsaaudio.c | 26 +++---- audio/audio.c | 156 ++++++++++++++++++++-------------------- audio/coreaudio.c | 10 +-- audio/dsoundaudio.c | 11 +-- audio/noaudio.c | 16 ++--- audio/ossaudio.c | 45 ++++++------ audio/paaudio.c | 44 ++++++------ audio/sdlaudio.c | 20 +++--- audio/spiceaudio.c | 12 ++-- audio/wavaudio.c | 8 +-- replay/replay-audio.c | 16 ++--- replay/replay.c | 2 +- 18 files changed, 212 insertions(+), 213 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index 4a95758516..2db27bba7b 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -112,7 +112,7 @@ SWVoiceOut *AUD_open_out ( ); =20 void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw); -int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size); +size_t AUD_write (SWVoiceOut *sw, void *pcm_buf, size_t size); int AUD_get_buffer_size_out (SWVoiceOut *sw); void AUD_set_active_out (SWVoiceOut *sw, int on); int AUD_is_active_out (SWVoiceOut *sw); @@ -133,7 +133,7 @@ SWVoiceIn *AUD_open_in ( ); =20 void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw); -int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size); +size_t AUD_read (SWVoiceIn *sw, void *pcm_buf, size_t size); void AUD_set_active_in (SWVoiceIn *sw, int on); int AUD_is_active_in (SWVoiceIn *sw); =20 diff --git a/audio/audio_int.h b/audio/audio_int.h index 003b7ab8cc..a674c5374a 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -61,12 +61,12 @@ typedef struct HWVoiceOut { =20 f_sample *clip; =20 - int rpos; + size_t rpos; uint64_t ts_helper; =20 struct st_sample *mix_buf; =20 - int samples; + size_t samples; QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head; QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head; int ctl_caps; @@ -82,13 +82,13 @@ typedef struct HWVoiceIn { =20 t_sample *conv; =20 - int wpos; - int total_samples_captured; + size_t wpos; + size_t total_samples_captured; uint64_t ts_helper; =20 struct st_sample *conv_buf; =20 - int samples; + size_t samples; QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head; int ctl_caps; struct audio_pcm_ops *pcm_ops; @@ -103,7 +103,7 @@ struct SWVoiceOut { int64_t ratio; struct st_sample *buf; void *rate; - int total_hw_samples_mixed; + size_t total_hw_samples_mixed; int active; int empty; HWVoiceOut *hw; @@ -120,7 +120,7 @@ struct SWVoiceIn { struct audio_pcm_info info; int64_t ratio; void *rate; - int total_hw_samples_acquired; + size_t total_hw_samples_acquired; struct st_sample *buf; f_sample *clip; HWVoiceIn *hw; @@ -149,12 +149,12 @@ struct audio_driver { struct audio_pcm_ops { int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opa= que); void (*fini_out)(HWVoiceOut *hw); - int (*run_out) (HWVoiceOut *hw, int live); + size_t (*run_out)(HWVoiceOut *hw, size_t live); int (*ctl_out) (HWVoiceOut *hw, int cmd, ...); =20 int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaq= ue); void (*fini_in) (HWVoiceIn *hw); - int (*run_in) (HWVoiceIn *hw); + size_t (*run_in)(HWVoiceIn *hw); int (*ctl_in) (HWVoiceIn *hw, int cmd, ...); }; =20 @@ -208,10 +208,10 @@ audio_driver *audio_driver_lookup(const char *name); void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings = *as); void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len); =20 -int audio_pcm_hw_get_live_in (HWVoiceIn *hw); +size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw); =20 -int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, - int live, int pending); +size_t audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, + size_t live, size_t pending); =20 int audio_bug (const char *funcname, int cond); void *audio_calloc (const char *funcname, int nmemb, size_t size); @@ -224,7 +224,7 @@ void audio_run(AudioState *s, const char *msg); =20 #define VOICE_VOLUME_CAP (1 << VOICE_VOLUME) =20 -static inline int audio_ring_dist (int dst, int src, int len) +static inline size_t audio_ring_dist(size_t dst, size_t src, size_t len) { return (dst >=3D src) ? (dst - src) : (len - src + dst); } diff --git a/audio/audio_template.h b/audio/audio_template.h index 54f07338e7..2562bf5f00 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -75,16 +75,16 @@ static void glue (audio_pcm_hw_free_resources_, TYPE) (= HW *hw) HWBUF =3D NULL; } =20 -static int glue (audio_pcm_hw_alloc_resources_, TYPE) (HW *hw) +static bool glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw) { HWBUF =3D audio_calloc(__func__, hw->samples, sizeof(struct st_sample)= ); if (!HWBUF) { - dolog ("Could not allocate " NAME " buffer (%d samples)\n", - hw->samples); - return -1; + dolog("Could not allocate " NAME " buffer (%zu samples)\n", + hw->samples); + return false; } =20 - return 0; + return true; } =20 static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw) @@ -265,7 +265,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState= *s, } =20 if (audio_bug(__func__, hw->samples <=3D 0)) { - dolog ("hw->samples=3D%d\n", hw->samples); + dolog("hw->samples=3D%zd\n", hw->samples); goto err1; } =20 @@ -279,7 +279,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState= *s, [hw->info.swap_endianness] [audio_bits_to_index (hw->info.bits)]; =20 - if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) { + if (!glue(audio_pcm_hw_alloc_resources_, TYPE)(hw)) { goto err1; } =20 diff --git a/audio/mixeng.h b/audio/mixeng.h index b53a5ef99a..18e62c7c49 100644 --- a/audio/mixeng.h +++ b/audio/mixeng.h @@ -33,6 +33,7 @@ struct st_sample { mixeng_real l; mixeng_real r; }; struct mixeng_volume { int mute; int64_t r; int64_t l; }; struct st_sample { int64_t l; int64_t r; }; #endif +typedef struct st_sample st_sample; =20 typedef void (t_sample) (struct st_sample *dst, const void *src, int sampl= es); typedef void (f_sample) (void *dst, const struct st_sample *src, int sampl= es); @@ -41,10 +42,10 @@ extern t_sample *mixeng_conv[2][2][2][3]; extern f_sample *mixeng_clip[2][2][2][3]; =20 void *st_rate_start (int inrate, int outrate); -void st_rate_flow (void *opaque, struct st_sample *ibuf, struct st_sample = *obuf, - int *isamp, int *osamp); -void st_rate_flow_mix (void *opaque, struct st_sample *ibuf, struct st_sam= ple *obuf, - int *isamp, int *osamp); +void st_rate_flow(void *opaque, st_sample *ibuf, st_sample *obuf, + size_t *isamp, size_t *osamp); +void st_rate_flow_mix(void *opaque, st_sample *ibuf, st_sample *obuf, + size_t *isamp, size_t *osamp); void st_rate_stop (void *opaque); void mixeng_clear (struct st_sample *buf, int len); void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *= vol); diff --git a/audio/rate_template.h b/audio/rate_template.h index 6e93588877..f94c940c61 100644 --- a/audio/rate_template.h +++ b/audio/rate_template.h @@ -28,7 +28,7 @@ * Return number of samples processed. */ void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf, - int *isamp, int *osamp) + size_t *isamp, size_t *osamp) { struct rate *rate =3D opaque; struct st_sample *istart, *iend; diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index 3a7c58e423..5c0a91e44f 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -179,9 +179,9 @@ void replay_net_packet_event(ReplayNetState *rns, unsig= ned flags, /* Audio */ =20 /*! Saves/restores number of played samples of audio out operation. */ -void replay_audio_out(int *played); +void replay_audio_out(size_t *played); /*! Saves/restores recorded samples of audio in operation. */ -void replay_audio_in(int *recorded, void *samples, int *wpos, int size); +void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t= size); =20 /* VM state operations */ =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index e9e3a4819c..591344dccd 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -681,10 +681,10 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) } } =20 -static int alsa_run_out (HWVoiceOut *hw, int live) +static size_t alsa_run_out(HWVoiceOut *hw, size_t live) { ALSAVoiceOut *alsa =3D (ALSAVoiceOut *) hw; - int decr; + size_t decr; snd_pcm_sframes_t avail; =20 avail =3D alsa_get_avail (alsa->handle); @@ -739,8 +739,8 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as, =20 alsa->pcm_buf =3D audio_calloc(__func__, obt.samples, 1 << hw->info.sh= ift); if (!alsa->pcm_buf) { - dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\= n", - hw->samples, 1 << hw->info.shift); + dolog("Could not allocate DAC buffer (%zu samples, each %d bytes)\= n", + hw->samples, 1 << hw->info.shift); alsa_anal_close1 (&handle); return -1; } @@ -841,8 +841,8 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) =20 alsa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.sh= ift); if (!alsa->pcm_buf) { - dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\= n", - hw->samples, 1 << hw->info.shift); + dolog("Could not allocate ADC buffer (%zu samples, each %d bytes)\= n", + hw->samples, 1 << hw->info.shift); alsa_anal_close1 (&handle); return -1; } @@ -863,17 +863,17 @@ static void alsa_fini_in (HWVoiceIn *hw) alsa->pcm_buf =3D NULL; } =20 -static int alsa_run_in (HWVoiceIn *hw) +static size_t alsa_run_in(HWVoiceIn *hw) { ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; int hwshift =3D hw->info.shift; int i; - int live =3D audio_pcm_hw_get_live_in (hw); - int dead =3D hw->samples - live; - int decr; + size_t live =3D audio_pcm_hw_get_live_in (hw); + size_t dead =3D hw->samples - live; + size_t decr; struct { - int add; - int len; + size_t add; + size_t len; } bufs[2] =3D { { .add =3D hw->wpos, .len =3D 0 }, { .add =3D 0, .len =3D 0 } @@ -913,7 +913,7 @@ static int alsa_run_in (HWVoiceIn *hw) } } =20 - decr =3D MIN (dead, avail); + decr =3D MIN(dead, avail); if (!decr) { return 0; } diff --git a/audio/audio.c b/audio/audio.c index 254499dfa1..d3c639211d 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -526,10 +526,10 @@ static int audio_attach_capture (HWVoiceOut *hw) /* * Hard voice (capture) */ -static int audio_pcm_hw_find_min_in (HWVoiceIn *hw) +static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw) { SWVoiceIn *sw; - int m =3D hw->total_samples_captured; + size_t m =3D hw->total_samples_captured; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active) { @@ -539,28 +539,28 @@ static int audio_pcm_hw_find_min_in (HWVoiceIn *hw) return m; } =20 -int audio_pcm_hw_get_live_in (HWVoiceIn *hw) +size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) { - int live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in (hw= ); - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + size_t live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in = (hw); + if (audio_bug(__func__, live > hw->samples)) { + dolog("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } return live; } =20 -int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, - int live, int pending) +size_t audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, + size_t live, size_t pending) { - int left =3D hw->samples - pending; - int len =3D MIN (left, live); - int clipped =3D 0; + size_t left =3D hw->samples - pending; + size_t len =3D MIN (left, live); + size_t clipped =3D 0; =20 while (len) { struct st_sample *src =3D hw->mix_buf + hw->rpos; uint8_t *dst =3D advance (pcm_buf, hw->rpos << hw->info.shift); - int samples_till_end_of_buf =3D hw->samples - hw->rpos; - int samples_to_clip =3D MIN (len, samples_till_end_of_buf); + size_t samples_till_end_of_buf =3D hw->samples - hw->rpos; + size_t samples_to_clip =3D MIN (len, samples_till_end_of_buf); =20 hw->clip (dst, src, samples_to_clip); =20 @@ -574,14 +574,14 @@ int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_= buf, /* * Soft voice (capture) */ -static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw) +static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) { HWVoiceIn *hw =3D sw->hw; - int live =3D hw->total_samples_captured - sw->total_hw_samples_acquire= d; - int rpos; + ssize_t live =3D hw->total_samples_captured - sw->total_hw_samples_acq= uired; + ssize_t rpos; =20 if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + dolog("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } =20 @@ -594,17 +594,17 @@ static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw) } } =20 -static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size) +static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) { HWVoiceIn *hw =3D sw->hw; - int samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D 0; + size_t samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D = 0; struct st_sample *src, *dst =3D sw->buf; =20 rpos =3D audio_pcm_sw_get_rpos_in (sw) % hw->samples; =20 live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live_in=3D%d hw->samples=3D%d\n", live, hw->samples); + if (audio_bug(__func__, live > hw->samples)) { + dolog("live_in=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } =20 @@ -618,9 +618,9 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, = int size) =20 while (swlim) { src =3D hw->conv_buf + rpos; - isamp =3D hw->wpos - rpos; - /* XXX: <=3D ? */ - if (isamp <=3D 0) { + if (hw->wpos > rpos) { + isamp =3D hw->wpos - rpos; + } else { isamp =3D hw->samples - rpos; } =20 @@ -629,11 +629,6 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf,= int size) } osamp =3D swlim; =20 - if (audio_bug(__func__, osamp < 0)) { - dolog ("osamp=3D%d\n", osamp); - return 0; - } - st_rate_flow (sw->rate, src, dst, &isamp, &osamp); swlim -=3D osamp; rpos =3D (rpos + isamp) % hw->samples; @@ -654,10 +649,10 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf= , int size) /* * Hard voice (playback) */ -static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep) +static size_t audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep) { SWVoiceOut *sw; - int m =3D INT_MAX; + size_t m =3D SIZE_MAX; int nb_live =3D 0; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { @@ -671,9 +666,9 @@ static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, i= nt *nb_livep) return m; } =20 -static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live) +static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live) { - int smin; + size_t smin; int nb_live1; =20 smin =3D audio_pcm_hw_find_min_out (hw, &nb_live1); @@ -682,10 +677,10 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw,= int *nb_live) } =20 if (nb_live1) { - int live =3D smin; + size_t live =3D smin; =20 - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + if (audio_bug(__func__, live > hw->samples)) { + dolog("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } return live; @@ -696,10 +691,10 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw,= int *nb_live) /* * Soft voice (playback) */ -static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf, int size) +static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) { - int hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, b= lck; - int ret =3D 0, pos =3D 0, total =3D 0; + size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim= , blck; + size_t ret =3D 0, pos =3D 0, total =3D 0; =20 if (!sw) { return size; @@ -708,8 +703,8 @@ static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf= , int size) hwsamples =3D sw->hw->samples; =20 live =3D sw->total_hw_samples_mixed; - if (audio_bug(__func__, live < 0 || live > hwsamples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hwsamples); + if (audio_bug(__func__, live > hwsamples)) { + dolog("live=3D%zu hw->samples=3D%zu\n", live, hwsamples); return 0; } =20 @@ -763,7 +758,7 @@ static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf= , int size) =20 #ifdef DEBUG_OUT dolog ( - "%s: write size %d ret %d total sw %d\n", + "%s: write size %zu ret %zu total sw %zu\n", SW_NAME (sw), size >> sw->info.shift, ret, @@ -842,7 +837,7 @@ static void audio_timer (void *opaque) /* * Public API */ -int AUD_write (SWVoiceOut *sw, void *buf, int size) +size_t AUD_write(SWVoiceOut *sw, void *buf, size_t size) { if (!sw) { /* XXX: Consider options */ @@ -857,7 +852,7 @@ int AUD_write (SWVoiceOut *sw, void *buf, int size) return audio_pcm_sw_write(sw, buf, size); } =20 -int AUD_read (SWVoiceIn *sw, void *buf, int size) +size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size) { if (!sw) { /* XXX: Consider options */ @@ -966,17 +961,17 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) } } =20 -static int audio_get_avail (SWVoiceIn *sw) +static size_t audio_get_avail (SWVoiceIn *sw) { - int live; + size_t live; =20 if (!sw) { return 0; } =20 live =3D sw->hw->total_samples_captured - sw->total_hw_samples_acquire= d; - if (audio_bug(__func__, live < 0 || live > sw->hw->samples)) { - dolog ("live=3D%d sw->hw->samples=3D%d\n", live, sw->hw->samples); + if (audio_bug(__func__, live > sw->hw->samples)) { + dolog("live=3D%zu sw->hw->samples=3D%zu\n", live, sw->hw->samples); return 0; } =20 @@ -989,9 +984,9 @@ static int audio_get_avail (SWVoiceIn *sw) return (((int64_t) live << 32) / sw->ratio) << sw->info.shift; } =20 -static int audio_get_free (SWVoiceOut *sw) +static size_t audio_get_free(SWVoiceOut *sw) { - int live, dead; + size_t live, dead; =20 if (!sw) { return 0; @@ -999,8 +994,8 @@ static int audio_get_free (SWVoiceOut *sw) =20 live =3D sw->total_hw_samples_mixed; =20 - if (audio_bug(__func__, live < 0 || live > sw->hw->samples)) { - dolog ("live=3D%d sw->hw->samples=3D%d\n", live, sw->hw->samples); + if (audio_bug(__func__, live > sw->hw->samples)) { + dolog("live=3D%zu sw->hw->samples=3D%zu\n", live, sw->hw->samples); return 0; } =20 @@ -1015,9 +1010,10 @@ static int audio_get_free (SWVoiceOut *sw) return (((int64_t) dead << 32) / sw->ratio) << sw->info.shift; } =20 -static void audio_capture_mix_and_clear (HWVoiceOut *hw, int rpos, int sam= ples) +static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos, + size_t samples) { - int n; + size_t n; =20 if (hw->enabled) { SWVoiceCap *sc; @@ -1028,17 +1024,17 @@ static void audio_capture_mix_and_clear (HWVoiceOut= *hw, int rpos, int samples) =20 n =3D samples; while (n) { - int till_end_of_hw =3D hw->samples - rpos2; - int to_write =3D MIN (till_end_of_hw, n); - int bytes =3D to_write << hw->info.shift; - int written; + size_t till_end_of_hw =3D hw->samples - rpos2; + size_t to_write =3D MIN(till_end_of_hw, n); + size_t bytes =3D to_write << hw->info.shift; + size_t written; =20 sw->buf =3D hw->mix_buf + rpos2; written =3D audio_pcm_sw_write (sw, NULL, bytes); if (written - bytes) { - dolog ("Could not mix %d bytes into a capture " - "buffer, mixed %d\n", - bytes, written); + dolog("Could not mix %zu bytes into a capture " + "buffer, mixed %zu\n", + bytes, written); break; } n -=3D to_write; @@ -1047,9 +1043,9 @@ static void audio_capture_mix_and_clear (HWVoiceOut *= hw, int rpos, int samples) } } =20 - n =3D MIN (samples, hw->samples - rpos); - mixeng_clear (hw->mix_buf + rpos, n); - mixeng_clear (hw->mix_buf, samples - n); + n =3D MIN(samples, hw->samples - rpos); + mixeng_clear(hw->mix_buf + rpos, n); + mixeng_clear(hw->mix_buf, samples - n); } =20 static void audio_run_out (AudioState *s) @@ -1058,16 +1054,16 @@ static void audio_run_out (AudioState *s) SWVoiceOut *sw; =20 while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { - int played; - int live, free, nb_live, cleanup_required, prev_rpos; + size_t played, live, prev_rpos, free; + int nb_live, cleanup_required; =20 live =3D audio_pcm_hw_get_live_out (hw, &nb_live); if (!nb_live) { live =3D 0; } =20 - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + if (audio_bug(__func__, live > hw->samples)) { + dolog ("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); continue; } =20 @@ -1102,13 +1098,13 @@ static void audio_run_out (AudioState *s) played =3D hw->pcm_ops->run_out (hw, live); replay_audio_out(&played); if (audio_bug(__func__, hw->rpos >=3D hw->samples)) { - dolog ("hw->rpos=3D%d hw->samples=3D%d played=3D%d\n", - hw->rpos, hw->samples, played); + dolog("hw->rpos=3D%zu hw->samples=3D%zu played=3D%zu\n", + hw->rpos, hw->samples, played); hw->rpos =3D 0; } =20 #ifdef DEBUG_OUT - dolog ("played=3D%d\n", played); + dolog("played=3D%zu\n", played); #endif =20 if (played) { @@ -1123,8 +1119,8 @@ static void audio_run_out (AudioState *s) } =20 if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) { - dolog ("played=3D%d sw->total_hw_samples_mixed=3D%d\n", - played, sw->total_hw_samples_mixed); + dolog("played=3D%zu sw->total_hw_samples_mixed=3D%zu\n", + played, sw->total_hw_samples_mixed); played =3D sw->total_hw_samples_mixed; } =20 @@ -1164,7 +1160,7 @@ static void audio_run_in (AudioState *s) =20 while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { SWVoiceIn *sw; - int captured =3D 0, min; + size_t captured =3D 0, min; =20 if (replay_mode !=3D REPLAY_MODE_PLAY) { captured =3D hw->pcm_ops->run_in(hw); @@ -1179,7 +1175,7 @@ static void audio_run_in (AudioState *s) sw->total_hw_samples_acquired -=3D min; =20 if (sw->active) { - int avail; + size_t avail; =20 avail =3D audio_get_avail (sw); if (avail > 0) { @@ -1195,15 +1191,15 @@ static void audio_run_capture (AudioState *s) CaptureVoiceOut *cap; =20 for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { - int live, rpos, captured; + size_t live, rpos, captured; HWVoiceOut *hw =3D &cap->hw; SWVoiceOut *sw; =20 captured =3D live =3D audio_pcm_hw_get_live_out (hw, NULL); rpos =3D hw->rpos; while (live) { - int left =3D hw->samples - rpos; - int to_capture =3D MIN (live, left); + size_t left =3D hw->samples - rpos; + size_t to_capture =3D MIN(live, left); struct st_sample *src; struct capture_callback *cb; =20 @@ -1226,8 +1222,8 @@ static void audio_run_capture (AudioState *s) } =20 if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)= ) { - dolog ("captured=3D%d sw->total_hw_samples_mixed=3D%d\n", - captured, sw->total_hw_samples_mixed); + dolog("captured=3D%zu sw->total_hw_samples_mixed=3D%zu\n", + captured, sw->total_hw_samples_mixed); captured =3D sw->total_hw_samples_mixed; } =20 diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 091fe84a34..d1be58b40a 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -43,9 +43,9 @@ typedef struct coreaudioVoiceOut { UInt32 audioDevicePropertyBufferFrameSize; AudioStreamBasicDescription outputStreamBasicDescription; AudioDeviceIOProcID ioprocid; - int live; - int decr; - int rpos; + size_t live; + size_t decr; + size_t rpos; } coreaudioVoiceOut; =20 #if MAC_OS_X_VERSION_MAX_ALLOWED >=3D MAC_OS_X_VERSION_10_6 @@ -397,9 +397,9 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, c= onst char *fn_name) return 0; } =20 -static int coreaudio_run_out (HWVoiceOut *hw, int live) +static size_t coreaudio_run_out(HWVoiceOut *hw, size_t live) { - int decr; + size_t decr; coreaudioVoiceOut *core =3D (coreaudioVoiceOut *) hw; =20 if (coreaudio_lock (core, "coreaudio_run_out")) { diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 11594c3095..67aa1d0ad5 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -454,19 +454,20 @@ static int dsound_ctl_out (HWVoiceOut *hw, int cmd, .= ..) return 0; } =20 -static int dsound_run_out (HWVoiceOut *hw, int live) +static size_t dsound_run_out(HWVoiceOut *hw, size_t live) { int err; HRESULT hr; DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; - int len, hwshift; + size_t len; + int hwshift; DWORD blen1, blen2; DWORD len1, len2; DWORD decr; DWORD wpos, ppos, old_pos; LPVOID p1, p2; - int bufsize; + size_t bufsize; dsound *s =3D ds->s; AudiodevDsoundOptions *dso =3D &s->dev->u.dsound; =20 @@ -640,13 +641,13 @@ static int dsound_ctl_in (HWVoiceIn *hw, int cmd, ...) return 0; } =20 -static int dsound_run_in (HWVoiceIn *hw) +static size_t dsound_run_in(HWVoiceIn *hw) { int err; HRESULT hr; DSoundVoiceIn *ds =3D (DSoundVoiceIn *) hw; LPDIRECTSOUNDCAPTUREBUFFER dscb =3D ds->dsound_capture_buffer; - int live, len, dead; + size_t live, len, dead; DWORD blen1, blen2; DWORD len1, len2; DWORD decr; diff --git a/audio/noaudio.c b/audio/noaudio.c index cbb02d9e49..0fb2629cf2 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -41,10 +41,10 @@ typedef struct NoVoiceIn { int64_t old_ticks; } NoVoiceIn; =20 -static int no_run_out (HWVoiceOut *hw, int live) +static size_t no_run_out(HWVoiceOut *hw, size_t live) { NoVoiceOut *no =3D (NoVoiceOut *) hw; - int decr, samples; + size_t decr, samples; int64_t now; int64_t ticks; int64_t bytes; @@ -52,7 +52,7 @@ static int no_run_out (HWVoiceOut *hw, int live) now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ticks =3D now - no->old_ticks; bytes =3D muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_S= ECOND); - bytes =3D MIN(bytes, INT_MAX); + bytes =3D MIN(bytes, SIZE_MAX); samples =3D bytes >> hw->info.shift; =20 no->old_ticks =3D now; @@ -92,12 +92,12 @@ static void no_fini_in (HWVoiceIn *hw) (void) hw; } =20 -static int no_run_in (HWVoiceIn *hw) +static size_t no_run_in(HWVoiceIn *hw) { NoVoiceIn *no =3D (NoVoiceIn *) hw; - int live =3D audio_pcm_hw_get_live_in (hw); - int dead =3D hw->samples - live; - int samples =3D 0; + size_t live =3D audio_pcm_hw_get_live_in(hw); + size_t dead =3D hw->samples - live; + size_t samples =3D 0; =20 if (dead) { int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); @@ -106,7 +106,7 @@ static int no_run_in (HWVoiceIn *hw) muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SEC= OND); =20 no->old_ticks =3D now; - bytes =3D MIN (bytes, INT_MAX); + bytes =3D MIN (bytes, SIZE_MAX); samples =3D bytes >> hw->info.shift; samples =3D MIN (samples, dead); } diff --git a/audio/ossaudio.c b/audio/ossaudio.c index b99edbec17..1696933688 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -411,13 +411,14 @@ static void oss_write_pending (OSSVoiceOut *oss) } } =20 -static int oss_run_out (HWVoiceOut *hw, int live) +static size_t oss_run_out(HWVoiceOut *hw, size_t live) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; - int err, decr; + int err; + size_t decr; struct audio_buf_info abinfo; struct count_info cntinfo; - int bufsize; + size_t bufsize; =20 bufsize =3D hw->samples << hw->info.shift; =20 @@ -476,8 +477,8 @@ static void oss_fini_out (HWVoiceOut *hw) if (oss->mmapped) { err =3D munmap (oss->pcm_buf, hw->samples << hw->info.shift); if (err) { - oss_logerr (errno, "Failed to unmap buffer %p, size %d\n", - oss->pcm_buf, hw->samples << hw->info.shift); + oss_logerr(errno, "Failed to unmap buffer %p, size %zu\n", + oss->pcm_buf, hw->samples << hw->info.shift); } } else { @@ -543,8 +544,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, 0 ); if (oss->pcm_buf =3D=3D MAP_FAILED) { - oss_logerr (errno, "Failed to map %d bytes of DAC\n", - hw->samples << hw->info.shift); + oss_logerr(errno, "Failed to map %zu bytes of DAC\n", + hw->samples << hw->info.shift); } else { int err; @@ -568,8 +569,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, if (!oss->mmapped) { err =3D munmap (oss->pcm_buf, hw->samples << hw->info.shif= t); if (err) { - oss_logerr (errno, "Failed to unmap buffer %p size %d\= n", - oss->pcm_buf, hw->samples << hw->info.shif= t); + oss_logerr(errno, "Failed to unmap buffer %p size %zu\= n", + oss->pcm_buf, hw->samples << hw->info.shift= ); } } } @@ -581,7 +582,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, 1 << hw->info.shift); if (!oss->pcm_buf) { dolog ( - "Could not allocate DAC buffer (%d samples, each %d bytes)= \n", + "Could not allocate DAC buffer (%zu samples, each %d bytes= )\n", hw->samples, 1 << hw->info.shift ); @@ -693,8 +694,8 @@ static int oss_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) hw->samples =3D (obt.nfrags * obt.fragsize) >> hw->info.shift; oss->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shi= ft); if (!oss->pcm_buf) { - dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\= n", - hw->samples, 1 << hw->info.shift); + dolog("Could not allocate ADC buffer (%zu samples, each %d bytes)\= n", + hw->samples, 1 << hw->info.shift); oss_anal_close (&fd); return -1; } @@ -714,17 +715,17 @@ static void oss_fini_in (HWVoiceIn *hw) oss->pcm_buf =3D NULL; } =20 -static int oss_run_in (HWVoiceIn *hw) +static size_t oss_run_in(HWVoiceIn *hw) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; int hwshift =3D hw->info.shift; int i; - int live =3D audio_pcm_hw_get_live_in (hw); - int dead =3D hw->samples - live; + size_t live =3D audio_pcm_hw_get_live_in (hw); + size_t dead =3D hw->samples - live; size_t read_samples =3D 0; struct { - int add; - int len; + size_t add; + size_t len; } bufs[2] =3D { { .add =3D hw->wpos, .len =3D 0 }, { .add =3D 0, .len =3D 0 } @@ -751,9 +752,9 @@ static int oss_run_in (HWVoiceIn *hw) =20 if (nread > 0) { if (nread & hw->info.align) { - dolog ("warning: Misaligned read %zd (requested %d), " - "alignment %d\n", nread, bufs[i].add << hwshift, - hw->info.align + 1); + dolog("warning: Misaligned read %zd (requested %zu), " + "alignment %d\n", nread, bufs[i].add << hwshift, + hw->info.align + 1); } read_samples +=3D nread >> hwshift; hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift); @@ -766,9 +767,9 @@ static int oss_run_in (HWVoiceIn *hw) case EAGAIN: break; default: - oss_logerr ( + oss_logerr( errno, - "Failed to read %d bytes of audio (to %p)\n", + "Failed to read %zu bytes of audio (to %p)\n", bufs[i].len, p ); break; diff --git a/audio/paaudio.c b/audio/paaudio.c index efb72ced30..bfef9acaad 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -30,30 +30,30 @@ typedef struct { =20 typedef struct { HWVoiceOut hw; - int done; - int live; - int decr; - int rpos; + size_t done; + size_t live; + size_t decr; + size_t rpos; pa_stream *stream; void *pcm_buf; struct audio_pt pt; paaudio *g; - int samples; + size_t samples; } PAVoiceOut; =20 typedef struct { HWVoiceIn hw; - int done; - int dead; - int incr; - int wpos; + size_t done; + size_t dead; + size_t incr; + size_t wpos; pa_stream *stream; void *pcm_buf; struct audio_pt pt; const void *read_data; size_t read_index, read_length; paaudio *g; - int samples; + size_t samples; } PAVoiceIn; =20 static void qpa_conn_fini(PAConnection *c); @@ -219,7 +219,7 @@ static void *qpa_thread_out (void *arg) } =20 for (;;) { - int decr, to_mix, rpos; + size_t decr, to_mix, rpos; =20 for (;;) { if (pa->done) { @@ -244,7 +244,7 @@ static void *qpa_thread_out (void *arg) =20 while (to_mix) { int error; - int chunk =3D MIN (to_mix, hw->samples - rpos); + size_t chunk =3D MIN (to_mix, hw->samples - rpos); struct st_sample *src =3D hw->mix_buf + rpos; =20 hw->clip (pa->pcm_buf, src, chunk); @@ -273,9 +273,9 @@ static void *qpa_thread_out (void *arg) return NULL; } =20 -static int qpa_run_out (HWVoiceOut *hw, int live) +static size_t qpa_run_out(HWVoiceOut *hw, size_t live) { - int decr; + size_t decr; PAVoiceOut *pa =3D (PAVoiceOut *) hw; =20 if (audio_pt_lock(&pa->pt, __func__)) { @@ -306,7 +306,7 @@ static void *qpa_thread_in (void *arg) } =20 for (;;) { - int incr, to_grab, wpos; + size_t incr, to_grab, wpos; =20 for (;;) { if (pa->done) { @@ -331,7 +331,7 @@ static void *qpa_thread_in (void *arg) =20 while (to_grab) { int error; - int chunk =3D MIN (to_grab, hw->samples - wpos); + size_t chunk =3D MIN (to_grab, hw->samples - wpos); void *buf =3D advance (pa->pcm_buf, wpos); =20 if (qpa_simple_read (pa, buf, @@ -359,9 +359,9 @@ static void *qpa_thread_in (void *arg) return NULL; } =20 -static int qpa_run_in (HWVoiceIn *hw) +static size_t qpa_run_in(HWVoiceIn *hw) { - int live, incr, dead; + size_t live, incr, dead; PAVoiceIn *pa =3D (PAVoiceIn *) hw; =20 if (audio_pt_lock(&pa->pt, __func__)) { @@ -582,8 +582,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, pa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shif= t); pa->rpos =3D hw->rpos; if (!pa->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog("Could not allocate buffer (%zu bytes)\n", + hw->samples << hw->info.shift); goto fail2; } =20 @@ -650,8 +650,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) pa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shif= t); pa->wpos =3D hw->wpos; if (!pa->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog("Could not allocate buffer (%zu bytes)\n", + hw->samples << hw->info.shift); goto fail2; } =20 diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index c7fd487e0e..14b11f0335 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -41,8 +41,8 @@ =20 typedef struct SDLVoiceOut { HWVoiceOut hw; - int live; - int decr; + size_t live; + size_t decr; } SDLVoiceOut; =20 static struct SDLAudioState { @@ -184,22 +184,22 @@ static void sdl_callback (void *opaque, Uint8 *buf, i= nt len) SDLVoiceOut *sdl =3D opaque; SDLAudioState *s =3D &glob_sdl; HWVoiceOut *hw =3D &sdl->hw; - int samples =3D len >> hw->info.shift; - int to_mix, decr; + size_t samples =3D len >> hw->info.shift; + size_t to_mix, decr; =20 if (s->exit || !sdl->live) { return; } =20 - /* dolog ("in callback samples=3D%d live=3D%d\n", samples, sdl->live);= */ + /* dolog ("in callback samples=3D%zu live=3D%zu\n", samples, sdl->live= ); */ =20 to_mix =3D MIN(samples, sdl->live); decr =3D to_mix; while (to_mix) { - int chunk =3D MIN(to_mix, hw->samples - hw->rpos); + size_t chunk =3D MIN(to_mix, hw->samples - hw->rpos); struct st_sample *src =3D hw->mix_buf + hw->rpos; =20 - /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */ + /* dolog ("in callback to_mix %zu, chunk %zu\n", to_mix, chunk); */ hw->clip(buf, src, chunk); hw->rpos =3D (hw->rpos + chunk) % hw->samples; to_mix -=3D chunk; @@ -209,7 +209,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int= len) sdl->live -=3D decr; sdl->decr +=3D decr; =20 - /* dolog ("done len=3D%d\n", len); */ + /* dolog ("done len=3D%zu\n", len); */ =20 /* SDL2 does not clear the remaining buffer for us, so do it on our ow= n */ if (samples) { @@ -217,9 +217,9 @@ static void sdl_callback (void *opaque, Uint8 *buf, int= len) } } =20 -static int sdl_run_out (HWVoiceOut *hw, int live) +static size_t sdl_run_out(HWVoiceOut *hw, size_t live) { - int decr; + size_t decr; SDLVoiceOut *sdl =3D (SDLVoiceOut *) hw; =20 SDL_LockAudio(); diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6e7f13cffa..d9db1a39e6 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -153,11 +153,11 @@ static void line_out_fini (HWVoiceOut *hw) spice_server_remove_interface (&out->sin.base); } =20 -static int line_out_run (HWVoiceOut *hw, int live) +static size_t line_out_run (HWVoiceOut *hw, size_t live) { SpiceVoiceOut *out =3D container_of (hw, SpiceVoiceOut, hw); - int rpos, decr; - int samples; + size_t rpos, decr; + size_t samples; =20 if (!live) { return 0; @@ -276,12 +276,12 @@ static void line_in_fini (HWVoiceIn *hw) spice_server_remove_interface (&in->sin.base); } =20 -static int line_in_run (HWVoiceIn *hw) +static size_t line_in_run(HWVoiceIn *hw) { SpiceVoiceIn *in =3D container_of (hw, SpiceVoiceIn, hw); - int num_samples; + size_t num_samples; int ready; - int len[2]; + size_t len[2]; uint64_t delta_samp; const uint32_t *samples; =20 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 17ab921cef..b6eeeb4e26 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -40,10 +40,10 @@ typedef struct WAVVoiceOut { int total_samples; } WAVVoiceOut; =20 -static int wav_run_out (HWVoiceOut *hw, int live) +static size_t wav_run_out(HWVoiceOut *hw, size_t live) { WAVVoiceOut *wav =3D (WAVVoiceOut *) hw; - int rpos, decr, samples; + size_t rpos, decr, samples; uint8_t *dst; struct st_sample *src; int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); @@ -139,8 +139,8 @@ static int wav_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, hw->samples =3D 1024; wav->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shi= ft); if (!wav->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog("Could not allocate buffer (%zu bytes)\n", + hw->samples << hw->info.shift); return -1; } =20 diff --git a/replay/replay-audio.c b/replay/replay-audio.c index b113836de4..efe1628727 100644 --- a/replay/replay-audio.c +++ b/replay/replay-audio.c @@ -16,18 +16,18 @@ #include "sysemu/sysemu.h" #include "audio/audio.h" =20 -void replay_audio_out(int *played) +void replay_audio_out(size_t *played) { if (replay_mode =3D=3D REPLAY_MODE_RECORD) { g_assert(replay_mutex_locked()); replay_save_instructions(); replay_put_event(EVENT_AUDIO_OUT); - replay_put_dword(*played); + replay_put_qword(*played); } else if (replay_mode =3D=3D REPLAY_MODE_PLAY) { g_assert(replay_mutex_locked()); replay_account_executed_instructions(); if (replay_next_event_is(EVENT_AUDIO_OUT)) { - *played =3D replay_get_dword(); + *played =3D replay_get_qword(); replay_finish_event(); } else { error_report("Missing audio out event in the replay log"); @@ -36,7 +36,7 @@ void replay_audio_out(int *played) } } =20 -void replay_audio_in(int *recorded, void *samples, int *wpos, int size) +void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t= size) { int pos; uint64_t left, right; @@ -44,8 +44,8 @@ void replay_audio_in(int *recorded, void *samples, int *w= pos, int size) g_assert(replay_mutex_locked()); replay_save_instructions(); replay_put_event(EVENT_AUDIO_IN); - replay_put_dword(*recorded); - replay_put_dword(*wpos); + replay_put_qword(*recorded); + replay_put_qword(*wpos); for (pos =3D (*wpos - *recorded + size) % size ; pos !=3D *wpos ; pos =3D (pos + 1) % size) { audio_sample_to_uint64(samples, pos, &left, &right); @@ -56,8 +56,8 @@ void replay_audio_in(int *recorded, void *samples, int *w= pos, int size) g_assert(replay_mutex_locked()); replay_account_executed_instructions(); if (replay_next_event_is(EVENT_AUDIO_IN)) { - *recorded =3D replay_get_dword(); - *wpos =3D replay_get_dword(); + *recorded =3D replay_get_qword(); + *wpos =3D replay_get_qword(); for (pos =3D (*wpos - *recorded + size) % size ; pos !=3D *wpos ; pos =3D (pos + 1) % size) { left =3D replay_get_qword(); diff --git a/replay/replay.c b/replay/replay.c index 8b172b2d1b..a1135a9943 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -22,7 +22,7 @@ =20 /* Current version of the replay mechanism. Increase it when file format changes. */ -#define REPLAY_VERSION 0xe02007 +#define REPLAY_VERSION 0xe02008 /* Size of replay log header */ #define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t)) =20 --=20 2.22.0 From nobody Mon Apr 29 01:57:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563225027; cv=none; d=zoho.com; s=zohoarc; b=l2ia9Jlmv6cfxu6phIgXLeETNSjO0X8UmQRAAkGAy9LaHOuYtaZkA6HJdxZnjoX/hX0+yKkgx5EP7fhD6CyDjyv1L0nqYXnINB/Szgd0yZOGZYtQF9rJdAqeH7cDd2lBwuE3lgnFAvqGp+bIZkZLuLrLL0YVcnzNyrqhZvfXrbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563225027; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N/mwlriTgvMl6h8mnLx3KY4L68sc0uS+YQp6dXqnv9w=; b=ZKWONXHTtnapZIDPUtNUXtowrHEhkM3OXCH/eRQ8y8eCsW9MY9La6OyydjIcSvMbUkomlEc30zrWFpgdk7QNbgPCk8mAPcOl/bpcxG5rf8N1Hf3lh276pSHzz1VqoVgWQ7cBZbZR2rGfuxKMsFIVeYyGbhREIR93uJXN5N+cWiM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563225027519169.81538615769023; Mon, 15 Jul 2019 14:10:27 -0700 (PDT) Received: from localhost ([::1]:43830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Er-0007MV-KA for importer@patchew.org; Mon, 15 Jul 2019 17:10:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42318) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8D2-0008Tc-Qz for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8D1-0004oL-UU for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:32 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8D1-0004nh-O6 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:31 -0400 Received: by mail-wm1-x342.google.com with SMTP id g67so12440895wme.1 for ; Mon, 15 Jul 2019 14:08:31 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N/mwlriTgvMl6h8mnLx3KY4L68sc0uS+YQp6dXqnv9w=; b=l1/zjX+6cHo71kRGfu8M1KZ0nMsUq1Pk3E5d8uE2DJ28bdCgIQCTnY1t2c1fjDwj9P AgL+5DCrKnqtT3oXMXVqMo8RnJ3oNKnm0fqjf66dEkMxvfQUNxh3/3MjukRTDSTPJNF5 7jSI7fD9eNWSGZURbEwBB4V6UG6zvQRzgk/uT6U/DEGCb3lXxEJe526NActVIZBh/QhZ 2saMwP13ojZZJm+U0lppQC3MaBvGunSyA4jm1Lmw2g8FY/dZAFWt+X4pku6F8RT0R3WX QBcynRDnEJSCFaPHcbO+AUUmBWdPPaWYE44NUOuoIpUUfk5D0bkPru/4knu5HeGLVv9g oLCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N/mwlriTgvMl6h8mnLx3KY4L68sc0uS+YQp6dXqnv9w=; b=ZUm55xIJiYNq4MrDsKoYTNG1HTMrgIasmj4vCP8sgPmedS4zWisl/cE2fPTEX8ckZr hAr+Cx+YC6Qbpp+N08gktq84ymVxI8X3XGZ/u+2OF07shkKYeqF6rgNhFcwkatI1nzuO iG8HLbtXk1RxeXxvKY3C76yDPWUQf718eYKsDrxPf/YkZ4oynjS1XndZgDH/ZxerpFze m7yPhrv4Qyc4OR6H09gT+6/6x41ixkxwo7YAgLBVXP16OlHGySoqy717Xsa/l9Lm5zvO 6iBeSLyWyL1m5n6IQOFYgCE9qDjmNbjrA9kwaAk6cIQpXmtH2g4F5U2MlIuDJUmNoiPH JSAA== X-Gm-Message-State: APjAAAUSBrYAjOc5iiwfFGc/yW/gbhlesgxvCOtVc0D/837aNsb5RHAB d2WqvjM2hEBtIsqazi/RtvytoAWf X-Google-Smtp-Source: APXvYqw5exBddtJb8LVPsBqTMA8+h83tBDwceNuwsF3KuR5SuXsnMjIeY4VUviaQ0G4tAGD0uNKHAg== X-Received: by 2002:a1c:7606:: with SMTP id r6mr25209377wmc.118.1563224910646; Mon, 15 Jul 2019 14:08:30 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:16 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v2 14/14] audio: fix memory leak reported by ASAN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index d3c639211d..ebe49f3ca1 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1343,6 +1343,12 @@ static void free_audio_state(AudioState *s) qapi_free_Audiodev(s->dev); s->dev =3D NULL; } + + if (s->ts) { + timer_free(s->ts); + s->ts =3D NULL; + } + g_free(s); } =20 --=20 2.22.0