From nobody Fri Apr 26 10:25:22 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=1566169827; cv=none; d=zoho.com; s=zohoarc; b=DSJfDGZGkVpZUdza1xMA2LkJp63eSSeHQUD0Iw7wiq4oS7XnbmOlt+rq8BBaqTG0fpWXXDdSGW/gxoUYFhAQGS6O/gMlMRSrQHXgOHf+YEr29KW44jLXcuJfYxQ+syoM2mZ/lXHWrRCXStboV+uGP223pHW2TxIrhWEBzsDsjw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566169827; 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=Ur1rUFP6FjDWlw/RJwJeYnHP5EBXcgT1FzEaNJ4ozGU=; b=DWrCBqsl1k9Sl6sAko1aQXX2xBFdgaCEyGWoZPT6ZUXtfuHNbne2Mj2aBS8rs4kg2T7C5AO5fCp+1S0lYzc7JIZew1IguQ2ZUO+8274f0GSB2PftpZazmo+9aKDo81VV0r//VFkfCiIsuk4HOESNiR7em/Xt9m8Aie307ZPHKoc= 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 1566169827926573.2290129983959; Sun, 18 Aug 2019 16:10:27 -0700 (PDT) Received: from localhost ([::1]:43518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUJe-0000kU-B3 for importer@patchew.org; Sun, 18 Aug 2019 19:10:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49670) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGP-0006OB-6s for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGN-0005Fd-9q for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:05 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:45775) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGN-0005E6-2E for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:03 -0400 Received: by mail-wr1-x430.google.com with SMTP id q12so6728889wrj.12 for ; Sun, 18 Aug 2019 16:07:02 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:00 -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=Ur1rUFP6FjDWlw/RJwJeYnHP5EBXcgT1FzEaNJ4ozGU=; b=UQ/ghnp8Ck+/Zu8TmtEfBv9vHJFlNG1gdJ1K5NxbmuEb6OtKC4TEqe93mQSLi5lKcU vt6r5hqKR5cY15EqxmUpJ7Jtw0hsceleTzAwG2MGKRfrA3ayum7BJYBpoWMqeQLaKDZD LXIWRj9WVUmwO58h2z/0zZhgtxlAGlrkv8RHBfpESvDzp9j//ymKWCvmjRKCzCoxCdPN MiO9tCTGjo3wlbhwkGdXSeiJ46vAb3fony2LZTVMzEqb11v9hPDixBeLjEW1VgfGSGXh axGchY/bkeCyp//7ZfydJPyJW4Y+tSB8ZS8+OoeB/BIAm4WqTCNHi+VX0fn4MaQmsAnw PEYg== 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=Ur1rUFP6FjDWlw/RJwJeYnHP5EBXcgT1FzEaNJ4ozGU=; b=h73W7JiGQnfq2MReB824R5Oy4+2exRUu6iRxrozpD+lSKg0OrQBLBzqH/xYZ+zbrgR fBiatoa21/rIS0oHRZCjTbifmBL0uVmhOSohyDHDwEHxrFAv7oT07Ie5VK2rVTQkUfK8 vHDgiQ5uFfud7EguTvvJWZF6U3xoBDS5hwcPXo2V0LPcc/vCUwfpYTqNfzZBrmym5FIq v+1xrx30GsNRL4kd/GjA4PC83odKhvbj2zT5GIX4Cu+6NANEjiAzFNsUp6aJ1Y1sKFUN RmIXzewzd9VWwmovEBrnVh2g06uSFV87nyNYmJlsacpioip/kcd9dCAoJctDtX5mZJIT /4yA== X-Gm-Message-State: APjAAAUvFZzCE8CV45sJBBPfvSuogKNdHRupnRUKVok1NqqkGIysoPzB zlEGCAp3Jy7cgZQg0Uz/m4jJaCZ/ X-Google-Smtp-Source: APXvYqyro3SUhVG2mD270hVGd+6W4GHCxRRFhUM7WOMEf1DxWU3hzOOl728UBnAD2m/wNvyhbYLobA== X-Received: by 2002:adf:8bd8:: with SMTP id w24mr23377828wra.273.1566169621197; Sun, 18 Aug 2019 16:07:01 -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, 19 Aug 2019 01:06:46 +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::430 Subject: [Qemu-devel] [PATCH v4 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 c8b88d892d..4f27e33245 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 Fri Apr 26 10:25:22 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=1566170019; cv=none; d=zoho.com; s=zohoarc; b=NX+R1pg8ACfrGAaCH7S2u2VGzjM9z1jhQ02mQgqhDgg36MZ/aexb34GlH2ioEg4AEsJrlxfl4tSHsHS8UvCyXISoarGjVLcD68G7oPPj80OZX5Vf0chWcXf9OoTQtIQVN/f9/AMMee8MBm6d9SWX91DAa0YsPbKw7zytCdh1vmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170019; 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=rLuE1VYugRIBQ6xgNLZazfJDNiMMD4SCYlxUXZPXkaU=; b=cb4AKgTJPAKcgJTmOFcu08q/7qUIuk+RmPgipQmCc3jHiFztUcuDjb6Bj9+J8yhuWpJvtLIF3f5VJyWcuvBQiY7ZhJ6DICVZPv12KWvK6ALYA/v4RyAR57I6qC1eL5sguDgMQx91aS9kE1YEjK9+JmLBgL1xrPpjfAZxgYuvQOY= 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 1566170019982842.8163872942532; Sun, 18 Aug 2019 16:13:39 -0700 (PDT) Received: from localhost ([::1]:43552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUMk-000567-EE for importer@patchew.org; Sun, 18 Aug 2019 19:13:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGP-0006OZ-G9 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGN-0005Fs-FO for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:05 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36351) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGN-0005F9-8A for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:03 -0400 Received: by mail-wr1-x441.google.com with SMTP id r3so6763837wrt.3 for ; Sun, 18 Aug 2019 16:07:03 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:01 -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=rLuE1VYugRIBQ6xgNLZazfJDNiMMD4SCYlxUXZPXkaU=; b=elbowPXGBepJbypBVQANbSyjfkCOgoq4HwiwYJnZf+ryV9JOIhcCezxhNgmOuuoG9r TUlcVPiLkk4O33Pliro5fNsIgR7WoL/CQ1oGt64nitT3novbg4bjqi/6TdCfIFxQtEoh 0sBhGI1NsUVQJamPULzUNzYeLyBQ36PNfPRnwwO8gmw+JAnZLuDozcNteGdl0M67UsOd R1HneqN1vjT1O3sef/l0gDjgKEHmkVeSP+xMYcyXNWn/LTPh4ME8mnEoRXvfbZXm3fEr b8Eey3tGfPZ8iI3gVr1eA/UNXCNzAjJozMsLO7TWvQpXhW0FP9jieRSdOEoeItt/IhpW XJPg== 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=rLuE1VYugRIBQ6xgNLZazfJDNiMMD4SCYlxUXZPXkaU=; b=UCDxvmnkGuC0G92KbOlc4BKeJRkSXKJd86qCU2BT95fE+iwSmRWr6B92fxhv+LpoaP swIEA2Wfvthw8a3goz1PgegsCPHMUOqeq5E9451bT+mmDtWy3Hv0B98OOFOFryhviKEa hqJvO2T3hAj9ORGWvJ+Ysmo42OkjwRvd18RFAyzPDjnXWeN+DnEV5gLj0yBjS59VYQM4 gK8FPX9hXEG7/AY4o93XDpesG1wesiNJT5l/hpjzWJc3q5FoRQOZLU5qKb19mTObWA+/ cAVt7BPBIaHVlVfico0XqsAljWl9xZmwvzNZtDt9lSA437nVsamSgxa/uSXS1GJcQZFY TLaA== X-Gm-Message-State: APjAAAUWpzNj1B76ROWfRl+mfPzdVIRimfhHDLupxbUR21R+ZQimAXbG iadb0tagsqIsl4qHfCvmIaV6KN1X X-Google-Smtp-Source: APXvYqyz9nasw8OB9K4I6CPYXMyvE/nETTcMR2F+lfEMxf8n5r/WX4SeqbW3kt3HRYURRRzB9wl0VA== X-Received: by 2002:adf:f286:: with SMTP id k6mr9391340wro.320.1566169622002; Sun, 18 Aug 2019 16:07:02 -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, 19 Aug 2019 01:06:47 +0200 Message-Id: <67aef54f9e729a7160fe95c465351115e392164b.1566168923.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::441 Subject: [Qemu-devel] [PATCH v4 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 4f27e33245..8e9ccd0ac4 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 493edc60e4..8d7ce2eda1 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -104,8 +104,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 { @@ -170,7 +170,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 d229e65450..6b71059739 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 4812ed29d0..ed5e8aa5f8 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1224,7 +1224,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 Fri Apr 26 10:25:22 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=1566169862; cv=none; d=zoho.com; s=zohoarc; b=DM/JWHY03JpffNC0Fd3HG77ev6uULWpuJVvJ9g4xA91W9YYFjzlC3fUtJT5/qFYUxjwRIUf7+fQKhe1xj/5LTpSe3l5SuVRzic+5vmeyjuE1yaJA9EH2+7BGQ9KC2ABcB3H8HF+7qmI79dpDPJkG0Qavu8/vcfTpkCFhac65INw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566169862; 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=QXktBjDIkU004GPPN3Dzwd8YTk78iS8o8SEmh2y6abE=; b=j+JGHpi9+yBcn1AnR6YrJFlEMsuGXlC5gdgNW/67YAAPN6LkDl+U4Q75pbTVfafTI6f/QsuHeKCE1zGj+phwapONuiO9O1yanZb7M/F/INJrhrYYZsWmtWquSI6EPubkzdSh31iKcR4xXkoGryaXCepjPYvPD7Qs95VrSt/hgNQ= 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 1566169862533795.6726268500975; Sun, 18 Aug 2019 16:11:02 -0700 (PDT) Received: from localhost ([::1]:43524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUKD-0001M2-2i for importer@patchew.org; Sun, 18 Aug 2019 19:11:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49675) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGP-0006Oq-Lx for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGO-0005GG-1k for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:05 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:56228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGN-0005Ff-Qs for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:03 -0400 Received: by mail-wm1-x344.google.com with SMTP id f72so3485wmf.5 for ; Sun, 18 Aug 2019 16:07:03 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:02 -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=QXktBjDIkU004GPPN3Dzwd8YTk78iS8o8SEmh2y6abE=; b=TSAnI6TmWwSVHa0ZK8rclNaFLqdpgAhVmsUuDktkqMDrpTFb98DRnTjU1ZdNoqRE50 ISydPtcMOjz+BZaIc9Sjdrz56tf3bTNZy5WdVnB2VmXWesPJHWWnqhZn5wy6XcIWfEup X5xC/ykPLIq6Sxw756o7kehcXpqSI9JIFNUBcIqntmkU8GFeJcRO30+M2jd0T7kOG/Dy FamC5Vkrwt/j+KYOtlhg4jxEZxlAc655qnKMlA+HcFbBfS+YIV/sc2QRurabkdh39Icg CsYOklJTHcek+juDVSb4A4rUJRTfpfRuDa6jNuUEA85wxFzd94Mkc0RoUeYuwTbeRfBA ETrQ== 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=QXktBjDIkU004GPPN3Dzwd8YTk78iS8o8SEmh2y6abE=; b=tXdoozrrQR0XwpdwwC142KBo82R5NIDnHiM3eteuZq1hm462RXw2CG5kU9PXGvRTEc PPb58FWyWraiNE/OZXg3H/U6yS0px6fi8q0oFjh7jpkY/OizBRTjQcN9DY3pTmAE/uC7 2Pd0/HqPUP3zTQh51I3dsNpjlHFX4YeYNM+2K4GzaD42GBlvmF3guZpjt6hEu6lJnRO5 YRfDiP5vxAxK7OaGEG+u5Bj10tr+RKzv3hNICl57W3/AR++JPMkVvHJVrpYTWx+YC8up zKST4ohQVBLLjepEafHP5zEU1+5Zno0ckiqtG99PsGroD5xRsKgVA+oepaq4Ykg20WHM E6yQ== X-Gm-Message-State: APjAAAUBgZuUrYAV70UdT8JuhhTlH4O4bmUOIe+XGTevVWMJbf+Jo63V HAw1Pfem/21OEZewD+sGF2U5tFDZ X-Google-Smtp-Source: APXvYqw50wn7TewekKsWI7pPt43LUxlGZyjuXJXlCn3ew8rjP+b9/EFVLFcYNLCsyWF87g9AvIUyjA== X-Received: by 2002:a1c:f20a:: with SMTP id s10mr17732870wmc.145.1566169622716; Sun, 18 Aug 2019 16:07:02 -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, 19 Aug 2019 01:06:48 +0200 Message-Id: <8cbc9e865bbf40850c14340fc0549e6ac2d5fe9c.1566168923.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::344 Subject: [Qemu-devel] [PATCH v4 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 --- Notes: Changes from v2: =20 * audiodev parameter for wavcapture is now mandatory. * removed some unnecessary qdict_haskey calls from hmp_wavcapture ui/vnc.h | 2 ++ monitor/misc.c | 22 +++++++++++----------- ui/vnc.c | 15 ++++++++++++++- hmp-commands.hx | 11 ++++++----- qemu-options.hx | 6 ++++++ 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/ui/vnc.h b/ui/vnc.h index 18f1b1d6d0..8643860967 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -182,6 +182,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 6b71059739..aef16f6cfb 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1142,21 +1142,21 @@ static void hmp_stopcapture(Monitor *mon, const QDi= ct *qdict) static void hmp_wavcapture(Monitor *mon, const QDict *qdict) { const char *path =3D qdict_get_str(qdict, "path"); - int has_freq =3D qdict_haskey(qdict, "freq"); - int freq =3D qdict_get_try_int(qdict, "freq", -1); - int has_bits =3D qdict_haskey(qdict, "bits"); - 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); + int freq =3D qdict_get_try_int(qdict, "freq", 44100); + int bits =3D qdict_get_try_int(qdict, "bits", 16); + int nchannels =3D qdict_get_try_int(qdict, "nchannels", 2); + const char *audiodev =3D qdict_get_str(qdict, "audiodev"); CaptureState *s; + AudioState *as =3D audio_state_by_name(audiodev); + + if (!as) { + monitor_printf(mon, "Audiodev '%s' not found\n", audiodev); + return; + } =20 s =3D g_malloc0 (sizeof (*s)); =20 - freq =3D has_freq ? freq : 44100; - bits =3D has_bits ? bits : 16; - nchannels =3D has_channels ? nchannels : 2; - - 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 ed5e8aa5f8..649ce93cd2 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1224,7 +1224,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"); } @@ -3371,6 +3371,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 */ } }, @@ -3808,6 +3811,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"); @@ -3993,6 +3997,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..cfcc044ce4 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -819,16 +819,17 @@ 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,audiodev:s,freq:i?,bits:i?,nchannels:i?", + .params =3D "path audiodev [frequency [bits [channels]]]", .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{audiodev} [@var{frequency} [@var{bits= } [@var{channels}]]] @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}. =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 Fri Apr 26 10:25:22 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=1566170018; cv=none; d=zoho.com; s=zohoarc; b=daIM+U2lp/pcJ65PW5kHgJvz5+rGt/tum7E1gb4xfRyhyfixHk2DbAZ4ApcSVn2jUaJe5DRI+52J2W0u0UQn2fqGDvIFtt46OBaYXkCvNVpOrMU5DCoIO4EfTMvuAFne6RYbvloxlEJzxWFCVyD22p3zpfESASU5oz0veiweUrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170018; 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=gU5nT9s78tyx9N3KqE3raJac/pdKYcuSU+V5VusGQvg=; b=U1wJTOreqVJQ3mOtZ7O/sEj4yst/E1kYlCPBjWd4Xh8flx+CPtlwsn2nlJZYpD0dNzXWexxDktw/xfarP9qRbF68bSR8FxFJkPJJj2rFfzabA0+y4LLlnX25XE+o0sY7hwXQICOPWqOLv7r4T0/QI3hnzJsy0prK2J0Mn3V1fwA= 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 1566170018803598.0811501383271; Sun, 18 Aug 2019 16:13:38 -0700 (PDT) Received: from localhost ([::1]:43550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUMj-00054S-8S for importer@patchew.org; Sun, 18 Aug 2019 19:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49695) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGR-0006Qq-04 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGP-0005Gs-1n for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:06 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:34071) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGO-0005GX-R0 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:04 -0400 Received: by mail-wm1-x344.google.com with SMTP id e8so1421101wme.1 for ; Sun, 18 Aug 2019 16:07:04 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:03 -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=gU5nT9s78tyx9N3KqE3raJac/pdKYcuSU+V5VusGQvg=; b=fPTOIAafzhbmnthmI85SCDZAGsw8y/iwZ+DZ3BH4U7AqmHMpGYcJm5/0Q1faIe+HW6 yqmGGdB5Y3OMIIVkH3pIG31t0hFQu0xBLI3ZWnKAgQ5t0sX7tcTf4Lw/heMZhcTYMksY +bOGLpjGrP6uvlLr2pXkb853U1a+crSGg4Q1Uxj0YI/Qky0kGlhttTo8kz80NaMuSRKN +0TtR1XdKSt06wjPpEb693aH+xjUY9/RQL9d4ZuE0uzKnekmv7/uNc7XbHLPwL3F6x6B y7oSsH2Jb5cDJ0dBeJhr64v2k6BVeNlaNzkfc8tN49Axb0VvU/6RAxlTngysLIVHJTD7 y67Q== 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=gU5nT9s78tyx9N3KqE3raJac/pdKYcuSU+V5VusGQvg=; b=UYVcIcdi2AG20Q2hA1KMPiQps00QAku4v5+x839rZLusBDsrd8e8aKNkqBNTHnjTNl MYvhvpPu6DrGYd6s0BVp6F1laUWs7S02NRMGjzZUs4DbgXmxjcHNdpaxSVW7W6VMh0QE P/nmrEsguDFqoN78ptbVP3EXXtzAa/WxH1dkP3PNoEFBJjMiPGAuw74fTtkUFWQnIGNc LEqrYgAa9CrWm59+BzJDgyqDMxjqKZMjyTst7fBJduXmL5PK6jCnfeGPenYVeYHfV2FR Ev7nlWymQ6zhU1BtZyRs5OEu9PeZiyVr9tSJNvTYr6eUT48+KgufmMixBQ8nIFA57pDX w3wA== X-Gm-Message-State: APjAAAXi75FEeBI56uXYR41phrS1sHtbtT8qmW2zPgZQNMYq+xuO/ZV5 8Z6LUxuog+qsK25rlG3tYwfe2p2V6iw= X-Google-Smtp-Source: APXvYqx+1H9uC5qV9a+mod99tK4yjBAVEjzqpP9jQju1AVCiNCUVewEhdBwP1tE8O0DSG+0icHqJtQ== X-Received: by 2002:a1c:f703:: with SMTP id v3mr16659636wmh.107.1566169623613; Sun, 18 Aug 2019 16:07:03 -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, 19 Aug 2019 01:06:49 +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::344 Subject: [Qemu-devel] [PATCH v4 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 --- Notes: Changes from v3: =20 * Fixed compilation error due to changes in master (#include "hw/qdev-properties.h" in audio.h) audio/audio.h | 4 +++ 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, 91 insertions(+), 1 deletion(-) diff --git a/audio/audio.h b/audio/audio.h index ad2457f4de..3257165b05 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -27,6 +27,7 @@ =20 #include "qemu/queue.h" #include "qapi/qapi-types-audio.h" +#include "hw/qdev-properties.h" =20 typedef void (*audio_callback_fn) (void *opaque, int avail); =20 @@ -181,4 +182,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 bb34a614e2..2e98dd60db 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -33,6 +33,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; @@ -234,6 +235,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 115ee51c7c..b4c0b690d7 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -1410,6 +1410,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 2f4aacbf43..64a1060b80 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 d77a4e713e..5b7baeae25 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -690,6 +690,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 39deecbbc6..88f886491b 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 dbfe7cf634..effec31d35 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -299,6 +299,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 4fee0673d9..68fe1de987 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -841,6 +841,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 481dde10a1..853b4ed874 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -330,6 +330,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); @@ -337,6 +342,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 016946d4b2..307c664725 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 ca91399078..c30417d46d 100644 --- a/hw/audio/pl041.c +++ b/hw/audio/pl041.c @@ -625,6 +625,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 3ad01f3599..7e50ab8a84 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1422,6 +1422,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 9f6df5d59c..a8725abf6a 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -702,6 +702,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); @@ -712,6 +717,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 fceab9afd5..70bfd4809b 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-properties.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 d3ca3bd1ab..ae42e5a2f1 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -667,6 +667,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 Fri Apr 26 10:25:22 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=1566170176; cv=none; d=zoho.com; s=zohoarc; b=G6Yn7qtx6tRyns3xq2wELrrNOlRsbfrnitIG9x7OUjiNHpOd5RCWpz2rKlRjddRUFHgF8MHC486IuVnNA9nvjc7B1hc5kfc5qsBdO9cY3h0pGTHlT4Suj7Mvs2ViwwAke9odY5EhJI4XNo1DtyauC7qP5zIT4F+XoF6HLNm8Of4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170176; 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=hDetD+rBKzFYXeehd3Z1O35q4Xt+CIVltZF12VAzii+30vxEqxjuGYFnxqlPRmEACGiqdOEWZfe8yFsH/svJsbPK0j45vGdbV17/dIz0fYViUNP8L/xyyMCoAngNvyh5OVNG5pgCTtB32+lL9CKHoH/CxSOAmwnceQdqesHIqDc= 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 1566170176599598.99197449707; Sun, 18 Aug 2019 16:16:16 -0700 (PDT) Received: from localhost ([::1]:43580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUP7-00087L-Or for importer@patchew.org; Sun, 18 Aug 2019 19:16:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49717) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGS-0006T6-C9 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGQ-0005Hs-2M for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:08 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:51557) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGP-0005Gz-PM for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:06 -0400 Received: by mail-wm1-x342.google.com with SMTP id 207so11353wma.1 for ; Sun, 18 Aug 2019 16:07:05 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:03 -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=Zzdp7ej3/c2hbY+ECxe4WA60jPIy4S+lgCfjeGv31bn9QnhGVCmdRtsULhFkovF8dQ aEkMJq9eU1euoI/PsN34ZP1F42QaGsr3eg3SgnFzaD2lXdbzuyeggFihf3chqguTns65 ESHmNVZza2JEJ+vNHMDGcEhzAbomSIw/HrDHolMzEztXJA8ztin9uQaCF5o7bKR5mext LWYQ8mIOMHcb3gZ2EaQzFlaPgd8s9zgKJHgw7jb+5mjhaZ6JVx/yiSH6xjmr8fHn210L jC9xkm6+4MZVtA/XwQHMoLxgZ6FmQUDITHsgZ3mCpD/luzpYVm2h4lIyCK0IhFnhVxXG UzjA== 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=LxQxCB5mHDep595DQhX3viCn6x7G9L8vKHQCSk9Z6YqXfnAs5FCS9wt6u//ma8+j25 7FGtmjF66mIWjIu6f3v7kszHxcPcee+oOKRv/5QXDsphhphxFlWFc72tBwgbJROrhWIk fdqXnpFTNQKITuwDjhocbf9jR2HkhBZiclzhvDWDHVJRFiVXKCyZ0zqtK//MSgH1WeL5 hjBt13DEAZnJzDowhhghEzDjiWAPblgv2OePKHsUp0NrfyI360E+03YZnm/hBOc0jcwE vAHf44CXWXy+T3hjAVOSDGq/xJynrkAU8JLXMF5dT43A12OEvu88ZnyQLR6Y+1mmN1eJ IRkQ== X-Gm-Message-State: APjAAAWikGTW7XG0TauqxVzUWvq1evud3JJej07S2gpeReQS4t3M2nPa FhvFCH5bt4sgy+XnNz+v22HaYAxF X-Google-Smtp-Source: APXvYqzKPPX9wIooVuWrZF6v99RYkxEGSOd2d2q7PBIlllej30LkDGcSuENOTQUSFVFv2lo9Rig1sw== X-Received: by 2002:a7b:cf3a:: with SMTP id m26mr17688496wmg.111.1566169624341; Sun, 18 Aug 2019 16:07:04 -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, 19 Aug 2019 01:06:50 +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 v4 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 Fri Apr 26 10:25:22 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=1566169992; cv=none; d=zoho.com; s=zohoarc; b=HI43EF+jcoNg1R/SPqGa3sl9lgJi5GtxpqY8P6dXhZrtnS1BO+O7XZ21qNpfM1olYnhoLTIbDzCxpOckm8VaFv4abAOfb/iDCvxSJu9DY8J0OjaEBNBIpBxjXuJn+ere6RfsCCAJdBgK/KkRgfWjiyhRLmpwotC7DqITgp6TYcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566169992; 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=MC5OBi2ZKOOmkFl5C2VVnsgxIzYWjfoInmdM2v3Cze8=; b=fMHCiYsPHCSKXnJbDU5RxxmQXhcoTjaZIVcbdTP17qfxHvB7FZaRz25MZUAh7JdPC4/g+rhtYrZRDUXDVKRxhn/kEUzpTN0dmUfOms9sVM1CnRykf843TxYaIrze82IfSnKWiwSq8MENKHNkLbcT7OpHuCvEmFKRPkIyOAl5V70= 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 1566169992367827.8666970476677; Sun, 18 Aug 2019 16:13:12 -0700 (PDT) Received: from localhost ([::1]:43546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUMH-0004Pf-0r for importer@patchew.org; Sun, 18 Aug 2019 19:13:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49702) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGR-0006Rw-KB for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGQ-0005I5-G5 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:07 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:56227) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGQ-0005HY-9w for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:06 -0400 Received: by mail-wm1-x342.google.com with SMTP id f72so3532wmf.5 for ; Sun, 18 Aug 2019 16:07:06 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:04 -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=MC5OBi2ZKOOmkFl5C2VVnsgxIzYWjfoInmdM2v3Cze8=; b=UsuOOaXmTczy80F8wbUoqzhQiUICFu75SELHegUHSzSKOkm3Uxx5oAj15CvCUuQ9xn 8wXRs3XmcijEPnzlA7R+Ktk/TE7e/y4kfwqPbKXqNxKHueqM7zwRVeL/EQbvehXZ2lF9 V8Jrzsh6jV8UtlXlJDl4ypnI8H/fRpBDbWZsBFetnEzij4RdnnayI+aie7aPsBEQQMT3 kdMSUG/diphhFFwM361wVmAQzU4fxybN0bm0X2oK9m7ejG8bZ/jWXsyqbr4Tv+U5phuQ BP7M40x6XLjgjo17alSzc2isTc0zcUlAz71WX33Id7InXwmKi6u9ZxMFCsYsSSVPReyY RPgg== 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=MC5OBi2ZKOOmkFl5C2VVnsgxIzYWjfoInmdM2v3Cze8=; b=LmqSshWS/LFtjjVA4Y4OxuEoWa7dyiV8GwwAqZ3OVVq0W2uykDThKksEJf0SjaocEh acYDsLe/VqphgzdPISdlUHofL3U+dPZdtTb0t9HhxJgo956Y0o1hmodTGNPXgken9W1d fsVdXS+bh563e921wYBxyTKLUsbiJDr27W799yInz54FFNBR33yLxY5QNfOcCVXaelBv W6lBGBQKKxbKKEWJ1In7JMeqARYARsWx4VSRh6KX8EXc769eqYz64OHAS5uIPycsftSs Vu45lWVbDwFM4pR9JBzAfqESqESw5w7F9hD0MsnExrU/hbI4+4LYrQBMiJ0ig29+MkTj fzPw== X-Gm-Message-State: APjAAAXtXLcRtZwJznSD98mmtV/CsuYmb2gKnXCazWqKFnLmZGUybokP g0Is3/rAUzipgnfwQmTj8KLJy4ib X-Google-Smtp-Source: APXvYqzn2YOp7nH//zWfPOO/oGy0czHT7HY+tAkV12V+YD/enBcYLtAZCsUaWsbCT00vL+FmvvEtPw== X-Received: by 2002:a1c:a852:: with SMTP id r79mr16366961wme.36.1566169625207; Sun, 18 Aug 2019 16:07:05 -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, 19 Aug 2019 01:06:51 +0200 Message-Id: <9072b955acffda13976bca7b61f86d7f708c9269.1566168923.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 v4 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 8e9ccd0ac4..7267cab9d7 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 Fri Apr 26 10:25:22 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=1566170196; cv=none; d=zoho.com; s=zohoarc; b=WtBDjZ+bEsk5E41WXtDw4v6Ed4XetLc84xacLPZepACt+4NXs7Xksz3yMRpkl1HM9sGEL4VlCd6vtkQyHCqmjW9/FZE8o/F+BaBqNfKEhRn23mQeT3EMPcILo7NfLv6LB7c0PGjsmSNIk4UJpZmXmTaMmoknRC6okIa9qksWPmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170196; 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=Ui0saXYh8OeatyWCKejcE+se9BKzOgGfefONRTfbu9DhifL206IncTNKR2Nj17+Cg94Mbowy7qWURV2DIUF1xeedOKOA8C/TYBH6Ei4k2JVDI1a2oxtebmXPSBE252JOHe8lwfrUKvHPxbK2jJG6frL2YwxKNYNzhirXMslGBM0= 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 1566170196222680.9890253356725; Sun, 18 Aug 2019 16:16:36 -0700 (PDT) Received: from localhost ([::1]:43582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUPa-0000CL-Ku for importer@patchew.org; Sun, 18 Aug 2019 19:16:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49715) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGS-0006T5-73 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGR-0005Ic-9j for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:08 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGR-0005I3-46 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:07 -0400 Received: by mail-wr1-x444.google.com with SMTP id b16so6742968wrq.9 for ; Sun, 18 Aug 2019 16:07:07 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:05 -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=cxVJfMC9RkViOeSspi0t2cLErhyX4bF5K0o4zTH5wyZaZCU1ErfY7sjmLetrXVEuDj V6bzFbQOLyn/I8I4pC8KG/XM+UWqjoZ1VBPAb8rX2OIJ0lB4drHqPGaektfOW5odUXJd D3s50Hv71PJ8tM1EWX327r2j/n0GfXSu+z2sH0/c8DrpyCLN/I1QQH9Y1JAXekmAKO8z AvCqmk0ySXwnAF2I7kBJ2JMAnu72DH10HtdICKsglj6BvCQlAeVxtMAtbMHoqMWFy0U/ /xDmVk7iG5vFA+0hD649ebenvn+0i5H4qySb/koD6RIWWNHb1IxjrDyyceZ066j45TND +PIg== 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=Q5+vq1FHXcRXYm+iP/B9cIlelnuomtdxEhMTyHjC6zhiiMFWM/k2ClXJUY4VK3J38T pjx3Pjv72l+SDt1fyYSebSAmNAXaFQmV5PJdipChPX6LNvZCniZ7shUCct15oAslAeRZ 8wGrrPvSikqiEq6A8z8os8bVgb9UVzg8R8SCDJm2NNoo8/y8QVGnJBrokoWA6fewyIVJ keE5auLu+FaKwiYlqzVbgPDfbdBNE6z5PyVN89b7Lad0xpqsLVzeXDZU4a+UwZKkU8qZ 5fkS3TPmpPw5Z/f2mciFU7dUB80UPjc0UC7fdreOQ7Shp3zbJ3Ww3isw2JuiSoS8DqcV PZ/Q== X-Gm-Message-State: APjAAAUQ8QknozB5XL1t/3kAzdx+Nd1B5I+C2IiBSqr65+SNVSRAE3a2 Nls4GyQ7Ofu9DyO3a2V8vcHNKQkfH+A= X-Google-Smtp-Source: APXvYqwoUEOu8sNGvRKwXEBvmfKbykIcQFuUM1fjwz9hC8jh3eUzQqJbuz8jWLJ7YHIXXFQrTwGK1A== X-Received: by 2002:adf:8004:: with SMTP id 4mr15528970wrk.341.1566169625986; Sun, 18 Aug 2019 16:07:05 -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, 19 Aug 2019 01:06:52 +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 v4 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 Fri Apr 26 10:25:22 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=1566169995; cv=none; d=zoho.com; s=zohoarc; b=UY+LWkrgs8KobAClGlWBRaWj/41mtpaAcICaWtZypuNyUle7v/omUdeVhDxXytN5WHJiNgyL15OhRTIQ5wfAuxafLXsAsh52BdWBGH8zFOR5/s8t04g7QgbK4hA4wWgkoYggNc0HdpwTN+4XUIpMemGx1X1GELRi4BUhEyI/+u8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566169995; 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=kg61s//awDqDsypJZ1VUoc9LjA/b82F9NZk+KFm9mGmEQqc4hb2wM4Aw74WksyJhCxl6Wi6DehjteItC1TM/hM989GVtmdZy9L3Ovl61KKwcOePTsqt8c21E6hYJ3BbJOuHOVutfp6R2muyADcEcUpBuj86ORmzuIf05lPIv2Kg= 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 1566169995446331.49187472920096; Sun, 18 Aug 2019 16:13:15 -0700 (PDT) Received: from localhost ([::1]:43548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUMM-0004cb-55 for importer@patchew.org; Sun, 18 Aug 2019 19:13:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49733) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGT-0006Uk-3r for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGS-0005J3-1N for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:08 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45560) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGR-0005IX-Rt for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:07 -0400 Received: by mail-wr1-x442.google.com with SMTP id q12so6728990wrj.12 for ; Sun, 18 Aug 2019 16:07:07 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:06 -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=bhm7J5WmqoaiqOT9MpO/YBlLvJe2+OELuIQxSHhTPuJ/UnOP28hg03rFukTJMpHZMS 9YWtMjmspgdeap3qRuPUyj0WdSvV4M7CCpbKo5Tjgg1uH4LtUPZ+0NuFEzUJAF+v+28v ticIqugalbBHuQuLB5s7V7CYjUFCaIy34b71PTYnDNUGK4YfIryPBIHAQrXhEv/5Gjrj LPeLsn2SqvTpbk0mRvUFtiNpIbh4JNUp6DOd6kbE2gwENAk+SDH9f73QbGlMdgpDNp0i rrlsJ7eLksZtExxu5Dt9BuH66y032i6GIx+O+uetsCmcA6K+1FgO1hYJAqivqwVZQjTq MPiQ== 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=V9AU0c5hDR3NeGFfu7JpoNGOZcrQdbVs7gXKv90X1VoNuZCXGpOA6lCvFUfpch25pu eaPpafM00lNUcBP156UOsMawSJ0XlN8sYix12Rkx+iuXqmKIYmNF5XKrUSCS8auNAcao mBeBmAotzvD4Ya+55ra9Jn5QSQ0dNaYyKkQZ17JpFdDSt5smVQ+DM7n1BFNb7trWcYNJ Q4hAtH+Blorg0FO28RYYcNgH/DjhPAEV5roWAYlQuBNweNM/f9gYsbkfmJ7fhe+Tn9eS rDm6+Fa2FpAERGuVf9VBV5xuUdsOYM4tT5bCssxs/CfiEyqZhFpSQ5xY/30Q611Nk/eS HAzg== X-Gm-Message-State: APjAAAVRjH/ruogHIwgdZaDCm2SsLsPVLQs88v8hyoyvJ3P3x6FiTlHJ Qp8I2nP/vN7VHtpSrupjr7PAV74AxUw= X-Google-Smtp-Source: APXvYqwYF2hOooTME+dXctIkL5vuCECTpDypSc3fiEQKeXemYjoSfDA+d4fWycw6MPPkJ8wKyp40iA== X-Received: by 2002:a5d:4cc5:: with SMTP id c5mr21987734wrt.278.1566169626737; Sun, 18 Aug 2019 16:07:06 -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, 19 Aug 2019 01:06:53 +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::442 Subject: [Qemu-devel] [PATCH v4 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 Fri Apr 26 10:25:22 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=1566170169; cv=none; d=zoho.com; s=zohoarc; b=UoTgy0qxjwZObnAPz0obGfx6bSSk4rb+CeJY4pPYPy/14kVjhxyIeDkTTmqI6YlvW1IxNWRv9xRINQcjLw42GL+QB76JhIoH+AEiw0Ayvve+LYo3yB0/6UJAZpX1Qsg+VhZ0xiOOC668hJr8e1C450dAcLzMHS/vybtkc/XBqms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170169; 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=7h1ndHoS+4IrgyYYd52ibrytHCMGLJ4rIh+AB7wYxIM=; b=GGRZ/my/CoAu9ry3apkYj9kZbFsHiNJb8PlVLkH3HU5vLT5HMdR67ZN6SjLaYwb6l6He16W2wvhTvIco0TqaQ4laKy7BXsIvWI3nfuwBNypya0Y33z278BCzjDWLzylQCgvAMok57fFa+hq7mQ0k88V9LKgCze3l9k925Y9AEOM= 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 156617016935144.59293342211811; Sun, 18 Aug 2019 16:16:09 -0700 (PDT) Received: from localhost ([::1]:43578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUP2-0007z9-6T for importer@patchew.org; Sun, 18 Aug 2019 19:16:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49772) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGW-0006ae-JL for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGT-0005Js-Lc for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:12 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:56095) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGT-0005JQ-Bs for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:09 -0400 Received: by mail-wm1-x330.google.com with SMTP id f72so3586wmf.5 for ; Sun, 18 Aug 2019 16:07:09 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:07 -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=7h1ndHoS+4IrgyYYd52ibrytHCMGLJ4rIh+AB7wYxIM=; b=p89rtYMdvSJgcgF+PLXmI+ZbB4JMScLx2FeawiREpcZDw6qJvWnXvlYvXxjnqqp/dC lTUC4FJYlyC+G6Lqcff64nBmSaiYcmq9z6gKv6voT139eh666YmFrWiB3uqs/NRVLDS1 g+ZNIzn1IQaZhMb3vXN3RbiFMbiB0k0cVj4fggU7V31hsf6coQLqxtD6BBiKtFtTMjSz zyuviSDkMqvxl4Xy8Sbb+7UyRyLw0SHecggGQBNsI8srHgiPPqXHPteha2zEJcJCqTUX gZ+yBtkpnHGAoV05LBDwFqua+ejrYSkbLy351bEsYVZ9/Ddh9poPH5R7H91C00VnrgwV VPrg== 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=7h1ndHoS+4IrgyYYd52ibrytHCMGLJ4rIh+AB7wYxIM=; b=JUZFB65qPqONnSZaAiuxRd2IrlX173XSLsCnl13I1dy2cdUVl8ZYSijTzR5x2+7Qvq DQXZtScwvb9BHeambPHVT2vtZQBSxpbpAscMraft9Qvo5IMcfIoFW/g4Cqo9UnMparb1 ZcJMYapVi1wvEPlElvtCt7N6toagJX6zaWuKjsOSnsPN3joLqQBwTdcBHohaFYS6rNRO vsvOAF9tNx84HKmz2JBssICh51h5F30hDUSZRRnsDr39MR/ICvM3kk6hhDGovXk2axLk En4imubspjDl5OczcLhReh96vP6jQW2GPRv9B1hkGy7TM2A43rLB52UPBGYqitO9hqKi fx4w== X-Gm-Message-State: APjAAAXZ+Hi6QDOUGpem9ftyuZdhDnP9hxLmOK9mDck7jsb2sgQbEBbp XWsFF6n7E/pg9rSxxi+PfSXhEi2jFT0= X-Google-Smtp-Source: APXvYqx/Qt3qX0jk3lKPg3Z19awjNgYoHC24xfnbL/lJMChvyS+279E5kzdWX8QnU51kQYP9JXUd/g== X-Received: by 2002:a05:600c:10ce:: with SMTP id l14mr16787243wmd.118.1566169627619; Sun, 18 Aug 2019 16:07:07 -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, 19 Aug 2019 01:06:54 +0200 Message-Id: <303222477df6f7373217e0df768635fab5855745.1566168923.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::330 Subject: [Qemu-devel] [PATCH v4 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 3257165b05..96e22887a0 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -147,23 +147,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 7267cab9d7..100c3ea177 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 ec1c8fe936..5672e12dc3 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -163,20 +163,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; @@ -294,7 +294,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; @@ -304,7 +304,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 b4c0b690d7..a136b97f68 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -965,7 +965,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; @@ -974,7 +974,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", @@ -1020,7 +1020,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) @@ -1041,7 +1041,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; @@ -1050,7 +1050,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 64a1060b80..cb4178d861 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 5b7baeae25..c7b8067489 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -536,7 +536,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); } @@ -579,7 +579,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 88f886491b..f9e9f2a3b3 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 effec31d35..2b6b7c4e3f 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -119,7 +119,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); @@ -134,7 +134,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 @@ -194,7 +194,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 68fe1de987..f17e8d8dce 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -235,10 +235,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) { @@ -263,13 +263,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; @@ -299,10 +299,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) { @@ -327,7 +327,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 */ @@ -342,7 +342,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 853b4ed874..6d409eff1b 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -185,7 +185,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 @@ -199,7 +199,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; @@ -228,7 +228,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 @@ -242,7 +242,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 307c664725..d773eb80de 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 7e50ab8a84..a354f94acb 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1169,7 +1169,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 a8725abf6a..601ed04aff 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -70,7 +70,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); } @@ -101,7 +101,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 Fri Apr 26 10:25:23 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=1566170196; cv=none; d=zoho.com; s=zohoarc; b=NHBSzhad+6fDWZPc1xze+iA6baB6x4Na0nL4KreOejHBUtCNwJuQ5QhV+AmSuglfN/x4L4nhQU8SmfZ3bhSGnMB12Ug2gX5I77z1Vn0ac//wsUJAybvFoV9telTlA+ANmuL0z64pqQkZd4xdoH+cFsFuYbrZm9iPuCNBYFE2OLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170196; 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=dS+kQo1c55Y/59/HzMqpFWI2NLCxKN5RjySdBkuDcJI=; b=LqFRYWYCijj4J9+3YQwGrV+XB3qbRDHYdzas7F5qzg5l0U/nS1YJRSa1bJFIupXQfeidIQulc6NHK28nsB8p75iCZw4+4M7SZqVvSj4DSIczrV5n6WLKghQN0jck3jXTGid1+MCy8xEOTQynuo39Np05H5V1jCyZGbTgJXK1N60= 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 1566170196573410.8471384129899; Sun, 18 Aug 2019 16:16:36 -0700 (PDT) Received: from localhost ([::1]:43584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUPa-0000FI-RY for importer@patchew.org; Sun, 18 Aug 2019 19:16:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49754) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGU-0006Xl-Tq for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGT-0005K0-Nd for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:10 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGT-0005Ja-Hu for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:09 -0400 Received: by mail-wm1-x344.google.com with SMTP id i63so16840wmg.4 for ; Sun, 18 Aug 2019 16:07:09 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:08 -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=dS+kQo1c55Y/59/HzMqpFWI2NLCxKN5RjySdBkuDcJI=; b=H/hEBuFr9fIE8yMMnGaCl71lqlD4OX7fAVFmQcauR+7MEG8TxUUNOseahuQ1YO+UAJ OdZmqJULAJR3e0UjcEVj8IJ+uycjwtAj66Wy+ZhD+5Ricb4352R85V7cPUHcMc7M44+M 80Keli+tLAHDMmlG0sLBkuyy3qGAGqRD1yfhA7Iulc556pLnKE8HQH1KaGn8NXRiU2r8 AMnwleH/6bPQ7gBbvvli0rzoxegLiE3x6mrDst8FP+2jSlXxbYzhPl4DvlqsmrzVlxL/ yp1fgGpv9abUvq9Xn6nIB1HYHNa2Xh6hoD6Bpn0WI1EQVtrXq4RZ1e1KUeKURohib9he SKAw== 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=dS+kQo1c55Y/59/HzMqpFWI2NLCxKN5RjySdBkuDcJI=; b=o4Lj3XrhK4zI+us/5XprH57lgsrKW3N56hm+uhiUNg2Dx6RAKYOMFPf7BIWq3FDAYx aSfZkqtsPGqLft5rY5AJP8w604sBpGCrhFNK7eMmVeK5J+qFMK2+93bKle2cgsWgmwLC aXRivAzXnHMdtjaMe6UKRLTTZr/v1eDM7i2dOMGYRxvzVAZKazIyD+jMnsow1TrWkTy0 k2MJ7I2kQisRlfKwVnM0/T9wfV47ZgI6W8jsz6y7/bKVzVIVciXl2ujixVyRyVkEPR+N 3IG05Z1ewGlKdqT5X3yR8Ozq/Gv7PsCeMTwiWIrcJ8xrtEI4YSB38k8Ak5qYbvmvZ065 qL4g== X-Gm-Message-State: APjAAAV/5yj96X2xxjJjL5FMBPZ5xENsFmA8TO24Il+5XYapaaV73qOe NHzX616A2Mv4s745KBU/2QY+dXi96lw= X-Google-Smtp-Source: APXvYqwPKgWQ8wU6T+M9Wy4C3GwxANfIpTjy2gX8Wh4rIMNExKIviDqWLirRo+6FdX0ZhY6pHkA4Gw== X-Received: by 2002:a7b:cb03:: with SMTP id u3mr5044447wmj.58.1566169628470; Sun, 18 Aug 2019 16:07:08 -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, 19 Aug 2019 01:06:55 +0200 Message-Id: <10221fcea2028fa18d95cf531526ffe3b1d9b21a.1566168923.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::344 Subject: [Qemu-devel] [PATCH v4 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 100c3ea177..cb6a9d8ac5 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 Fri Apr 26 10:25:23 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=1566170393; cv=none; d=zoho.com; s=zohoarc; b=bqHfuSYIL22BEZQH0YxlOSx+AR6SzhJXwp3k57EkJcmswlAtsyaU1pri7OlSXkbhskF+iLsf/+IpDWzA2zaWWtsfxONrVqSIlE4Fol5CuNB73zWTz+F3GWVlvTuD0Rt0f/SMFzrt82gAudl838YZNgqPXMXsJow5El9GWh3a+hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170393; 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=B4HFRDcGY4cTapsRdpHgg0fpACUYZ5Vi4TrWPDvomiqDDiPxia/PXkg0XdcbfXJCpDR0/MDl9xW6hjNGvfGtatxV+qo5LRYADsbbc1D2bmE+c9zTpgDkCs7djU7PIZUMrGCW5BY/5eb2C8+D2GFTYY1njcvg8iDOXvbOHirkVlA= 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 1566170393446327.1164415615856; Sun, 18 Aug 2019 16:19:53 -0700 (PDT) Received: from localhost ([::1]:43638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUSj-0003K5-P4 for importer@patchew.org; Sun, 18 Aug 2019 19:19:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49757) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGV-0006YV-9E for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGU-0005KR-Bo for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:11 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:52756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGU-0005Jn-5m for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:10 -0400 Received: by mail-wm1-x344.google.com with SMTP id o4so9534wmh.2 for ; Sun, 18 Aug 2019 16:07:10 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:08 -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=aWd9oHb04kGXvRv0eC4j08jUkl3cS6T1vdY8J0+fuwXtGChWBgkua53TJJZtE9EET0 gh6joL6CGg9zEq2ZROo0pb5F2TbVtgl9v9ndUaYqM4qwRcWvtfVCxgLXPYpyFTU3P2Qt j3LMuePYHOjMhl2rWn2s869qH2gETGonCJTTFiExGr7VMvFGVajYeRrwwZqQlrxy8V3Q jYZaNPUboYHW4p8J++4TUaNSUiiMbeXcuXFFmnR4f9r1IcmQGOQI0Bz+rL7ZRh9MiiVk 3i5vIp5AX7oYlTbbk3D0bvcaEwTSYML5U4HXesthFw3edCho652qQ75gtQLgoBGC0Z9J jUZg== 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=EpEF1/ZBH0Qf57C7KBdxN4nFivuoeDZcUGgNiTBH4iu6WRoCk4IDw1UJSN5LjS8I6+ NFE4jdL/k0NdL/EZ83d/vcHjExInl8uSRguLJHoHIw3upMCuEf/GLC//VDHwVNZWPiJ9 wcO7yEHAenrw54k5CWnV0dPdjWJlkts/WfwMMXgMFw6HCXs80Dt0ljn3sFG/l8Gk1XKW gPiziw/bJ3s162sfQ1n2D24E2BFx6D11uYzqRyY6HDndDYh3PpGuN3qOGdzxtkcJ4IlP RWIJu6W39iLVlAr1hmKorbijUVrL30z34rWs+7ILPcGuYScyr3kLszQGDLPoAKYL8JMo Z5sQ== X-Gm-Message-State: APjAAAV9e9s3HNW7nqMRf6n6d+yHDbCVYzM1PYBW29tuXf9GVbkWQbdL kCgDAVNYp6AU10NJfJB73Rhl+Wny X-Google-Smtp-Source: APXvYqzpAOWQga7jlikjWTMZupVMJGq5vHtRuRwHl/dpb+FzyxTO3WZEywT408LIKgX+Eoms4iP4Mw== X-Received: by 2002:a1c:200a:: with SMTP id g10mr16099005wmg.160.1566169629108; Sun, 18 Aug 2019 16:07:09 -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, 19 Aug 2019 01:06:56 +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::344 Subject: [Qemu-devel] [PATCH v4 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 Fri Apr 26 10:25:23 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=1566170394; cv=none; d=zoho.com; s=zohoarc; b=V8ALK3ZbL9I6Eq+diWtVKLAH4K1uC7Q5RLSfJUnFE1FNWTzbrBuVy8SAMIuom1E034/I4aMvAwT2iqw50jVE2yayrXLhxo4VbxHcmm9L7R3B+sx7AyVN8fCU3/M7DXs4u9bPQhk2g9oEnLpt8RpJX7Y/bCpchry3ukjrKdS0slg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170394; 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=K6cAdFjyFZrfqURbx3b8/gz9G8WoE16A83gLPgmwe98=; b=Tves0QE5OmNClxZD1YOG2yjRdpXAmr9FTVVWdHP1K37YAQzqdLMEkrSo/LWqXFrkL+I7DhanB4vN+bSsf3amAHjlawtwvYyDbXgt8iP0/dZ175kjt8xaA1QhV8jplpJMQQv2R539NnW1WkqJug+vgwHouC6GgwP0e0cX3gUCrPE= 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 1566170394838841.495738331265; Sun, 18 Aug 2019 16:19:54 -0700 (PDT) Received: from localhost ([::1]:43640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUSn-0003Ph-17 for importer@patchew.org; Sun, 18 Aug 2019 19:19:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49783) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGX-0006bd-5l for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGV-0005Kv-AQ for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:13 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:37681) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGV-0005KV-3o for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:11 -0400 Received: by mail-wr1-x444.google.com with SMTP id z11so6756498wrt.4 for ; Sun, 18 Aug 2019 16:07:11 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:09 -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=K6cAdFjyFZrfqURbx3b8/gz9G8WoE16A83gLPgmwe98=; b=IujkNdsbiV2VfUOkDk7DPdM0uTuzObVwTkLDZ+HWyPq/RXzHCfm5w+ZQZqkQ3W+MHW zSJVNFz9WkLOwUl1L+cExNCcddvUMK6mvMKzOaEg5rhEwpoE8PntCMxAkwX1qdhGMxId jGrltkO69sIH/2/T8wSqhLcXST5gjQRGW6UB8DjwG4LYdbTNPvTVCNEMGNvWMoNjERld 3hjFbNjioWbFb/a6Dr9j76u9H6CKIwdYo1oYjN6qjHWdUQxs8x2iH3QALvca4TAjqjdi JXL9IppBoWStXjXz2ZvRoJlD+4QDsb3u15xo1+ITAW0zXmuFRkGjAopVX/odtfVCAV4H i29g== 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=K6cAdFjyFZrfqURbx3b8/gz9G8WoE16A83gLPgmwe98=; b=egyASdvc9hewF05nMuqlLcmUb6DaAw6R8CfrKumQBerlAnfecIDhCyC6NdinNXwol1 T/dytpf656+6HMQ32+GcFm/SamxCKwg/Dyc5ijjagu1MJkAOPluh56Z/wLrF1FxWCU5H sk61KE4OnmLqIFCEiikxNQIj1o00q0LrP4LCqZB4SOTdlPjdddcp01/GFm5ddovYpdeO zi5tH+c8oIwGZWuxqWJbu235pzGFnc+ZS+w0u/P9SlZ3gaeT7uArmelhcaPoeWnIrJc6 YpSfkpIhjVmnQ8af1RtXgGaQSgegV0ikTW/dnY49HLhTZFJijxCTCnlr6DlEJJ0t476e I5Hg== X-Gm-Message-State: APjAAAWezt2AxGOvfII93AzaUpKAN836qzSZ5GqtUbHu8T4IYXd+AcR2 OiQIBN3GW6EAyLRtxMMhaY8PBbob X-Google-Smtp-Source: APXvYqzhMqS1/QdIk6DpfNZulW7Culp1H0FzstE5jbK7lwIxrKGYTULp3qU88qqI5wE0Q5XwQeHdRQ== X-Received: by 2002:adf:9e09:: with SMTP id u9mr23264214wre.169.1566169629877; Sun, 18 Aug 2019 16:07:09 -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, 19 Aug 2019 01:06:57 +0200 Message-Id: <92ddc98133bc4b687c6e4608b9321e7b64c0e496.1566168923.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 v4 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 cb6a9d8ac5..43db134bb9 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 5672e12dc3..ab69521ef9 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -192,11 +192,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); @@ -325,11 +320,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); @@ -377,13 +367,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 Fri Apr 26 10:25:23 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=1566170546; cv=none; d=zoho.com; s=zohoarc; b=GW6zfd5QLycGVNf49b1iA0LIm4rlSl/dniinCKT4ahh0BnNi9xddTccU9QiTLLCgdUtxnAFIqvJnsD04iQI5LU4ugodL9eOvruoyccTi/c37MYLXbs44lEoGLv3nfXkFyh6OjcnVwFvTM/qL4TvSPMyM3IW+Zu9rHQO2quuaomE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170546; 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=94GbBUrcWSp1putS/zN192QUHRNOeVOz6N7GY3T6j/k=; b=ZqoH9M0ek/ITRDIsk+unFck4G6brj4G/o7f9P+AuzJleciBZhT2UJ49XSEth8xtLabDYaSSfGfdpkoWa2NBK9C79X5qww67LHz9c+yGtt4YMSPVtZUOOxI8ICET6xF1ygPXUn7NPF6JGGngKOuTbsgdVfmnMBk+yfh2crX/69t8= 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 1566170546808101.75903417888378; Sun, 18 Aug 2019 16:22:26 -0700 (PDT) Received: from localhost ([::1]:43676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUVF-0007Hs-Eb for importer@patchew.org; Sun, 18 Aug 2019 19:22:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49807) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGc-0006h6-NQ for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGX-0005Lx-3C for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:17 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:40069) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGW-0005LL-MQ for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:13 -0400 Received: by mail-wr1-x433.google.com with SMTP id c3so6752365wrd.7 for ; Sun, 18 Aug 2019 16:07:12 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:10 -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=94GbBUrcWSp1putS/zN192QUHRNOeVOz6N7GY3T6j/k=; b=YImxH2zHsJNTAXMQxewTi/e0I5zdd5GUBNcwPOOVP/tSJgjjYHAufYgdKqrALejo1Q Yo63EIlwnL3w4vmG1pPrScXdSfqJFcXn89zlG+BuVNiAXFJoA1EoqCE+Ede8EDJabALO 7iSR9Gh7j0p0ApppCgHuIEimWKM2WdlYafYYJRVW24PR3mVocnyQxwQ3E1GlZ/KXVcxM wmYuMK2PUu9wE6iMUpa59HFRTrt7IOW10c9UDdSGcwGCgjmZ1CXV8x4wg0bKrx/cRiUh R+uWiBeJSJGALofJ06tQQ07CorQRbBIKiI6B/WhOHU1fy8NfIENXqRrBcMSd1CqXPjrB rNKQ== 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=94GbBUrcWSp1putS/zN192QUHRNOeVOz6N7GY3T6j/k=; b=XQfX4nEI5w9xOrTFwCF37DMLLhLaaSfqVEgNmIt4JdJJpabpcoAPpI3BieoV4g1lRL x3y7stI0eT/pBnLRU5rEJLg250M5OdqjYZJB1WedkGDA4WwO/FO2K82p3yvqYX2WqDbO tnir0voU6SphHy77ZRjFeNI3cUe5rI605rPavrpkIEzmVicI7nTDu3xk8NtheIC6XrXe KGvqtDA0m6CXA2BJY490aEXN8H2U1ZXIEslfUw8yv0Ms3p62wOeX0oHyF+38mn/Olyky wzRA72DDTAzWY+AeM148eiiQSaws7GFAvAfdgJTykDIUib0gdF1MlYWaAtqBjc8tdbka SUHg== X-Gm-Message-State: APjAAAU8d40u1FtE2STcXpZvR8qTCOZ3tnKq4rlYNRtaEOPmgilzpgiy bidqP2Q+TVXFQXVNhDJMKIETfeMOCok= X-Google-Smtp-Source: APXvYqxe2u+dsG0JeLF+NT9uan2AqyxAtkeH4D4kEnzlZYXjXHxF6/YaJyHQ7K1ysEsk8Ch8VpQQHQ== X-Received: by 2002:a5d:4284:: with SMTP id k4mr23492515wrq.6.1566169630810; Sun, 18 Aug 2019 16:07:10 -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, 19 Aug 2019 01:06:58 +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::433 Subject: [Qemu-devel] [PATCH v4 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 --- Notes: Changes from v3: =20 * (Hopefully) fix windows build 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 | 17 ++--- 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, 215 insertions(+), 216 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index 96e22887a0..c74abb8c47 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -113,7 +113,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); @@ -134,7 +134,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 2f2ccdbc98..df248af581 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 43db134bb9..924dddf2e7 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..2fc118b795 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 @@ -533,9 +534,9 @@ static int dsound_run_out (HWVoiceOut *hw, int live) } } =20 - if (audio_bug(__func__, len < 0 || len > bufsize)) { - dolog ("len=3D%d bufsize=3D%d old_pos=3D%ld ppos=3D%ld\n", - len, bufsize, old_pos, ppos); + if (audio_bug(__func__, len > bufsize)) { + dolog("len=3D%zu bufsize=3D%zu old_pos=3D%ld ppos=3D%ld\n", + len, bufsize, old_pos, ppos); return 0; } =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 ab69521ef9..26873c7f22 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -152,11 +152,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; @@ -275,12 +275,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 178094e601..91854f02ea 100644 --- a/replay/replay-audio.c +++ b/replay/replay-audio.c @@ -15,18 +15,18 @@ #include "replay-internal.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"); @@ -35,7 +35,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; @@ -43,8 +43,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); @@ -55,8 +55,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 0c4e9c1318..7fc9891d2e 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 Fri Apr 26 10:25:23 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=1566170363; cv=none; d=zoho.com; s=zohoarc; b=jZ3CZXt+sErEriUEZnZss1BwlUorMH5qCN/d93CL9EpWJ5RF7h6VjzfvTJqJAeBSehv8oBEAo2lchURul28U647crlE7THRMhP7t6LuygCMoNa8q9V9xnB3jvrPZzkeNsERRbd+yy6ml6pRg/KJjNx0/DnyeLiOLrxeEgt48XgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566170363; 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=dnMQA/uiUZlUE5JhU4VhzWAdVWlF/CgYQuC67E40M/Y=; b=J4xIXr7u/ayzTFiw116ozCixXHamHdZorY5dh+FpCt0BwUb+uwtdN8V4XU1IYNC0imhk75ingORs0jzIW0fMk9mJVXP2/qVy0c2IXiSeoMVAwyUs3BKGkk/B4U3v6+eQs5XXKd+An3LdHhnGflBeqmTChBh/xi0LQmcM8YO/uPo= 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 1566170363126269.8938600895625; Sun, 18 Aug 2019 16:19:23 -0700 (PDT) Received: from localhost ([::1]:43604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUSH-0002tg-6U for importer@patchew.org; Sun, 18 Aug 2019 19:19:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49786) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzUGX-0006cB-IL for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzUGW-0005Lg-KA for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:13 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzUGW-0005L9-ET for qemu-devel@nongnu.org; Sun, 18 Aug 2019 19:07:12 -0400 Received: by mail-wr1-x441.google.com with SMTP id k2so6753261wrq.2 for ; Sun, 18 Aug 2019 16:07:12 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-49c9-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:49c9::5]) by smtp.gmail.com with ESMTPSA id c15sm33657152wrb.80.2019.08.18.16.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Aug 2019 16:07:11 -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=dnMQA/uiUZlUE5JhU4VhzWAdVWlF/CgYQuC67E40M/Y=; b=TM3i1A+KI2u1KwNINcwi6ZWcnd2Wo53Nk4KetUpbDQJjiatYF+C4w1HblRoCEpnoJn GYWiqD0+H4AYeBKQwMwAg35fFQoQV7wVowgJQo+uvPABLXgVHD9ReK5dCqhqL+LgvAp7 o+zribpCGNnRuKjzQw0yhpggPYWm4h91N3Zw9uG6jxZBZEoFoF+dle0HWjX19GRHap9m kHp3CpQyYcNGOt8xfyU4HyLSAiNjWzgJ6ks+YeGTus3FTcsMZrKppyuCSL/0iTYRWMzF gWr3ItgsAFQzloqh3JK4mvVrH0dNYNZlhFmc3Q7z4JfDY1itg8ltK+T3FGe5dJj59aV5 vwZA== 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=dnMQA/uiUZlUE5JhU4VhzWAdVWlF/CgYQuC67E40M/Y=; b=YVBHrDP6QNlrwwVybmR45YThcV3h/0QcJSC9hvA7YzPQhzAKcFt9foxNVHxV2P2Qz0 zXluSnFtVDAANqa6DS8aM4kOHncscxSAGrfq9m+bd2Eld5xyDVQYr31M5UB4e2kIuhYU HPovT+K3yWu9pWtkAiRkcmVwaNpTanFxi6bd8B0tdhDakJ0fB6sc/Au4behY0kGN9Fo6 76FfF9fQq0OSLwdMma5Upi/8baU1vcSjWmFcQ2ZQMKm6R4zmqUU7mIPBAtmrrj38mz/P 1hEsEQ67ql/NScRfzwUvkM4WWYXNHPsVaZom9KyniwdwDiceyXGD6s0bUL7uwjYXYHUz SFaA== X-Gm-Message-State: APjAAAW0FYYcbCc9/clzfQJwfYZyZQJ847IolfdDvRhEVUC/dl/bPnMO wkFRcLiCc53cIEPtEUgXsD1cJj9Efas= X-Google-Smtp-Source: APXvYqyX09olMAba0/KUEZtaZl3XaR/lAFIC/QzZS8fP+AhigaAdDEKphTHU7nRk8cNJm7xKKlQvfA== X-Received: by 2002:adf:c7cb:: with SMTP id y11mr16278930wrg.281.1566169631434; Sun, 18 Aug 2019 16:07:11 -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, 19 Aug 2019 01:06:59 +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 v4 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- audio/audio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index 924dddf2e7..9b28abca14 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