From nobody Tue Apr 30 01:16:34 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=1564938351; cv=none; d=zoho.com; s=zohoarc; b=Et2eqQBWPE6cS48IANXZvk3xM3oDGBpTYfEUYuJA+sdnpTVGmJLOz36bqfIoU4XCerI836Py7HO5x2rCMRS0uWoOonMpM5DMUrHmI0C4clNh30bqK/xIQLm9x0rReEGrTJGUD5LxDfwfjTj5NMfLwCLYuMXOuDbuF989RBfo/Sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938351; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N04kGAyyPqX8q8BYYYbKhgnzmzt+O2LAdu0HcQqLcxc=; b=FA5/NQp1aMKrjXVSE6C4MW3w1zu2T9/4AnQhuLSaYsOZWznA/ttyXW52wpqkSgBie4NWA6ydLeJaNJYM5+NN1vqwtL1B1aIZq+oZ3QbJ5vddVPIh2O0TvCFw4Qa9KZ2Wq/8lkBySS3GhaKhDZc0EsASn+ReqkQOOXWPayjn88EA= 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 1564938351741796.7174804430506; Sun, 4 Aug 2019 10:05:51 -0700 (PDT) Received: from localhost ([::1]:48852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJx4-0004JL-Mj for importer@patchew.org; Sun, 04 Aug 2019 13:05:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56766) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw9-0002QC-AC for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw3-00048s-2n for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:54689) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw2-0003zQ-Jy for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:42 -0400 Received: by mail-wm1-x343.google.com with SMTP id p74so72554839wme.4 for ; Sun, 04 Aug 2019 10:04:30 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N04kGAyyPqX8q8BYYYbKhgnzmzt+O2LAdu0HcQqLcxc=; b=elJclC88B5aTB0Mo2+wrZVGtjMKYIiEIaZUU7O7P0wRBmGqyD7nfrgvnaXfJ6rq+Ih TUEqEiTzVC4CXLmuzQ/KyRkWeNAHMFdX+BwEXi7gCZP1yPVQCzCeF9zgLP09za0Whpi2 u2SAEO6PUZQp2GPJofdcFSGeJAd0QWn7WPWZQTrAA5vanj/a3o9ZXLMWVwNGPO/HPeG/ TtfEnoW1oUe3RRPZD9i+1if74mFkxm7+xQ80WbW/9CfokZ5eD0hcNQ5in8ftvPTvJicp TR9VTXYOmGencDOnr5FvwlQajwVEiEVTL0EfENcmhPe2f+KBmc/iYAjgsA/W3V2JkUb/ pM4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N04kGAyyPqX8q8BYYYbKhgnzmzt+O2LAdu0HcQqLcxc=; b=O6p4mj0WCxl1rmGoMtWY2xtdGOn+a0rnLrmBfyHC7sXldWLbu1NvLlMg0pVcqdBgkL NbgI+QlAUT4IjPhgz6Nmfpgz4OHTlIMkwr5sStg2e28G8LfkjuTnmvUOdSXLj4X03H2V dB8QaxNo6U7aSifp+x2btYiKMwKlpwwFTXLuWP+Y60hLDWW+3VLpl0UYs1MUw/bccPdg xakCdgfaDB6CLxvusm7ZKI5+znLurRjxveYSadTo2I8cfxp2Y1/hduue4BmF3bjkNKOR ZXaGAG1RyOA5A7K1zCtIFrBGe1ONSdRqtk7zgU0bMYWKJ+2jSXsBjX185OakHTDRU8Gu ffJw== X-Gm-Message-State: APjAAAV5F9+PdnrXBjqHtY3SBBmXT3OOt1WH4Nxhd5CdkGQ1V15agbnO h4d0wrkMV6AfrWgT9JUcauSjKSlN X-Google-Smtp-Source: APXvYqwHNleCLx4Rw7T8aGAU+4ip6fmsjM20x70+sxpryvQYY6CnD9Kl8vl3YRToHxIxuAeLIRfgEA== X-Received: by 2002:a1c:7304:: with SMTP id d4mr14095219wmb.39.1564938269497; Sun, 04 Aug 2019 10:04:29 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Sun, 4 Aug 2019 19:04:13 +0200 Message-Id: <03e8aeba327355b64d55b2dd42e786c47e4b4667.1564925486.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::343 Subject: [Qemu-devel] [PATCH v3 01/14] audio: reduce glob_audio_state usage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Remove glob_audio_state from functions, where possible without breaking the API. This means that most static functions in audio.c now take an AudioState pointer instead of implicitly using glob_audio_state. Also included a pointer in SWVoice*, HWVoice* structs, so that functions dealing them can know the audio state without having to pass it around separately. This is required in order to support multiple simultaneous audio backends (added in a later commit). Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 8 ++++++ audio/audio_template.h | 46 ++++++++++++++++---------------- audio/audio.c | 59 +++++++++++++++++++----------------------- 3 files changed, 57 insertions(+), 56 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 3f14842709..8164696b2c 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -49,9 +49,11 @@ struct audio_pcm_info { int swap_endianness; }; =20 +typedef struct AudioState AudioState; typedef struct SWVoiceCap SWVoiceCap; =20 typedef struct HWVoiceOut { + AudioState *s; int enabled; int poll_mode; int pending_disable; @@ -73,6 +75,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; =20 typedef struct HWVoiceIn { + AudioState *s; int enabled; int poll_mode; struct audio_pcm_info info; @@ -94,6 +97,7 @@ typedef struct HWVoiceIn { =20 struct SWVoiceOut { QEMUSoundCard *card; + AudioState *s; struct audio_pcm_info info; t_sample *conv; int64_t ratio; @@ -111,6 +115,7 @@ struct SWVoiceOut { =20 struct SWVoiceIn { QEMUSoundCard *card; + AudioState *s; int active; struct audio_pcm_info info; int64_t ratio; @@ -188,6 +193,9 @@ typedef struct AudioState { int nb_hw_voices_in; int vm_running; int64_t period_ticks; + + bool timer_running; + uint64_t timer_last; } AudioState; =20 extern const struct mixeng_volume nominal_volume; diff --git a/audio/audio_template.h b/audio/audio_template.h index 1232bb54db..c721fed75d 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -36,9 +36,9 @@ #define HWBUF hw->conv_buf #endif =20 -static void glue (audio_init_nb_voices_, TYPE) (struct audio_driver *drv) +static void glue(audio_init_nb_voices_, TYPE)(AudioState *s, + struct audio_driver *drv) { - AudioState *s =3D &glob_audio_state; int max_voices =3D glue (drv->max_voices_, TYPE); int voice_size =3D glue (drv->voice_size_, TYPE); =20 @@ -183,8 +183,8 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw) =20 static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) { - AudioState *s =3D &glob_audio_state; HW *hw =3D *hwp; + AudioState *s =3D hw->s; =20 if (!hw->sw_head.lh_first) { #ifdef DAC @@ -199,15 +199,14 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) } } =20 -static HW *glue (audio_pcm_hw_find_any_, TYPE) (HW *hw) +static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioState *s, HW *hw) { - AudioState *s =3D &glob_audio_state; return hw ? hw->entries.le_next : glue (s->hw_head_, TYPE).lh_first; } =20 -static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE) (HW *hw) +static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *h= w) { - while ((hw =3D glue (audio_pcm_hw_find_any_, TYPE) (hw))) { + while ((hw =3D glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) { if (hw->enabled) { return hw; } @@ -215,12 +214,10 @@ static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE= ) (HW *hw) return NULL; } =20 -static HW *glue (audio_pcm_hw_find_specific_, TYPE) ( - HW *hw, - struct audsettings *as - ) +static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioState *s, HW *hw, + struct audsettings *as) { - while ((hw =3D glue (audio_pcm_hw_find_any_, TYPE) (hw))) { + while ((hw =3D glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) { if (audio_pcm_info_eq (&hw->info, as)) { return hw; } @@ -228,10 +225,10 @@ static HW *glue (audio_pcm_hw_find_specific_, TYPE) ( return NULL; } =20 -static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as) +static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s, + struct audsettings *as) { HW *hw; - AudioState *s =3D &glob_audio_state; struct audio_driver *drv =3D s->drv; =20 if (!glue (s->nb_hw_voices_, TYPE)) { @@ -255,6 +252,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct a= udsettings *as) return NULL; } =20 + hw->s =3D s; hw->pcm_ops =3D drv->pcm_ops; hw->ctl_caps =3D drv->ctl_caps; =20 @@ -328,33 +326,33 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYP= E)(Audiodev *dev) abort(); } =20 -static HW *glue (audio_pcm_hw_add_, TYPE) (struct audsettings *as) +static HW *glue(audio_pcm_hw_add_, TYPE)(AudioState *s, struct audsettings= *as) { HW *hw; - AudioState *s =3D &glob_audio_state; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 if (pdo->fixed_settings) { - hw =3D glue (audio_pcm_hw_add_new_, TYPE) (as); + hw =3D glue(audio_pcm_hw_add_new_, TYPE)(s, as); if (hw) { return hw; } } =20 - hw =3D glue (audio_pcm_hw_find_specific_, TYPE) (NULL, as); + hw =3D glue(audio_pcm_hw_find_specific_, TYPE)(s, NULL, as); if (hw) { return hw; } =20 - hw =3D glue (audio_pcm_hw_add_new_, TYPE) (as); + hw =3D glue(audio_pcm_hw_add_new_, TYPE)(s, as); if (hw) { return hw; } =20 - return glue (audio_pcm_hw_find_any_, TYPE) (NULL); + return glue(audio_pcm_hw_find_any_, TYPE)(s, NULL); } =20 -static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( +static SW *glue(audio_pcm_create_voice_pair_, TYPE)( + AudioState *s, const char *sw_name, struct audsettings *as ) @@ -362,7 +360,6 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( SW *sw; HW *hw; struct audsettings hw_as; - AudioState *s =3D &glob_audio_state; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 if (pdo->fixed_settings) { @@ -378,8 +375,9 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( sw_name ? sw_name : "unknown", sizeof (*sw)); goto err1; } + sw->s =3D s; =20 - hw =3D glue (audio_pcm_hw_add_, TYPE) (&hw_as); + hw =3D glue(audio_pcm_hw_add_, TYPE)(s, &hw_as); if (!hw) { goto err2; } @@ -476,7 +474,7 @@ SW *glue (AUD_open_, TYPE) ( } } else { - sw =3D glue (audio_pcm_create_voice_pair_, TYPE) (name, as); + sw =3D glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as); if (!sw) { dolog ("Failed to create voice `%s'\n", name); return NULL; diff --git a/audio/audio.c b/audio/audio.c index 05adf7ffeb..8d2f580788 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -399,12 +399,10 @@ static void noop_conv (struct st_sample *dst, const v= oid *src, int samples) (void) samples; } =20 -static CaptureVoiceOut *audio_pcm_capture_find_specific ( - struct audsettings *as - ) +static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioState *s, + struct audsettings= *as) { CaptureVoiceOut *cap; - AudioState *s =3D &glob_audio_state; =20 for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { if (audio_pcm_info_eq (&cap->hw.info, as)) { @@ -481,7 +479,7 @@ static void audio_detach_capture (HWVoiceOut *hw) =20 static int audio_attach_capture (HWVoiceOut *hw) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D hw->s; CaptureVoiceOut *cap; =20 audio_detach_capture (hw); @@ -789,19 +787,15 @@ static void audio_pcm_print_info (const char *cap, st= ruct audio_pcm_info *info) /* * Timer */ - -static bool audio_timer_running; -static uint64_t audio_timer_last; - -static int audio_is_timer_needed (void) +static int audio_is_timer_needed(AudioState *s) { HWVoiceIn *hwi =3D NULL; HWVoiceOut *hwo =3D NULL; =20 - while ((hwo =3D audio_pcm_hw_find_any_enabled_out (hwo))) { + while ((hwo =3D audio_pcm_hw_find_any_enabled_out(s, hwo))) { if (!hwo->poll_mode) return 1; } - while ((hwi =3D audio_pcm_hw_find_any_enabled_in (hwi))) { + while ((hwi =3D audio_pcm_hw_find_any_enabled_in(s, hwi))) { if (!hwi->poll_mode) return 1; } return 0; @@ -809,18 +803,18 @@ static int audio_is_timer_needed (void) =20 static void audio_reset_timer (AudioState *s) { - if (audio_is_timer_needed ()) { + if (audio_is_timer_needed(s)) { timer_mod_anticipate_ns(s->ts, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->period_ticks); - if (!audio_timer_running) { - audio_timer_running =3D true; - audio_timer_last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + if (!s->timer_running) { + s->timer_running =3D true; + s->timer_last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); trace_audio_timer_start(s->period_ticks / SCALE_MS); } } else { timer_del(s->ts); - if (audio_timer_running) { - audio_timer_running =3D false; + if (s->timer_running) { + s->timer_running =3D false; trace_audio_timer_stop(); } } @@ -832,11 +826,11 @@ static void audio_timer (void *opaque) AudioState *s =3D opaque; =20 now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - diff =3D now - audio_timer_last; + diff =3D now - s->timer_last; if (diff > s->period_ticks * 3 / 2) { trace_audio_timer_delayed(diff / SCALE_MS); } - audio_timer_last =3D now; + s->timer_last =3D now; =20 audio_run("timer"); audio_reset_timer(s); @@ -890,7 +884,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) =20 hw =3D sw->hw; if (sw->active !=3D on) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D sw->s; SWVoiceOut *temp_sw; SWVoiceCap *sc; =20 @@ -937,7 +931,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) =20 hw =3D sw->hw; if (sw->active !=3D on) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D sw->s; SWVoiceIn *temp_sw; =20 if (on) { @@ -1060,7 +1054,7 @@ static void audio_run_out (AudioState *s) HWVoiceOut *hw =3D NULL; SWVoiceOut *sw; =20 - while ((hw =3D audio_pcm_hw_find_any_enabled_out (hw))) { + while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { int played; int live, free, nb_live, cleanup_required, prev_rpos; =20 @@ -1165,7 +1159,7 @@ static void audio_run_in (AudioState *s) { HWVoiceIn *hw =3D NULL; =20 - while ((hw =3D audio_pcm_hw_find_any_enabled_in (hw))) { + while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { SWVoiceIn *sw; int captured =3D 0, min; =20 @@ -1271,8 +1265,8 @@ static int audio_driver_init(AudioState *s, struct au= dio_driver *drv, s->drv_opaque =3D drv->init(dev); =20 if (s->drv_opaque) { - audio_init_nb_voices_out (drv); - audio_init_nb_voices_in (drv); + audio_init_nb_voices_out(s, drv); + audio_init_nb_voices_in(s, drv); s->drv =3D drv; return 0; } @@ -1293,11 +1287,11 @@ static void audio_vm_change_state_handler (void *op= aque, int running, int op =3D running ? VOICE_ENABLE : VOICE_DISABLE; =20 s->vm_running =3D running; - while ((hwo =3D audio_pcm_hw_find_any_enabled_out (hwo))) { + while ((hwo =3D audio_pcm_hw_find_any_enabled_out(s, hwo))) { hwo->pcm_ops->ctl_out(hwo, op); } =20 - while ((hwi =3D audio_pcm_hw_find_any_enabled_in (hwi))) { + while ((hwi =3D audio_pcm_hw_find_any_enabled_in(s, hwi))) { hwi->pcm_ops->ctl_in(hwi, op); } audio_reset_timer (s); @@ -1317,7 +1311,7 @@ void audio_cleanup(void) HWVoiceIn *hwi, *hwin; =20 is_cleaning_up =3D true; - QLIST_FOREACH_SAFE(hwo, &glob_audio_state.hw_head_out, entries, hwon) { + QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) { SWVoiceCap *sc; =20 if (hwo->enabled) { @@ -1336,7 +1330,7 @@ void audio_cleanup(void) QLIST_REMOVE(hwo, entries); } =20 - QLIST_FOREACH_SAFE(hwi, &glob_audio_state.hw_head_in, entries, hwin) { + QLIST_FOREACH_SAFE(hwi, &s->hw_head_in, entries, hwin) { if (hwi->enabled) { hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE); } @@ -1532,7 +1526,7 @@ CaptureVoiceOut *AUD_add_capture ( cb->ops =3D *ops; cb->opaque =3D cb_opaque; =20 - cap =3D audio_pcm_capture_find_specific (as); + cap =3D audio_pcm_capture_find_specific(s, as); if (cap) { QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); return cap; @@ -1544,6 +1538,7 @@ CaptureVoiceOut *AUD_add_capture ( cap =3D g_malloc0(sizeof(*cap)); =20 hw =3D &cap->hw; + hw->s =3D s; QLIST_INIT (&hw->sw_head); QLIST_INIT (&cap->cb_head); =20 @@ -1564,7 +1559,7 @@ CaptureVoiceOut *AUD_add_capture ( QLIST_INSERT_HEAD (&s->cap_head, cap, entries); QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); =20 - QLIST_FOREACH(hw, &glob_audio_state.hw_head_out, entries) { + QLIST_FOREACH(hw, &s->hw_head_out, entries) { audio_attach_capture (hw); } return cap; --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938350; cv=none; d=zoho.com; s=zohoarc; b=EjCeyS4IN6W0CVPeVaFh/R0A4Z9Kxmjkdcs8yhc2UrwWkiCRNZBvwZIcrkWmTrcMY5XhhPLAqGeXrQ8Uou5qRFPyk910jw6iDHWReOExR+w6oUKTLz7bxc3wVrbBn/IUbKTVmd8F8nlwZKQzOGrK5do62zEFyDztOhrnwWmBdRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938350; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9EOsiPzupC9z3cs4OAkQhKC9rm1e4IxaFYIyQRaOKTQ=; b=Gxos8hJl5AoCHtE69tJJHe5BRv/BrL4rewOMUeKX1tuhJhjg8iKTu/AyMX5wdCJy5VJ9FQjZibMIbUlpc8ww/xUkkVWONUFFu4eFF6P2ItE9Z7YomFBdAyALvfC3ji/TfY2InbOMZsImUWV8y7oTMaAtXNBtm3YFKlTVpJ6io+0= 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 1564938350534180.0250269601429; Sun, 4 Aug 2019 10:05:50 -0700 (PDT) Received: from localhost ([::1]:48850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJx1-00048O-6M for importer@patchew.org; Sun, 04 Aug 2019 13:05:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56591) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw1-0002Ni-8J for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJvz-00044v-0r for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:40 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41925) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJvt-0003zW-F5 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:38 -0400 Received: by mail-wr1-x442.google.com with SMTP id c2so78835304wrm.8 for ; Sun, 04 Aug 2019 10:04:31 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9EOsiPzupC9z3cs4OAkQhKC9rm1e4IxaFYIyQRaOKTQ=; b=CzDbOuXGCNdR7OCfbySu8vSygA3T4aMcpFiOV7ud8baulnUD0valqT1GmRls8NeGxo ZFnLc6ZLFGXn1pGZcHHmzy+8F8U/b4iqeNFjGr2aS3cc2vUEwahdgcYeXBX9qgrXvfNL dt1LorPpKK/i8KXPi4ToTbD0pDYaTUMhF3nLcFyecH/KcH/nesFOdNkIiqJwuSBpNy72 KU7AidpeQP20u7dJ3XLNpPpjGssx7qRlOEKDN1oTnEHSz9O4RsYwkxyFEylvJsOzExY2 YUfYvsimb/Arc1xbl2nsbvmb1Fx1+PKEdIHyTMEKrjGT+IARQ+TNdKqFeDwzGkgUyu/w mbHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9EOsiPzupC9z3cs4OAkQhKC9rm1e4IxaFYIyQRaOKTQ=; b=Sb4iFvCkmxRWhrB0mH6hqV6oz0mgoIVv1Fm/Q4Fjm5pWE6ocReOH7ewqPGRUjBECSk MBPPJmAIA8c0AU70mW40P3VjmAxjUZkUTIxVwJvqVGfCOOkwochqj/7Y+53iXGWNbH5q rpWmrXo0AaD9klXx4BKhdjC1suk7JBZ9FuxvJyqdUrN+oM5bcEn3GcHFpRMVcQJxJXhD VKABh2+7x2sA+tWpURu8+KkhP+EAjf+IVjqfTFoqEnZa1ppBLCoiv5cphxdgS6Lgd7nv h24Zq0v+3htKZOjJR+3hfQIgyEsF/2vjoI+j9bEW5Kun/sKi7yjdtPVpu/Ds4UiqYgNx O2Uw== X-Gm-Message-State: APjAAAWBM6hMJ0yPav0O7XRKiqLrJvWlqpkqK9KvskDEr/Iut5XDQ2g1 ziLSN2IMvvOCCU72TSCyMwpjvRRQ X-Google-Smtp-Source: APXvYqyNN7S3jfPgNq4irbHKj23fbdC9sWKpZ+HSV7D035s1DvDj9ihJ+NcNhgCKEueuxXb5tIv1rA== X-Received: by 2002:adf:dd51:: with SMTP id u17mr6114007wrm.218.1564938270370; Sun, 04 Aug 2019 10:04:30 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Sun, 4 Aug 2019 19:04:14 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v3 02/14] audio: basic support for multi backend audio X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Dr. David Alan Gilbert" , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Audio functions no longer access glob_audio_state, instead they get an AudioState as a parameter. This is required in order to support multiple backends. glob_audio_state is also gone, and replaced with a tailq so we can store more than one states. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- Notes: Changes from v1: =20 * Moved wav_capture/vnc audiodev param to a separate commit audio/audio.h | 12 +++-- audio/audio_int.h | 2 + audio/audio_template.h | 2 +- audio/audio.c | 102 +++++++++++++++++++++++++++++++---------- audio/wavcapture.c | 6 +-- monitor/misc.c | 2 +- ui/vnc.c | 2 +- 7 files changed, 95 insertions(+), 33 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index 64b0f761bc..ad2457f4de 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -78,8 +78,10 @@ typedef struct SWVoiceOut SWVoiceOut; typedef struct CaptureVoiceOut CaptureVoiceOut; typedef struct SWVoiceIn SWVoiceIn; =20 +typedef struct AudioState AudioState; typedef struct QEMUSoundCard { char *name; + AudioState *state; QLIST_ENTRY (QEMUSoundCard) entries; } QEMUSoundCard; =20 @@ -92,7 +94,8 @@ void AUD_log (const char *cap, const char *fmt, ...) GCC_= FMT_ATTR(2, 3); =20 void AUD_register_card (const char *name, QEMUSoundCard *card); void AUD_remove_card (QEMUSoundCard *card); -CaptureVoiceOut *AUD_add_capture ( +CaptureVoiceOut *AUD_add_capture( + AudioState *s, struct audsettings *as, struct audio_capture_ops *ops, void *opaque @@ -160,8 +163,8 @@ static inline void *advance (void *p, int incr) #define audio_MAX(a, b) ((a)<(b)?(b):(a)) #endif =20 -int wav_start_capture (CaptureState *s, const char *path, int freq, - int bits, int nchannels); +int wav_start_capture(AudioState *state, CaptureState *s, const char *path, + int freq, int bits, int nchannels); =20 bool audio_is_cleaning_up(void); void audio_cleanup(void); @@ -175,4 +178,7 @@ void audio_parse_option(const char *opt); void audio_init_audiodevs(void); void audio_legacy_help(void); =20 +AudioState *audio_state_by_name(const char *name); +const char *audio_get_id(QEMUSoundCard *card); + #endif /* QEMU_AUDIO_H */ diff --git a/audio/audio_int.h b/audio/audio_int.h index 8164696b2c..9f01f6ad00 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -196,6 +196,8 @@ typedef struct AudioState { =20 bool timer_running; uint64_t timer_last; + + QTAILQ_ENTRY(AudioState) list; } AudioState; =20 extern const struct mixeng_volume nominal_volume; diff --git a/audio/audio_template.h b/audio/audio_template.h index c721fed75d..54f07338e7 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -428,7 +428,7 @@ SW *glue (AUD_open_, TYPE) ( struct audsettings *as ) { - AudioState *s =3D &glob_audio_state; + AudioState *s =3D card->state; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 if (audio_bug(__func__, !card || !name || !callback_fn || !as)) { diff --git a/audio/audio.c b/audio/audio.c index 8d2f580788..4baa37caac 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -87,7 +87,8 @@ audio_driver *audio_driver_lookup(const char *name) return NULL; } =20 -static AudioState glob_audio_state; +static QTAILQ_HEAD(AudioStateHead, AudioState) audio_states =3D + QTAILQ_HEAD_INITIALIZER(audio_states); =20 const struct mixeng_volume nominal_volume =3D { .mute =3D 0, @@ -1236,11 +1237,14 @@ static void audio_run_capture (AudioState *s) =20 void audio_run (const char *msg) { - AudioState *s =3D &glob_audio_state; + AudioState *s; + + QTAILQ_FOREACH(s, &audio_states, list) { + audio_run_out(s); + audio_run_in(s); + audio_run_capture(s); + } =20 - audio_run_out (s); - audio_run_in (s); - audio_run_capture (s); #ifdef DEBUG_POLL { static double prevtime; @@ -1304,13 +1308,11 @@ bool audio_is_cleaning_up(void) return is_cleaning_up; } =20 -void audio_cleanup(void) +static void free_audio_state(AudioState *s) { - AudioState *s =3D &glob_audio_state; HWVoiceOut *hwo, *hwon; HWVoiceIn *hwi, *hwin; =20 - is_cleaning_up =3D true; QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) { SWVoiceCap *sc; =20 @@ -1347,6 +1349,17 @@ void audio_cleanup(void) qapi_free_Audiodev(s->dev); s->dev =3D NULL; } + g_free(s); +} + +void audio_cleanup(void) +{ + is_cleaning_up =3D true; + while (!QTAILQ_EMPTY(&audio_states)) { + AudioState *s =3D QTAILQ_FIRST(&audio_states); + QTAILQ_REMOVE(&audio_states, s, list); + free_audio_state(s); + } } =20 static const VMStateDescription vmstate_audio =3D { @@ -1373,28 +1386,33 @@ static AudiodevListEntry *audiodev_find( return NULL; } =20 -static int audio_init(Audiodev *dev) +/* + * if we have dev, this function was called because of an -audiodev argume= nt =3D> + * initialize a new state with it + * if dev =3D=3D NULL =3D> legacy implicit initialization, return the alre= ady created + * state or create a new one + */ +static AudioState *audio_init(Audiodev *dev) { + static bool atexit_registered; size_t i; int done =3D 0; const char *drvname =3D NULL; VMChangeStateEntry *e; - AudioState *s =3D &glob_audio_state; + AudioState *s; struct audio_driver *driver; /* silence gcc warning about uninitialized variable */ AudiodevListHead head =3D QSIMPLEQ_HEAD_INITIALIZER(head); =20 - if (s->drv) { - if (dev) { - dolog("Cannot create more than one audio backend, sorry\n"); - qapi_free_Audiodev(dev); - } - return -1; - } - if (dev) { /* -audiodev option */ drvname =3D AudiodevDriver_str(dev->driver); + } else if (!QTAILQ_EMPTY(&audio_states)) { + /* + * todo: check for -audiodev once we have normal audiodev selection + * support + */ + return QTAILQ_FIRST(&audio_states); } else { /* legacy implicit initialization */ head =3D audio_handle_legacy_opts(); @@ -1408,12 +1426,18 @@ static int audio_init(Audiodev *dev) dev =3D QSIMPLEQ_FIRST(&head)->dev; audio_validate_opts(dev, &error_abort); } + + s =3D g_malloc0(sizeof(AudioState)); s->dev =3D dev; =20 QLIST_INIT (&s->hw_head_out); QLIST_INIT (&s->hw_head_in); QLIST_INIT (&s->cap_head); - atexit(audio_cleanup); + if (!atexit_registered) { + atexit(audio_cleanup); + atexit_registered =3D true; + } + QTAILQ_INSERT_TAIL(&audio_states, s, list); =20 s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); =20 @@ -1478,7 +1502,7 @@ static int audio_init(Audiodev *dev) =20 QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); - return 0; + return s; } =20 void audio_free_audiodev_list(AudiodevListHead *head) @@ -1493,10 +1517,13 @@ void audio_free_audiodev_list(AudiodevListHead *hea= d) =20 void AUD_register_card (const char *name, QEMUSoundCard *card) { - audio_init(NULL); + if (!card->state) { + card->state =3D audio_init(NULL); + } + card->name =3D g_strdup (name); memset (&card->entries, 0, sizeof (card->entries)); - QLIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries); + QLIST_INSERT_HEAD(&card->state->card_head, card, entries); } =20 void AUD_remove_card (QEMUSoundCard *card) @@ -1506,16 +1533,21 @@ void AUD_remove_card (QEMUSoundCard *card) } =20 =20 -CaptureVoiceOut *AUD_add_capture ( +CaptureVoiceOut *AUD_add_capture( + AudioState *s, struct audsettings *as, struct audio_capture_ops *ops, void *cb_opaque ) { - AudioState *s =3D &glob_audio_state; CaptureVoiceOut *cap; struct capture_callback *cb; =20 + if (!s) { + /* todo: remove when we have normal audiodev selection support */ + s =3D audio_init(NULL); + } + if (audio_validate_settings (as)) { dolog ("Invalid settings were passed when trying to add capture\n"= ); audio_print_settings (as); @@ -1805,3 +1837,25 @@ int audio_buffer_bytes(AudiodevPerDirectionOptions *= pdo, return audio_buffer_samples(pdo, as, def_usecs) * audioformat_bytes_per_sample(as->fmt); } + +AudioState *audio_state_by_name(const char *name) +{ + AudioState *s; + QTAILQ_FOREACH(s, &audio_states, list) { + assert(s->dev); + if (strcmp(name, s->dev->id) =3D=3D 0) { + return s; + } + } + return NULL; +} + +const char *audio_get_id(QEMUSoundCard *card) +{ + if (card->state) { + assert(card->state->dev); + return card->state->dev->id; + } else { + return ""; + } +} diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 74320dfecc..81c5c19032 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -105,8 +105,8 @@ static struct capture_ops wav_capture_ops =3D { .info =3D wav_capture_info }; =20 -int wav_start_capture (CaptureState *s, const char *path, int freq, - int bits, int nchannels) +int wav_start_capture(AudioState *state, CaptureState *s, const char *path, + int freq, int bits, int nchannels) { WAVState *wav; uint8_t hdr[] =3D { @@ -171,7 +171,7 @@ int wav_start_capture (CaptureState *s, const char *pat= h, int freq, goto error_free; } =20 - cap =3D AUD_add_capture (&as, &ops, wav); + cap =3D AUD_add_capture(state, &as, &ops, wav); if (!cap) { error_report("Failed to add audio capture"); goto error_free; diff --git a/monitor/misc.c b/monitor/misc.c index 00338c002a..e393333a0e 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1156,7 +1156,7 @@ static void hmp_wavcapture(Monitor *mon, const QDict = *qdict) bits =3D has_bits ? bits : 16; nchannels =3D has_channels ? nchannels : 2; =20 - if (wav_start_capture (s, path, freq, bits, nchannels)) { + if (wav_start_capture(NULL, s, path, freq, bits, nchannels)) { monitor_printf(mon, "Failed to add wave capture\n"); g_free (s); return; diff --git a/ui/vnc.c b/ui/vnc.c index 38f92bfca3..140f364dda 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1222,7 +1222,7 @@ static void audio_add(VncState *vs) ops.destroy =3D audio_capture_destroy; ops.capture =3D audio_capture; =20 - vs->audio_cap =3D AUD_add_capture(&vs->as, &ops, vs); + vs->audio_cap =3D AUD_add_capture(NULL, &vs->as, &ops, vs); if (!vs->audio_cap) { error_report("Failed to add audio capture"); } --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938350; cv=none; d=zoho.com; s=zohoarc; b=lNRBPB1QVStXgHphHUvWR9SUtQV8Oep6AKIu5arINIGSQyCzBPL9DcZqdmOAN6fspbMudiG3ZZptrTqcSX2RtYjP1XaO05Kb7Ux9ardJlWJRU95q8rEbILHpwKtY0nRP1jQKRaV0LmMGicW8gU9szXRor5k/RCDBN9kpy3CYekE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938350; 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=zmwu7QnhjoOubCcj+gXAWMt870pR20NYhJgBFOm+pcY=; b=KLMTHWVneNIQYyC1FCg0/d3hlxxm8W2c1xcRAD+CEZ+UIMxuaDLgWO1JjlkH9RPV/O9Xe8iSQJ/YwITUnFjsxrCrlv5kHRXu64EGI6t56eiw0U7e2rD1BNQu+V3C8vby0SznKuuZUBFDqqVuoa/5KlYNM9OSbRgPxBlPaqVvcdE= 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 1564938350858837.971804995754; Sun, 4 Aug 2019 10:05:50 -0700 (PDT) Received: from localhost ([::1]:48848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJx0-000479-Oz for importer@patchew.org; Sun, 04 Aug 2019 13:05:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56698) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw4-0002OC-T0 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw2-00048H-KS for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:44 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34459) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw1-0003ze-Fv for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:42 -0400 Received: by mail-wr1-x443.google.com with SMTP id 31so82085050wrm.1 for ; Sun, 04 Aug 2019 10:04:32 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zmwu7QnhjoOubCcj+gXAWMt870pR20NYhJgBFOm+pcY=; b=jEqVo2fK+2u6XPFW8INx6LlrDfFO3fChm2iVibxrS0maywteoVZ+UFS2B+GeLNHL+H oiOakOtpquPjRzFZcv8Dx96mTL6UKBFwn7lN8P/lcYOPEooZg1fYRdHC8ykl7SCKqxS/ 90HzVoarARcEMCIgEFqDzKX6BhHH4jIByVTOhaMuuDbL5VdRhGiFflyolfGiNU8RGwdw qjwHpEaMYvR3A23NwAnfVC06Hh52Z7eaFj2NxrZeXRgGdV9IBZYKQnaVMFNs9xkAAyuc xiy0Qt6wSXpde57tgNbKZ61gdCZl/hYxU/BAmZAlnz6fYu0OVwVfOzAyavpqM0mmhIvW J/Ow== 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=zmwu7QnhjoOubCcj+gXAWMt870pR20NYhJgBFOm+pcY=; b=WrYCZ/tNHKuTX1JNcJZEopM64ekHDtEe2rR4BpI/JD3zFgKsolNcyj3yvwXbzpukOE s70SpE35Ypg2xA/yVwFnVkR7iFAjAebVJvIeLeFbiF3MFUc6IJLKXKpAJmFeCEHQu+3a IUGpC825+ukqQFj2/RnaPC2mfNCiJ6SWDMC0iF2p5UT3zqOZktL4QzFiy7YWzTWksPo/ YkkVW+cNQHZ+TEy/8j+wYIs3FHzsSE1AhkKxCPfhj7dg5YClHCpXyujhNgSAM/eA6SnA h6n7B0BL3UMG24fQVT7Dr/EYA2VHCyNnWZSRMITdHlvze7vMVDcxQKbfLqSxLCIX5kvn pkYA== X-Gm-Message-State: APjAAAXsLlCMsT9y5QUsBC3jSlDbuWVNpsfOQx6zEOhhsm2bpbvY+pC6 xNdPiLV4v9WYYMoVPmgr8NJs2REs X-Google-Smtp-Source: APXvYqyLclFUfHfrCqTS3tSz9ri/yc/kTX6beKbxSClOGZIZuosdye6wvqea+k/HfLrDQqvMb54WKA== X-Received: by 2002:adf:cc85:: with SMTP id p5mr148494496wrj.47.1564938271149; Sun, 04 Aug 2019 10:04:31 -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: Sun, 4 Aug 2019 19:04:15 +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::443 Subject: [Qemu-devel] [PATCH v3 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 Acked-by: Dr. David Alan Gilbert --- 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 2f84db3142..6f54653455 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -183,6 +183,8 @@ struct VncDisplay #ifdef CONFIG_VNC_SASL VncDisplaySASL sasl; #endif + + AudioState *audio_state; }; =20 typedef struct VncTight { diff --git a/monitor/misc.c b/monitor/misc.c index e393333a0e..bdf857555f 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 140f364dda..24f9be5b5d 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1222,7 +1222,7 @@ static void audio_add(VncState *vs) ops.destroy =3D audio_capture_destroy; ops.capture =3D audio_capture; =20 - vs->audio_cap =3D AUD_add_capture(NULL, &vs->as, &ops, vs); + vs->audio_cap =3D AUD_add_capture(vs->vd->audio_state, &vs->as, &ops, = vs); if (!vs->audio_cap) { error_report("Failed to add audio capture"); } @@ -3369,6 +3369,9 @@ static QemuOptsList qemu_vnc_opts =3D { },{ .name =3D "non-adaptive", .type =3D QEMU_OPT_BOOL, + },{ + .name =3D "audiodev", + .type =3D QEMU_OPT_STRING, }, { /* end of list */ } }, @@ -3806,6 +3809,7 @@ void vnc_display_open(const char *id, Error **errp) const char *saslauthz; int lock_key_sync =3D 1; int key_delay_ms; + const char *audiodev; =20 if (!vd) { error_setg(errp, "VNC display not active"); @@ -3991,6 +3995,15 @@ void vnc_display_open(const char *id, Error **errp) } vd->ledstate =3D 0; =20 + audiodev =3D qemu_opt_get(opts, "audiodev"); + if (audiodev) { + vd->audio_state =3D audio_state_by_name(audiodev); + if (!vd->audio_state) { + error_setg(errp, "Audiodev '%s' not found", audiodev); + goto fail; + } + } + device_id =3D qemu_opt_get(opts, "display"); if (device_id) { int head =3D qemu_opt_get_number(opts, "head", 0); diff --git a/hmp-commands.hx b/hmp-commands.hx index bfa5681dd2..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 Tue Apr 30 01:16:34 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=1564938665; cv=none; d=zoho.com; s=zohoarc; b=dXpry/ZXiDrwOPLsEtQdBVnTSHl98THN2XYnX716W95POA4MUTRFcpu7RFHTaTynanYE2m8h2phYG3sllZmY845zgJp4z65WUcMl75sYgwsiHZJC6vc3rg6YACqSNiY8vgcLUMXtJEirzyiBMIcGYi7uL4mtheLhYrg1i8Wkd50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938665; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=THYF8P8oP1LtFmW+vLVidPiCPGgRINpP2KqOOOP7jgY=; b=SY0UVvAaFxEiRASoPFsxcFouPgApf1b6Du5L3ykL+s/a6S61b5G7rSCn78voG0OZOnQxYizLyl4Gyot9v2hqDSrOLEecA3+2Cs8fDn0ys+BSPlApKLJytNm2CKqyWhW3ZSCGhSVgjWX9oGDlxjc56LXmo2F+Tj063+Fmd2BapB8= 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 1564938665702607.4516110533684; Sun, 4 Aug 2019 10:11:05 -0700 (PDT) Received: from localhost ([::1]:48938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huK24-0006vm-OD for importer@patchew.org; Sun, 04 Aug 2019 13:10:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56755) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw8-0002Q4-Bk for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw2-00047p-Ha for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:37854) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw1-0003zt-8D for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:41 -0400 Received: by mail-wr1-x442.google.com with SMTP id n9so56986361wrr.4 for ; Sun, 04 Aug 2019 10:04:33 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=THYF8P8oP1LtFmW+vLVidPiCPGgRINpP2KqOOOP7jgY=; b=KoKn3CnfUjVOoaheuZgr84aZZATQq/pFoDCO6nlvnAGK8qMZaLIVXXp452yRpXVYyl jKt2D++6y+GLMGaHuwD4hpnU5+if2tgibm/m+t/sSK2WZlu2Yi6aynlH1rZFxJ5oPCE/ ZabryTedTu/6ht5dV3ReZj2Cfc+vWQ7LZYwJqRCRdBqJuZAloMRnfrsdbiBV+Ny/47XQ F0gQnDP031KvZXaDf9PXetSDK8sAWOijYb/qDigtM5WF32eR6Ueb9eOB1V3rwjJfzvf9 9c+n0SFrHJwDaX+1c5VGt1s8neIU2BFR5z0Umz+7alsIUhPY8/b99m7IZjYbtHmpSy47 D6/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=THYF8P8oP1LtFmW+vLVidPiCPGgRINpP2KqOOOP7jgY=; b=WsFcgFA9MYkFnVmOO/em1L9rWCpfA6P+JAGubLHQ2siWOEYUhTmkeVXO0ORC/aEW5l wV5G9eZ4rC/CErhLvM4hQ9AZoOcgVaUOr2ya4A+vzMDo4NXLGajG4piSCaOTN9ncGVdF 8Qwv6RuOky/qgtr54L9ZcLXxxLZQcktqf3A8BKDTKGqmw/RZO1JZsZNalIXbdZMukIih 2lxUzUle5GxXPoF54HsS4yhdBzHxeYvspO82cYZg6IRGCX7PLjFmHTFAh1C+VBTKgpQi 0bVLTJ22oxW/F+dng+37DykJWRVpxTaY+47oVN6wfwNt55UfyMNgBmN+c6/vnGdB3XEC 3HqQ== X-Gm-Message-State: APjAAAUmI6NWwWBq9g/b85W7iQ5CvUG1nCDGfbkDNlZqeICHMfxnPasn R6N5j4BN5sRkY9KVu8luAEaXBD+3X20= X-Google-Smtp-Source: APXvYqzjE9NIyj92H21U4XQqHFtGDtofJHlQ6MG+4Zka+NixhOjI9eiJ+q4ItVw+5lh5YCiVKSRcrg== X-Received: by 2002:adf:eec4:: with SMTP id a4mr147204065wrp.85.1564938272155; Sun, 04 Aug 2019 10:04:32 -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: Sun, 4 Aug 2019 19:04:16 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v3 04/14] audio: add audiodev properties to frontends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Michael Walle , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Finally add audiodev=3D options to audio frontends so users can specify which backend to use when multiple backends exist. Not specifying an audiodev=3D option currently causes the first audiodev to be used, this is fixed in the next commit. Example usage: -audiodev pa,id=3Dfoo -device AC97,audiodev=3Dfoo Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.h | 3 ++ include/hw/qdev-properties.h | 3 ++ hw/audio/ac97.c | 1 + hw/audio/adlib.c | 1 + hw/audio/cs4231a.c | 1 + hw/audio/es1370.c | 7 +++- hw/audio/gus.c | 1 + hw/audio/hda-codec.c | 1 + hw/audio/milkymist-ac97.c | 6 ++++ hw/audio/pcspk.c | 1 + hw/audio/pl041.c | 1 + hw/audio/sb16.c | 1 + hw/audio/wm8750.c | 6 ++++ hw/core/qdev-properties-system.c | 57 ++++++++++++++++++++++++++++++++ hw/usb/dev-audio.c | 1 + 15 files changed, 90 insertions(+), 1 deletion(-) diff --git a/audio/audio.h b/audio/audio.h index ad2457f4de..c0722a5cda 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -181,4 +181,7 @@ void audio_legacy_help(void); AudioState *audio_state_by_name(const char *name); const char *audio_get_id(QEMUSoundCard *card); =20 +#define DEFINE_AUDIO_PROPERTIES(_s, _f) \ + DEFINE_PROP_AUDIODEV("audiodev", _s, _f) + #endif /* QEMU_AUDIO_H */ diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 1eae5ab056..de0b2c8423 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -35,6 +35,7 @@ extern const PropertyInfo qdev_prop_blocksize; extern const PropertyInfo qdev_prop_pci_host_devaddr; extern const PropertyInfo qdev_prop_uuid; extern const PropertyInfo qdev_prop_arraylen; +extern const PropertyInfo qdev_prop_audiodev; extern const PropertyInfo qdev_prop_link; extern const PropertyInfo qdev_prop_off_auto_pcibar; extern const PropertyInfo qdev_prop_pcie_link_speed; @@ -236,6 +237,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width; + type_check(QemuUUID, typeof_field(_state, _field)), \ .set_default =3D true, \ } +#define DEFINE_PROP_AUDIODEV(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard) =20 #define DEFINE_PROP_END_OF_LIST() \ {} diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index fb98da2678..0d8e524233 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -1409,6 +1409,7 @@ static int ac97_init (PCIBus *bus) } =20 static Property ac97_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(AC97LinkState, card), DEFINE_PROP_UINT32 ("use_broken_id", AC97LinkState, use_broken_id, 0), DEFINE_PROP_END_OF_LIST (), }; diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index 7dd9a89b89..df2e781788 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -299,6 +299,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) } =20 static Property adlib_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(AdlibState, card), DEFINE_PROP_UINT32 ("iobase", AdlibState, port, 0x220), DEFINE_PROP_UINT32 ("freq", AdlibState, freq, 44100), DEFINE_PROP_END_OF_LIST (), diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 7216b41cc1..e3ea830b47 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -689,6 +689,7 @@ static int cs4231a_init (ISABus *bus) } =20 static Property cs4231a_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(CSState, card), DEFINE_PROP_UINT32 ("iobase", CSState, port, 0x534), DEFINE_PROP_UINT32 ("irq", CSState, irq, 9), DEFINE_PROP_UINT32 ("dma", CSState, dma, 3), diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 260c142b70..7589671d20 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -887,6 +887,11 @@ static int es1370_init (PCIBus *bus) return 0; } =20 +static Property es1370_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(ES1370State, card), + DEFINE_PROP_END_OF_LIST(), +}; + static void es1370_class_init (ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS (klass); @@ -903,6 +908,7 @@ static void es1370_class_init (ObjectClass *klass, void= *data) dc->desc =3D "ENSONIQ AudioPCI ES1370"; dc->vmsd =3D &vmstate_es1370; dc->reset =3D es1370_on_reset; + dc->props =3D es1370_properties; } =20 static const TypeInfo es1370_info =3D { @@ -923,4 +929,3 @@ static void es1370_register_types (void) } =20 type_init (es1370_register_types) - diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 9ab51631d9..566864bc9e 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -297,6 +297,7 @@ static int GUS_init (ISABus *bus) } =20 static Property gus_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(GUSState, card), DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100), DEFINE_PROP_UINT32 ("iobase", GUSState, port, 0x240), DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7), diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 84639b5424..967a10f189 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -840,6 +840,7 @@ static const VMStateDescription vmstate_hda_audio =3D { }; =20 static Property hda_audio_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(HDAAudioState, card), DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0), DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true), DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer, true), diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index bf6a5a6b96..4835229326 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -329,6 +329,11 @@ static const VMStateDescription vmstate_milkymist_ac97= =3D { } }; =20 +static Property milkymist_ac97_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(MilkymistAC97State, card), + DEFINE_PROP_END_OF_LIST(), +}; + static void milkymist_ac97_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -336,6 +341,7 @@ static void milkymist_ac97_class_init(ObjectClass *klas= s, void *data) dc->realize =3D milkymist_ac97_realize; dc->reset =3D milkymist_ac97_reset; dc->vmsd =3D &vmstate_milkymist_ac97; + dc->props =3D milkymist_ac97_properties; } =20 static const TypeInfo milkymist_ac97_info =3D { diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index a7b3ab0c2b..01127304c2 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -209,6 +209,7 @@ static const VMStateDescription vmstate_spk =3D { }; =20 static Property pcspk_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(PCSpkState, card), DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1), DEFINE_PROP_BOOL("migrate", PCSpkState, migrate, true), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/audio/pl041.c b/hw/audio/pl041.c index 59c6ce1f2e..ce430a7821 100644 --- a/hw/audio/pl041.c +++ b/hw/audio/pl041.c @@ -622,6 +622,7 @@ static const VMStateDescription vmstate_pl041 =3D { }; =20 static Property pl041_device_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(PL041State, codec.card), /* Non-compact FIFO depth property */ DEFINE_PROP_UINT32("nc_fifo_depth", PL041State, fifo_depth, DEFAULT_FIFO_DEPTH), diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index a2db06a2bb..6b604979cf 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1421,6 +1421,7 @@ static int SB16_init (ISABus *bus) } =20 static Property sb16_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(SB16State, card), DEFINE_PROP_UINT32 ("version", SB16State, ver, 0x0405), /* 4.5 */ DEFINE_PROP_UINT32 ("iobase", SB16State, port, 0x220), DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5), diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index 81f83eea88..dfb4156ff4 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -701,6 +701,11 @@ void wm8750_set_bclk_in(void *opaque, int new_hz) wm8750_clk_update(s, 1); } =20 +static Property wm8750_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(WM8750State, card), + DEFINE_PROP_END_OF_LIST(), +}; + static void wm8750_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -711,6 +716,7 @@ static void wm8750_class_init(ObjectClass *klass, void = *data) sc->recv =3D wm8750_rx; sc->send =3D wm8750_tx; dc->vmsd =3D &vmstate_wm8750; + dc->props =3D wm8750_properties; } =20 static const TypeInfo wm8750_info =3D { diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index ba412dd2ca..bf9974370c 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -11,6 +11,7 @@ */ =20 #include "qemu/osdep.h" +#include "audio/audio.h" #include "net/net.h" #include "hw/qdev.h" #include "qapi/error.h" @@ -353,6 +354,62 @@ const PropertyInfo qdev_prop_netdev =3D { }; =20 =20 +/* --- audiodev --- */ +static void get_audiodev(Object *obj, Visitor *v, const char* name, + void *opaque, Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + QEMUSoundCard *card =3D qdev_get_prop_ptr(dev, prop); + char *p =3D g_strdup(audio_get_id(card)); + + visit_type_str(v, name, &p, errp); + g_free(p); +} + +static void set_audiodev(Object *obj, Visitor *v, const char* name, + void *opaque, Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + QEMUSoundCard *card =3D qdev_get_prop_ptr(dev, prop); + AudioState *state; + Error *local_err =3D NULL; + int err =3D 0; + char *str; + + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + + visit_type_str(v, name, &str, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + state =3D audio_state_by_name(str); + + if (!state) { + err =3D -ENOENT; + goto out; + } + card->state =3D state; + +out: + error_set_from_qdev_prop_error(errp, err, dev, prop, str); + g_free(str); +} + +const PropertyInfo qdev_prop_audiodev =3D { + .name =3D "str", + .description =3D "ID of an audiodev to use as a backend", + /* release done on shutdown */ + .get =3D get_audiodev, + .set =3D set_audiodev, +}; + void qdev_prop_set_drive(DeviceState *dev, const char *name, BlockBackend *value, Error **errp) { diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 718ab53cbb..1b1cf91132 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -666,6 +666,7 @@ static const VMStateDescription vmstate_usb_audio =3D { }; =20 static Property usb_audio_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(USBAudioState, card), DEFINE_PROP_UINT32("debug", USBAudioState, debug, 0), DEFINE_PROP_UINT32("buffer", USBAudioState, buffer, 32 * USBAUDIO_PACKET_SIZE), --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938600; cv=none; d=zoho.com; s=zohoarc; b=Fi4E9HaotmogkLqYY2vRUBi01SI2tne4KpEqYhMe0uwcZpcO6MB5eLhCzxN19o+419IuaYcXNwUXJFu1bwGdNXq2ghH1x3CfWUl/LDjUNQQ4QhbnPStCmkwOKYgNUPl3ey7vmM6dsYX7n24pP2Tbp6PKTvfFLMKgjJCM3s9PRPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938600; 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=FQBwPj1lS+nkjsV9XcKkf7IvWPZGno6MspY0zQudv6fRIaGiyb7Eh/P3AtNeAPqjWOHzOpQktJEI7ahMCwC8RV8JFh71EPHZ41sYKGBrfJkbOiixjzUVLfZEViKHo7Z61oGPO3/KxOjR8fIwqS8Xy5LVDMFGra7GUvPpf6AdQWw= 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 1564938600927825.8954409354791; Sun, 4 Aug 2019 10:10:00 -0700 (PDT) Received: from localhost ([::1]:48932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huK19-0005xn-Vm for importer@patchew.org; Sun, 04 Aug 2019 13:09:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56769) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw9-0002QF-AQ for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw2-00047u-IN for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36141) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw1-00040F-9D for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:41 -0400 Received: by mail-wm1-x342.google.com with SMTP id g67so66750633wme.1 for ; Sun, 04 Aug 2019 10:04:34 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:32 -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=dzwzljh0yyfDUu7+j0V8vmHebIfoy3nCzo/eLnsp/m3Ugiab8rt1jCEq9VonPR/HdU Sa6JfikC13DjMzzQqMEdWY1LqGRHmNOXP/awJuIbSRH2NgrazcIYuJSuPUgfMMOKluMx 0cOOO4z9TuPBuoaLx8MNNMhWDak5UxVXPanvwO73c/LOvjeFSL68bypKE7Q0Jdad3tmj GgCuO12B/tdQfVQy/L6cNmPQ+108EOyjGX4JvVTV1XGMUbBpYLaNjG57CkxOQuGZRJHV Sq4K0A472q1TEHyH9MnhLuNgVVFujGR+Qeby+TxhnbXa+UixH2LoiU/UoP8EcblxlaCi DSjw== 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=WbOnNeUE96kKzep79FqIxkn/XUQj0/v5bPu9v3yIhqpK4FlhXoC5fUGzF1zNQSQuz+ 0rBxwmEDT2mD2nE4Ekc1H6rYJ3h6Efj1IXyW7wvDwzOE6JzoWBeNOaty1YwD++Aj3SfI q/oMtODRXCp0FPLhtkl0ecyZeKW3md5KZMjXSudjoRvHskCcNacgnjmySXe0dc+Te/tc dSsVRXqtfQuiQn+Peu98/+pYaJRKiRWbjet7oQdYjj3veG56cuBv1tt/U4H+VHyqlYf5 Fu+qO2yxjUq6UAKJ+uvrFeKh12Khu77RIJ1ewXuyYuutJJPWmDt6eJlji/Lh1qsIg95i 26pg== X-Gm-Message-State: APjAAAWUwn7k7nKDuB+yn63P57mjtyeETOvWKN64D1l6E8FbV8o9nNBL JZgXXcvsqVXBR2zPqPSq09w/0BY7Enc= X-Google-Smtp-Source: APXvYqzPiDQ+kYRzcjXLXnhTLvl6r4RoIbJn+myLEE6N9YquviXoqmhkzJhvK3Pz1DuwxyArbF+D7A== X-Received: by 2002:a1c:988a:: with SMTP id a132mr14033644wme.165.1564938272950; Sun, 04 Aug 2019 10:04:32 -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: Sun, 4 Aug 2019 19:04:17 +0200 Message-Id: <45d00e97d64544d645291454a7b09ce33dbca85c.1564925486.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 v3 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 Tue Apr 30 01:16:34 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=1564938471; cv=none; d=zoho.com; s=zohoarc; b=la6RRQexofzCxmUVvwhqlLXyCdD585yAzN5SVb1gwVY2dwRxsyj1D0ca9SukghDaGnarZLbuadtbQQu3BXXDgeCE7fsfZmVdxV2Oq7Jt58U8pKk5E7sXrCqEO2VdI6YpzDx7h9muoJzVN/1CQmVcd7CSUXOrUP1irR9q1uQ4gqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938471; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PksipMVzAiiMTAlABLCmlNruZKZ2bg95M8Q+Ha0hlqQ=; b=jtAC3a7CWIgMxpHVHfqt5+DqOEDxegx3UEUPzVsH9r1UfXtSIGkiiVul/069D+5XfaGywfnn4Xm1LJ4ayWdDloS/xYyOmKdfc9wL8LCUywahiPRja2Z8QiYr/3HV1vgQzmjy03GVIIra1MpMmQr6qjk99nTLup600fn85VtX3m4= 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 1564938471422372.72753683062035; Sun, 4 Aug 2019 10:07:51 -0700 (PDT) Received: from localhost ([::1]:48888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJz4-0001FW-Gj for importer@patchew.org; Sun, 04 Aug 2019 13:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56751) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw7-0002Pv-RL for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw3-00049X-Az for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:45 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw3-00040Q-1r for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:43 -0400 Received: by mail-wr1-x443.google.com with SMTP id p17so82047421wrf.11 for ; Sun, 04 Aug 2019 10:04:34 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PksipMVzAiiMTAlABLCmlNruZKZ2bg95M8Q+Ha0hlqQ=; b=sFjtWgdnNg98Urrin4BYTtOENReVLX3VsN5naYziLh/Y6A2sUcga5FB5Qne4gUEibg AqF3hiXfblFUjCnNgypJ813/jk6hovuu6TDYYKw4MflCBbY2GQeoM2ttRhXhuqwaZBUi KQoay9RoB+VSx7y0yhIv8rdd95gQhCxTO0Esx90wM06+S9yFn4IKi/MWhxHBij9nQa6i bdN6P6bRl5rDUqKC8p2sirfuf2JpwMFgm2bA1H9MAESuzhhui5tglIJ8b44gsO6VEjeJ CD4lbnAHX1K/60T5OT4tSsj03VVSBQJGdWos6Wb13Nmh+zwuF0LExL2Yb9Xervcl2dTO uXaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PksipMVzAiiMTAlABLCmlNruZKZ2bg95M8Q+Ha0hlqQ=; b=npDINRtlnBLhQTdLP2l80BFgQFjz67IQmurDWni05Z3+h614wKQQoTZmIxnEWZbIfq sBsGMGNaLk4/XZvqnROnsIRoQpxpbgQY5Ialzk6+9l2o0F3s/zZ7kqeYey+SKIey/OvP o5C0LLuWHDAkyhJzx8gUpl6QxEQFsEA3SP6K66R6iCKYVOa3ooVF/g7mWZ8ZemvTZhDY HdFTliYSBUI9/tipF146Y5co4oI445Uaup/tm/HzK5Gxp4ykKMo2bYrJpUwkUOFSIFDG uHMl6PlWoBnhdm+UYs0R5rhxiM/xygHNelyXbx+Xdr6qoJA42F4BUyaH9uVLhEUh1sww lPKg== X-Gm-Message-State: APjAAAX7oTjyo8WSqzJf4u88U5dZyX8P1szYr51eAT53G5AMCJotR1g9 2EDgO08Zqaev/3Pl9pA/T4HIJrPRuYc= X-Google-Smtp-Source: APXvYqxT8hCtITiFtyszZ5HCoHc4+cRVmDKjO6caNxyRzQudCUVcaob9/82Qly2A/fry744F9s10vQ== X-Received: by 2002:a5d:5302:: with SMTP id e2mr5201889wrv.347.1564938273955; Sun, 04 Aug 2019 10:04:33 -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: Sun, 4 Aug 2019 19:04:18 +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::443 Subject: [Qemu-devel] [PATCH v3 06/14] audio: audiodev= parameters no longer optional when -audiodev present X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This means you should probably stop using -soundhw (as it doesn't allow you to specify any options) and add the device manually with -device. The exception is pcspk, it's currently not possible to manually add it. To use it with audiodev, use something like this: -audiodev id=3Dfoo,... -global isa-pcspk.audiodev=3Dfoo -soundhw pcspk Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- Notes: Changes from v1: =20 * Split off paaudio changes to a different commit. audio/audio.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 4baa37caac..d131958194 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -101,6 +101,8 @@ const struct mixeng_volume nominal_volume =3D { #endif }; =20 +static bool legacy_config =3D true; + #ifdef AUDIO_IS_FLAWLESS_AND_NO_CHECKS_ARE_REQURIED #error No its not #else @@ -1392,7 +1394,7 @@ static AudiodevListEntry *audiodev_find( * if dev =3D=3D NULL =3D> legacy implicit initialization, return the alre= ady created * state or create a new one */ -static AudioState *audio_init(Audiodev *dev) +static AudioState *audio_init(Audiodev *dev, const char *name) { static bool atexit_registered; size_t i; @@ -1406,12 +1408,13 @@ static AudioState *audio_init(Audiodev *dev) =20 if (dev) { /* -audiodev option */ + legacy_config =3D false; drvname =3D AudiodevDriver_str(dev->driver); } else if (!QTAILQ_EMPTY(&audio_states)) { - /* - * todo: check for -audiodev once we have normal audiodev selection - * support - */ + if (!legacy_config) { + dolog("You must specify an audiodev=3D for the device %s\n", n= ame); + exit(1); + } return QTAILQ_FIRST(&audio_states); } else { /* legacy implicit initialization */ @@ -1518,7 +1521,7 @@ void audio_free_audiodev_list(AudiodevListHead *head) void AUD_register_card (const char *name, QEMUSoundCard *card) { if (!card->state) { - card->state =3D audio_init(NULL); + card->state =3D audio_init(NULL, name); } =20 card->name =3D g_strdup (name); @@ -1544,8 +1547,11 @@ CaptureVoiceOut *AUD_add_capture( struct capture_callback *cb; =20 if (!s) { - /* todo: remove when we have normal audiodev selection support */ - s =3D audio_init(NULL); + if (!legacy_config) { + dolog("You must specify audiodev when trying to capture\n"); + return NULL; + } + s =3D audio_init(NULL, NULL); } =20 if (audio_validate_settings (as)) { @@ -1776,7 +1782,7 @@ void audio_init_audiodevs(void) AudiodevListEntry *e; =20 QSIMPLEQ_FOREACH(e, &audiodevs, next) { - audio_init(e->dev); + audio_init(e->dev, NULL); } } =20 --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938410; cv=none; d=zoho.com; s=zohoarc; b=fKOrzGQemvJfRjyT4f83emNrseAMzZq4h9+xsENkNstI8Jwevw5Hr5PVF65+pALov1hTJJ3hZhTyJ1D8RioLaS19v6WCrKQYXhYjZYfZgOsLbM4QlLMsUZFC6LAstQ7oII5UxRdpu6KCBJ7hx1V5ovZfALGjmCt6HH7/2G1jUDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938410; 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=Q1PwGIykqd7r1oFqK+2gB8V8IirLhEb2J+bPSI79Dya2WckqjP8x6JEoFH1zc/1/xJr8SMXMhIIcVQRcH6GPR7c4v+ZS/u3YHsQp8Xa1JMLgr0YI4L3N/KeWJxy/BweAP/SJKbt8/P1yvZbBkjZ8K1mMEq2Cv9YfQehMo3KnaVU= 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 1564938410562898.177325522285; Sun, 4 Aug 2019 10:06:50 -0700 (PDT) Received: from localhost ([::1]:48868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJy5-00075r-Hl for importer@patchew.org; Sun, 04 Aug 2019 13:06:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56697) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw4-0002OB-T0 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw3-00048x-4C for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:44 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35577) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw2-00040Z-OX for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:43 -0400 Received: by mail-wm1-x343.google.com with SMTP id l2so70821580wmg.0 for ; Sun, 04 Aug 2019 10:04:35 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:34 -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=vJhPaJVw/LYCI9NfigX3ZG5cAFJRO7H6M0yGyBEULkZfq6F/x4sa7zSEW2S1XxOHds xvqUY+/KZ0nxHF0F7wE6CNe5Deus7FlIdAd+dPGFYZwNlZ6HY9MZwxU3Eh4Xydmy13qS rUZ2Q+Aa6gecBfCeJs8l9lTj0U0/7ExiQlFnUo2l4dIrHUDjGXEuBxi04C/z6s9/JR6j /KbgwxfUXgWit/O2c8c+1wmK8K7pMurJ+d4GrMPbu80jIOsWhIGptphyCpb+EiFGOw7s pjUQn0Da7dGyMzs9+t+uwjLLsOkpOtMGgli0GI6ETP22dqSm6VjQuN6Lsyi6a4D5AFUG KVUg== 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=fUU8RBmMNsb7rBZ4ol9mCHwULjInnoUZgBNo33BHFCVzhlSny7hGhek/5BjP9m8b/k 5kf9dI+vHxqkpJs4ZJQG95/qKaqktYZAfzQti9gceJ9Z1tfpvl/i66fuNwxDq3HtakBT JDEVL4DEdAuxzfjWssDTBCTinvHXOqR87+qE7jEXIbp39Hi22Ln9+wvm8X9gj7Kx6fNt Is+0kQALRYvBePe486jMCV8lKjVgYkSzRGrGvPCtEiTKMU4KmKVZGzNEjFpB8AKQya49 XRs+qzJWQUK3gx23hu9ThfdCOzC5QuDbbXak85yN4PpHebNy6sPEXlgPgOaY9+sVuoUI dn/A== X-Gm-Message-State: APjAAAV4leRiSVZ+6c7KOR+f6JIG7Tp1zcsr6L8tlNmYJGypfYISISMf G03OGMMcv1gUasdeD58tHaTT5Lof4YA= X-Google-Smtp-Source: APXvYqxnK43iyZGF7PJmAXJnV0bQTR9Z4+jZWclnoOZsCVy6/02Fsk7ruavBHxv+730JjNZDF17LoQ== X-Received: by 2002:a05:600c:2056:: with SMTP id p22mr14163129wmg.155.1564938274823; Sun, 04 Aug 2019 10:04:34 -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: Sun, 4 Aug 2019 19:04:19 +0200 Message-Id: <274fc4ecc9125605a210b737c7fd927c51ff08ce.1564925486.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::343 Subject: [Qemu-devel] [PATCH v3 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 Tue Apr 30 01:16:34 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=1564938470; cv=none; d=zoho.com; s=zohoarc; b=oVuEWACQnPormNehOrVLfMHyAwVO0jssozCl2mb1varorohkj6EhmqnN77C1xLIAEgF2SJsjGVbuflnqiAHwOeK+wslY09JCy8g6jzyj43zIjkvV4Wm7ESVzdsFkHtT+VeLhQcTWSS5VSJQU1A31WqWauJX2ti0TSPNoKX/ZbDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938470; 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=UTK3qUZMWVtURWYIrTovjDeI97Ar832wBRSZcD2Vy2zCBpesUQ2J6QZB2LX5G1SPZgfa+DoArrhWhxyx4YzI2ffhxbEq0iCaPHGOq08MQ5uF6x2zv8p+rv7KLOSB4gV4+5nsiYT1vydVtSUzgvnFc0oZPA2p1PNy5dngUUlw7sg= 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 1564938470089519.5907161911742; Sun, 4 Aug 2019 10:07:50 -0700 (PDT) Received: from localhost ([::1]:48886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJz3-0001BB-52 for importer@patchew.org; Sun, 04 Aug 2019 13:07:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56686) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw4-0002O8-PL for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw2-00048N-KD for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:44 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:37667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw1-00040h-GX for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:42 -0400 Received: by mail-wm1-x341.google.com with SMTP id f17so70837785wme.2 for ; Sun, 04 Aug 2019 10:04:36 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:35 -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=EMbEHk6h6pQNZwGzxGYAtxbS5OwGqmB7zIC6lQTqkNqIGbXv1jlnYU1cNpkuNDN/18 m29tip//zh0qgVM0V/cajWI1knBCAnZ0a8zmd+3VOf49ihcGvr5f83DyJkgVFrs170Gq m1b1Ulj+E2/CT/0xqd0Bim+F/oazvCPG4PjljnvQupIELKxaRhFI2LMzrV1QhDyy09Pj p6KYeVcSe19tLfTGnFCpWLZ6sh8tLpCmSfoXBT0D/VKua46HoFoMNMitFx/gXsxrx9Oy bmqKWkBudatCp7Dur3KvvYqafJNIjv4+7boKg9Du+QO9Tgr5B6VEWBeHkQzUFt+yL74d 5OfQ== 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=eUgu95HlzxML0kWYRdhgfFihT0gpFAFdDeH2sjp0VtYlCur5Bl7FZF1fWmWgxYvvWi cB6VS8QFukprPhzRxPzW5S0OfFYvOghJi2iJJDNLaC1QQ/8kq5JrMWYo9xuaVX0K+zK2 c+/wg+jOHMFcJQw9BcVkVFNcYiBcToVlzd3eVqfSAsrxqrmsVxXrDmkbUdbi3F2Zvpxu cJklZrr5M8eTqWeYkBOagJ2MINlfm2RTBUbzqmbD10mXinliyeDSaNJMRCMy299ZS6E3 JjwFa+u/xRcf0fQ05Fx8B+cD7m4I7SMV1yeiPKB04L56eQC+A0UacMQUUbKFW6PXMnBc QFeA== X-Gm-Message-State: APjAAAVIHliXNSY3AevnOye2/26NN7SY9ai7iUwArJ7v96ga5Tm//6La dRQlHmawOb3LT4BtDrxCoic/uug7IFc= X-Google-Smtp-Source: APXvYqyudTjPiWYkD0+gxZ7Smp2oZ/xvd8PoPP4b8/5c4Tsahce7Sbg+XBtlKhMktnyL3MBI5Ob2yA== X-Received: by 2002:a7b:c195:: with SMTP id y21mr14002063wmi.16.1564938275570; Sun, 04 Aug 2019 10:04:35 -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: Sun, 4 Aug 2019 19:04:20 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v3 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 Tue Apr 30 01:16:34 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=1564938534; cv=none; d=zoho.com; s=zohoarc; b=W/Dc4zVVkxC1qD11n40obaUB3B2yzY/LdWz6PEFSM/h1QRzWNj5fJdFWeGGZBYgUoryqPHn29SOsGLfcVtEzlwcV94tfBASVN+thtoCzU99KEmLUnGtmRZKR5Y2ZVCCpOpsSMQyBbUZsFX3qKAt5sUk6lk3aZhlrjRjnJRUBC9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938534; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ru3Fc2G+kcIWGOZ/7Fgkew5rnlD64ppzaeIJGRveV5c=; b=KiVhSw0TCvYmVwdah3+DiBacQ9ZlsBlZmI7T+YFXw8ruzEtdLSRjKHnHKz6q33RPRfjoXprWrBhz4VBxfRdYbrJzgvNlGseIyb5Utc4j5fkgjzLEARYm5pwga7DPMRtkQJEpWynFRiVYuAFVO4zv3I55QMg5ucb8gYeUUHqIgJc= 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 1564938534064973.8276563538808; Sun, 4 Aug 2019 10:08:54 -0700 (PDT) Received: from localhost ([::1]:48904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huK05-0003oL-2x for importer@patchew.org; Sun, 04 Aug 2019 13:08:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56784) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw9-0002QI-P5 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw2-00047y-In for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:47 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:52877) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw1-00042B-8B for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:41 -0400 Received: by mail-wm1-x336.google.com with SMTP id s3so72561288wms.2 for ; Sun, 04 Aug 2019 10:04:38 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ru3Fc2G+kcIWGOZ/7Fgkew5rnlD64ppzaeIJGRveV5c=; b=YPeotXVpMN8GKdnqnHX51nUMQRoVayxeX68X1DI9WORIhSk4Rz5jp7X5OVRI/HL29L YfJdD6WJHVt+tljuvoYdhvY//p2dpo4GLzimFMZ12mjnAk3RAY/ewd+ULm70BkrlLs8O FXpSkAwRo71KTEZ7fbyXgsJvlyJ9vNi6Sre87xh9g1wX++TsBnVIcm8S7dBUu8+W53GO pJedZzbHhX9wCVi8qlrzSQ0nBsUUun2eQA/BQHgkezmnjC1ObuiNqaVs+pE3JYz4oiuF fMRSIAH98X3jNqt8h/U6+E5nknU48ortpKR86iw5+FJ5dd8/L1VAP1IFnzyBr8HmcVoK ouqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ru3Fc2G+kcIWGOZ/7Fgkew5rnlD64ppzaeIJGRveV5c=; b=gbcsnOM5EWbB2fCx3RX9jum1LmF14fa8S0nHo0LA4RwGydl4gP+BcTV4TsTWhDVeIf PTo7kYQkW6UEib4d6UtZP1MPmJPkzRGwsKaeRJVTwB2A1LKv7gg9nLm2J5+Pxr3pop39 pEuMyMnpCrZAcl1BnyRmkRA1zb9brLv0XII40uzpiNojXQ9ZwGy2nGfFvgVigLDZsx0b TD0Jowyfjvbtg1BCVWKDyWbXzlK+t1uxX8bTkemimvqGCmMae2REaUbcRgQAHhXHcGYk 8UMwYYE8BEG8gM5n2gMlYVEOM9OkBtAWqURQ4YlW61uuLMtEe4LUzHfny6Gx9w1d2Twf oIrg== X-Gm-Message-State: APjAAAW3RKbf+3GzgA4XsH5N7n7EeKjNfSMOE8H1jgrGnGzZjQ0gcXR5 047Id83dynNvhgTNNyMhjFvvGBR1+VI= X-Google-Smtp-Source: APXvYqw8lm0N4GICHF2hPsN+dINavHCwjBKZAkTVWwGeu1vbkU5rA5ctp6YYQV7BmemA/N32d8hGIA== X-Received: by 2002:a05:600c:2388:: with SMTP id m8mr13796898wma.23.1564938276556; Sun, 04 Aug 2019 10:04:36 -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: Sun, 4 Aug 2019 19:04:21 +0200 Message-Id: <7b8f396f8d2048f5ac26da52b77e5d48249c7645.1564925486.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::336 Subject: [Qemu-devel] [PATCH v3 09/14] audio: remove audio_MIN, audio_MAX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Walle , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) There's already a MIN and MAX macro in include/qemu/osdep.h, use them instead. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.h | 17 ----------------- audio/alsaaudio.c | 6 +++--- audio/audio.c | 20 ++++++++++---------- audio/coreaudio.c | 2 +- audio/dsoundaudio.c | 2 +- audio/noaudio.c | 10 +++++----- audio/ossaudio.c | 6 +++--- audio/paaudio.c | 12 ++++++------ audio/sdlaudio.c | 6 +++--- audio/spiceaudio.c | 10 +++++----- audio/wavaudio.c | 4 ++-- hw/audio/ac97.c | 10 +++++----- hw/audio/adlib.c | 4 ++-- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 16 ++++++++-------- hw/audio/milkymist-ac97.c | 8 ++++---- hw/audio/pcspk.c | 2 +- hw/audio/sb16.c | 2 +- hw/audio/wm8750.c | 4 ++-- 21 files changed, 70 insertions(+), 87 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index c0722a5cda..4a95758516 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -146,23 +146,6 @@ static inline void *advance (void *p, int incr) return (d + incr); } =20 -#ifdef __GNUC__ -#define audio_MIN(a, b) ( __extension__ ({ \ - __typeof (a) ta =3D a; \ - __typeof (b) tb =3D b; \ - ((ta)>(tb)?(tb):(ta)); \ -})) - -#define audio_MAX(a, b) ( __extension__ ({ \ - __typeof (a) ta =3D a; \ - __typeof (b) tb =3D b; \ - ((ta)<(tb)?(tb):(ta)); \ -})) -#else -#define audio_MIN(a, b) ((a)>(b)?(b):(a)) -#define audio_MAX(a, b) ((a)<(b)?(b):(a)) -#endif - int wav_start_capture(AudioState *state, CaptureState *s, const char *path, int freq, int bits, int nchannels); =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 3745c823ad..6b9e0f06af 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -634,7 +634,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) =20 while (alsa->pending) { int left_till_end_samples =3D hw->samples - alsa->wpos; - int len =3D audio_MIN (alsa->pending, left_till_end_samples); + int len =3D MIN (alsa->pending, left_till_end_samples); char *src =3D advance (alsa->pcm_buf, alsa->wpos << hw->info.shift= ); =20 while (len) { @@ -697,7 +697,7 @@ static int alsa_run_out (HWVoiceOut *hw, int live) return 0; } =20 - decr =3D audio_MIN (live, avail); + decr =3D MIN (live, avail); decr =3D audio_pcm_hw_clip_out (hw, alsa->pcm_buf, decr, alsa->pending= ); alsa->pending +=3D decr; alsa_write_pending (alsa); @@ -915,7 +915,7 @@ static int alsa_run_in (HWVoiceIn *hw) } } =20 - decr =3D audio_MIN (dead, avail); + decr =3D MIN (dead, avail); if (!decr) { return 0; } diff --git a/audio/audio.c b/audio/audio.c index d131958194..cb0222ab4a 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -533,7 +533,7 @@ static int audio_pcm_hw_find_min_in (HWVoiceIn *hw) =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active) { - m =3D audio_MIN (m, sw->total_hw_samples_acquired); + m =3D MIN (m, sw->total_hw_samples_acquired); } } return m; @@ -553,14 +553,14 @@ int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_= buf, int live, int pending) { int left =3D hw->samples - pending; - int len =3D audio_MIN (left, live); + int len =3D MIN (left, live); int clipped =3D 0; =20 while (len) { struct st_sample *src =3D hw->mix_buf + hw->rpos; uint8_t *dst =3D advance (pcm_buf, hw->rpos << hw->info.shift); int samples_till_end_of_buf =3D hw->samples - hw->rpos; - int samples_to_clip =3D audio_MIN (len, samples_till_end_of_buf); + int samples_to_clip =3D MIN (len, samples_till_end_of_buf); =20 hw->clip (dst, src, samples_to_clip); =20 @@ -614,7 +614,7 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int si= ze) } =20 swlim =3D (live * sw->ratio) >> 32; - swlim =3D audio_MIN (swlim, samples); + swlim =3D MIN (swlim, samples); =20 while (swlim) { src =3D hw->conv_buf + rpos; @@ -662,7 +662,7 @@ static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, i= nt *nb_livep) =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active || !sw->empty) { - m =3D audio_MIN (m, sw->total_hw_samples_mixed); + m =3D MIN (m, sw->total_hw_samples_mixed); nb_live +=3D 1; } } @@ -725,7 +725,7 @@ int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int = size) =20 dead =3D hwsamples - live; swlim =3D ((int64_t) dead << 32) / sw->ratio; - swlim =3D audio_MIN (swlim, samples); + swlim =3D MIN (swlim, samples); if (swlim) { sw->conv (sw->buf, buf, swlim); =20 @@ -737,7 +737,7 @@ int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int = size) while (swlim) { dead =3D hwsamples - live; left =3D hwsamples - wpos; - blck =3D audio_MIN (dead, left); + blck =3D MIN (dead, left); if (!blck) { break; } @@ -1029,7 +1029,7 @@ static void audio_capture_mix_and_clear (HWVoiceOut *= hw, int rpos, int samples) n =3D samples; while (n) { int till_end_of_hw =3D hw->samples - rpos2; - int to_write =3D audio_MIN (till_end_of_hw, n); + int to_write =3D MIN (till_end_of_hw, n); int bytes =3D to_write << hw->info.shift; int written; =20 @@ -1047,7 +1047,7 @@ static void audio_capture_mix_and_clear (HWVoiceOut *= hw, int rpos, int samples) } } =20 - n =3D audio_MIN (samples, hw->samples - rpos); + n =3D MIN (samples, hw->samples - rpos); mixeng_clear (hw->mix_buf + rpos, n); mixeng_clear (hw->mix_buf, samples - n); } @@ -1203,7 +1203,7 @@ static void audio_run_capture (AudioState *s) rpos =3D hw->rpos; while (live) { int left =3D hw->samples - rpos; - int to_capture =3D audio_MIN (live, left); + int to_capture =3D MIN (live, left); struct st_sample *src; struct capture_callback *cb; =20 diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 4bec6c8c5c..f0ab4014a8 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -413,7 +413,7 @@ static int coreaudio_run_out (HWVoiceOut *hw, int live) core->live); } =20 - decr =3D audio_MIN (core->decr, live); + decr =3D MIN (core->decr, live); core->decr -=3D decr; =20 core->live =3D live - decr; diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 5da4c864c3..07260f881e 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -707,7 +707,7 @@ static int dsound_run_in (HWVoiceIn *hw) if (!len) { return 0; } - len =3D audio_MIN (len, dead); + len =3D MIN (len, dead); =20 err =3D dsound_lock_in ( dscb, diff --git a/audio/noaudio.c b/audio/noaudio.c index 9b195dc52c..14a0e4ab29 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -52,11 +52,11 @@ static int no_run_out (HWVoiceOut *hw, int live) now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ticks =3D now - no->old_ticks; bytes =3D muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_S= ECOND); - bytes =3D audio_MIN(bytes, INT_MAX); + bytes =3D MIN(bytes, INT_MAX); samples =3D bytes >> hw->info.shift; =20 no->old_ticks =3D now; - decr =3D audio_MIN (live, samples); + decr =3D MIN (live, samples); hw->rpos =3D (hw->rpos + decr) % hw->samples; return decr; } @@ -111,9 +111,9 @@ static int no_run_in (HWVoiceIn *hw) muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SEC= OND); =20 no->old_ticks =3D now; - bytes =3D audio_MIN (bytes, INT_MAX); + bytes =3D MIN (bytes, INT_MAX); samples =3D bytes >> hw->info.shift; - samples =3D audio_MIN (samples, dead); + samples =3D MIN (samples, dead); } return samples; } @@ -124,7 +124,7 @@ static int no_read (SWVoiceIn *sw, void *buf, int size) * useless resampling/mixing */ int samples =3D size >> sw->info.shift; int total =3D sw->hw->total_samples_captured - sw->total_hw_samples_ac= quired; - int to_clear =3D audio_MIN (samples, total); + int to_clear =3D MIN (samples, total); sw->total_hw_samples_acquired +=3D total; audio_pcm_info_clear_buf (&sw->info, buf, to_clear); return to_clear << sw->info.shift; diff --git a/audio/ossaudio.c b/audio/ossaudio.c index c0af065b6f..29139ef1f5 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -388,7 +388,7 @@ static void oss_write_pending (OSSVoiceOut *oss) int samples_written; ssize_t bytes_written; int samples_till_end =3D hw->samples - oss->wpos; - int samples_to_write =3D audio_MIN (oss->pending, samples_till_end= ); + int samples_to_write =3D MIN (oss->pending, samples_till_end); int bytes_to_write =3D samples_to_write << hw->info.shift; void *pcm =3D advance (oss->pcm_buf, oss->wpos << hw->info.shift); =20 @@ -437,7 +437,7 @@ static int oss_run_out (HWVoiceOut *hw, int live) =20 pos =3D hw->rpos << hw->info.shift; bytes =3D audio_ring_dist (cntinfo.ptr, pos, bufsize); - decr =3D audio_MIN (bytes >> hw->info.shift, live); + decr =3D MIN (bytes >> hw->info.shift, live); } else { err =3D ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &abinfo); @@ -456,7 +456,7 @@ static int oss_run_out (HWVoiceOut *hw, int live) return 0; } =20 - decr =3D audio_MIN (abinfo.bytes >> hw->info.shift, live); + decr =3D MIN (abinfo.bytes >> hw->info.shift, live); if (!decr) { return 0; } diff --git a/audio/paaudio.c b/audio/paaudio.c index 1d68173636..f3864e1d50 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -235,7 +235,7 @@ static void *qpa_thread_out (void *arg) } } =20 - decr =3D to_mix =3D audio_MIN(pa->live, pa->samples >> 5); + decr =3D to_mix =3D MIN(pa->live, pa->samples >> 5); rpos =3D pa->rpos; =20 if (audio_pt_unlock(&pa->pt, __func__)) { @@ -244,7 +244,7 @@ static void *qpa_thread_out (void *arg) =20 while (to_mix) { int error; - int chunk =3D audio_MIN (to_mix, hw->samples - rpos); + int chunk =3D MIN (to_mix, hw->samples - rpos); struct st_sample *src =3D hw->mix_buf + rpos; =20 hw->clip (pa->pcm_buf, src, chunk); @@ -282,7 +282,7 @@ static int qpa_run_out (HWVoiceOut *hw, int live) return 0; } =20 - decr =3D audio_MIN (live, pa->decr); + decr =3D MIN (live, pa->decr); pa->decr -=3D decr; pa->live =3D live - decr; hw->rpos =3D pa->rpos; @@ -327,7 +327,7 @@ static void *qpa_thread_in (void *arg) } } =20 - incr =3D to_grab =3D audio_MIN(pa->dead, pa->samples >> 5); + incr =3D to_grab =3D MIN(pa->dead, pa->samples >> 5); wpos =3D pa->wpos; =20 if (audio_pt_unlock(&pa->pt, __func__)) { @@ -336,7 +336,7 @@ static void *qpa_thread_in (void *arg) =20 while (to_grab) { int error; - int chunk =3D audio_MIN (to_grab, hw->samples - wpos); + int chunk =3D MIN (to_grab, hw->samples - wpos); void *buf =3D advance (pa->pcm_buf, wpos); =20 if (qpa_simple_read (pa, buf, @@ -375,7 +375,7 @@ static int qpa_run_in (HWVoiceIn *hw) =20 live =3D audio_pcm_hw_get_live_in (hw); dead =3D hw->samples - live; - incr =3D audio_MIN (dead, pa->incr); + incr =3D MIN (dead, pa->incr); pa->incr -=3D incr; pa->dead =3D dead - incr; hw->wpos =3D pa->wpos; diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index e7179ff1d4..42f7614124 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -193,10 +193,10 @@ static void sdl_callback (void *opaque, Uint8 *buf, i= nt len) =20 /* dolog ("in callback samples=3D%d live=3D%d\n", samples, sdl->live);= */ =20 - to_mix =3D audio_MIN(samples, sdl->live); + to_mix =3D MIN(samples, sdl->live); decr =3D to_mix; while (to_mix) { - int chunk =3D audio_MIN(to_mix, hw->samples - hw->rpos); + int chunk =3D MIN(to_mix, hw->samples - hw->rpos); struct st_sample *src =3D hw->mix_buf + hw->rpos; =20 /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */ @@ -236,7 +236,7 @@ static int sdl_run_out (HWVoiceOut *hw, int live) sdl->live); } =20 - decr =3D audio_MIN (sdl->decr, live); + decr =3D MIN (sdl->decr, live); sdl->decr -=3D decr; =20 sdl->live =3D live; diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 0ead5ae43a..6f4a0558f8 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -164,20 +164,20 @@ static int line_out_run (HWVoiceOut *hw, int live) } =20 decr =3D rate_get_samples (&hw->info, &out->rate); - decr =3D audio_MIN (live, decr); + decr =3D MIN (live, decr); =20 samples =3D decr; rpos =3D hw->rpos; while (samples) { int left_till_end_samples =3D hw->samples - rpos; - int len =3D audio_MIN (samples, left_till_end_samples); + int len =3D MIN (samples, left_till_end_samples); =20 if (!out->frame) { spice_server_playback_get_buffer (&out->sin, &out->frame, &out= ->fsize); out->fpos =3D out->frame; } if (out->frame) { - len =3D audio_MIN (len, out->fsize); + len =3D MIN (len, out->fsize); hw->clip (out->fpos, hw->mix_buf + rpos, len); out->fsize -=3D len; out->fpos +=3D len; @@ -295,7 +295,7 @@ static int line_in_run (HWVoiceIn *hw) } =20 delta_samp =3D rate_get_samples (&hw->info, &in->rate); - num_samples =3D audio_MIN (num_samples, delta_samp); + num_samples =3D MIN (num_samples, delta_samp); =20 ready =3D spice_server_record_get_samples (&in->sin, in->samples, num_= samples); samples =3D in->samples; @@ -305,7 +305,7 @@ static int line_in_run (HWVoiceIn *hw) ready =3D LINE_IN_SAMPLES; } =20 - num_samples =3D audio_MIN (ready, num_samples); + num_samples =3D MIN (ready, num_samples); =20 if (hw->wpos + num_samples > hw->samples) { len[0] =3D hw->samples - hw->wpos; diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 803b6cb1f3..bbf3f3b346 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -59,12 +59,12 @@ static int wav_run_out (HWVoiceOut *hw, int live) } =20 wav->old_ticks =3D now; - decr =3D audio_MIN (live, samples); + decr =3D MIN (live, samples); samples =3D decr; rpos =3D hw->rpos; while (samples) { int left_till_end_samples =3D hw->samples - rpos; - int convert_samples =3D audio_MIN (samples, left_till_end_samples); + int convert_samples =3D MIN (samples, left_till_end_samples); =20 src =3D hw->mix_buf + rpos; dst =3D advance (wav->pcm_buf, rpos << hw->info.shift); diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 0d8e524233..060bafdac3 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -964,7 +964,7 @@ static int write_audio (AC97LinkState *s, AC97BusMaster= Regs *r, uint32_t temp =3D r->picb << 1; uint32_t written =3D 0; int to_copy =3D 0; - temp =3D audio_MIN (temp, max); + temp =3D MIN (temp, max); =20 if (!temp) { *stop =3D 1; @@ -973,7 +973,7 @@ static int write_audio (AC97LinkState *s, AC97BusMaster= Regs *r, =20 while (temp) { int copied; - to_copy =3D audio_MIN (temp, sizeof (tmpbuf)); + to_copy =3D MIN (temp, sizeof (tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); copied =3D AUD_write (s->voice_po, tmpbuf, to_copy); dolog ("write_audio max=3D%x to_copy=3D%x copied=3D%x\n", @@ -1019,7 +1019,7 @@ static void write_bup (AC97LinkState *s, int elapsed) } =20 while (elapsed) { - int temp =3D audio_MIN (elapsed, sizeof (s->silence)); + int temp =3D MIN (elapsed, sizeof (s->silence)); while (temp) { int copied =3D AUD_write (s->voice_po, s->silence, temp); if (!copied) @@ -1040,7 +1040,7 @@ static int read_audio (AC97LinkState *s, AC97BusMaste= rRegs *r, int to_copy =3D 0; SWVoiceIn *voice =3D (r - s->bm_regs) =3D=3D MC_INDEX ? s->voice_mc : = s->voice_pi; =20 - temp =3D audio_MIN (temp, max); + temp =3D MIN (temp, max); =20 if (!temp) { *stop =3D 1; @@ -1049,7 +1049,7 @@ static int read_audio (AC97LinkState *s, AC97BusMaste= rRegs *r, =20 while (temp) { int acquired; - to_copy =3D audio_MIN (temp, sizeof (tmpbuf)); + to_copy =3D MIN (temp, sizeof (tmpbuf)); acquired =3D AUD_read (voice, tmpbuf, to_copy); if (!acquired) { *stop =3D 1; diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index df2e781788..1b32c4ff7f 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -195,7 +195,7 @@ static void adlib_callback (void *opaque, int free) return; } =20 - to_play =3D audio_MIN (s->left, samples); + to_play =3D MIN (s->left, samples); while (to_play) { written =3D write_audio (s, to_play); =20 @@ -210,7 +210,7 @@ static void adlib_callback (void *opaque, int free) } } =20 - samples =3D audio_MIN (samples, s->samples - s->pos); + samples =3D MIN (samples, s->samples - s->pos); if (!samples) { return; } diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index e3ea830b47..ca3af8a987 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -535,7 +535,7 @@ static int cs_write_audio (CSState *s, int nchan, int d= ma_pos, int copied; size_t to_copy; =20 - to_copy =3D audio_MIN (temp, left); + to_copy =3D MIN (temp, left); if (to_copy > sizeof (tmpbuf)) { to_copy =3D sizeof (tmpbuf); } @@ -578,7 +578,7 @@ static int cs_dma_read (void *opaque, int nchan, int dm= a_pos, int dma_len) till =3D (s->dregs[Playback_Lower_Base_Count] | (s->dregs[Playback_Upper_Base_Count] << 8)) << s->shift; till -=3D s->transferred; - copy =3D audio_MIN (till, copy); + copy =3D MIN (till, copy); } =20 if ((copy <=3D 0) || (dma_len <=3D 0)) { diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 7589671d20..50b144ded0 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -645,7 +645,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, int size =3D d->frame_cnt & 0xffff; int left =3D ((size - cnt + 1) << 2) + d->leftover; int transferred =3D 0; - int temp =3D audio_MIN (max, audio_MIN (left, csc_bytes)); + int temp =3D MIN (max, MIN (left, csc_bytes)); int index =3D d - &s->chan[0]; =20 addr +=3D (cnt << 2) + d->leftover; @@ -654,7 +654,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, while (temp) { int acquired, to_copy; =20 - to_copy =3D audio_MIN ((size_t) temp, sizeof (tmpbuf)); + to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); acquired =3D AUD_read (s->adc_voice, tmpbuf, to_copy); if (!acquired) break; @@ -672,7 +672,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, while (temp) { int copied, to_copy; =20 - to_copy =3D audio_MIN ((size_t) temp, sizeof (tmpbuf)); + to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); copied =3D AUD_write (voice, tmpbuf, to_copy); if (!copied) diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 566864bc9e..325efd8df7 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -117,7 +117,7 @@ static void GUS_callback (void *opaque, int free) GUSState *s =3D opaque; =20 samples =3D free >> s->shift; - to_play =3D audio_MIN (samples, s->left); + to_play =3D MIN (samples, s->left); =20 while (to_play) { int written =3D write_audio (s, to_play); @@ -132,7 +132,7 @@ static void GUS_callback (void *opaque, int free) net +=3D written; } =20 - samples =3D audio_MIN (samples, s->samples); + samples =3D MIN (samples, s->samples); if (samples) { gus_mixvoices (&s->emu, s->freq, samples, s->mixbuf); =20 @@ -192,7 +192,7 @@ static int GUS_read_DMA (void *opaque, int nchan, int d= ma_pos, int dma_len) ldebug ("read DMA %#x %d\n", dma_pos, dma_len); mode =3D k->has_autoinitialization(s->isa_dma, s->emu.gusdma); while (left) { - int to_copy =3D audio_MIN ((size_t) left, sizeof (tmpbuf)); + int to_copy =3D MIN ((size_t) left, sizeof (tmpbuf)); int copied; =20 ldebug ("left=3D%d to_copy=3D%d pos=3D%d\n", left, to_copy, pos); diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 967a10f189..c8f513d3ff 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -234,10 +234,10 @@ static void hda_audio_input_timer(void *opaque) goto out_timer; } =20 - int64_t to_transfer =3D audio_MIN(wpos - rpos, wanted_rpos - rpos); + int64_t to_transfer =3D MIN(wpos - rpos, wanted_rpos - rpos); while (to_transfer) { uint32_t start =3D (rpos & B_MASK); - uint32_t chunk =3D audio_MIN(B_SIZE - start, to_transfer); + uint32_t chunk =3D MIN(B_SIZE - start, to_transfer); int rc =3D hda_codec_xfer( &st->state->hda, st->stream, false, st->buf + start, chunk= ); if (!rc) { @@ -262,13 +262,13 @@ static void hda_audio_input_cb(void *opaque, int avai= l) int64_t wpos =3D st->wpos; int64_t rpos =3D st->rpos; =20 - int64_t to_transfer =3D audio_MIN(B_SIZE - (wpos - rpos), avail); + int64_t to_transfer =3D MIN(B_SIZE - (wpos - rpos), avail); =20 hda_timer_sync_adjust(st, -((wpos - rpos) + to_transfer - (B_SIZE >> 1= ))); =20 while (to_transfer) { uint32_t start =3D (uint32_t) (wpos & B_MASK); - uint32_t chunk =3D (uint32_t) audio_MIN(B_SIZE - start, to_transfe= r); + uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); uint32_t read =3D AUD_read(st->voice.in, st->buf + start, chunk); wpos +=3D read; to_transfer -=3D read; @@ -298,10 +298,10 @@ static void hda_audio_output_timer(void *opaque) goto out_timer; } =20 - int64_t to_transfer =3D audio_MIN(B_SIZE - (wpos - rpos), wanted_wpos = - wpos); + int64_t to_transfer =3D MIN(B_SIZE - (wpos - rpos), wanted_wpos - wpos= ); while (to_transfer) { uint32_t start =3D (wpos & B_MASK); - uint32_t chunk =3D audio_MIN(B_SIZE - start, to_transfer); + uint32_t chunk =3D MIN(B_SIZE - start, to_transfer); int rc =3D hda_codec_xfer( &st->state->hda, st->stream, true, st->buf + start, chunk); if (!rc) { @@ -326,7 +326,7 @@ static void hda_audio_output_cb(void *opaque, int avail) int64_t wpos =3D st->wpos; int64_t rpos =3D st->rpos; =20 - int64_t to_transfer =3D audio_MIN(wpos - rpos, avail); + int64_t to_transfer =3D MIN(wpos - rpos, avail); =20 if (wpos - rpos =3D=3D B_SIZE) { /* drop buffer, reset timer adjust */ @@ -341,7 +341,7 @@ static void hda_audio_output_cb(void *opaque, int avail) =20 while (to_transfer) { uint32_t start =3D (uint32_t) (rpos & B_MASK); - uint32_t chunk =3D (uint32_t) audio_MIN(B_SIZE - start, to_transfe= r); + uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); uint32_t written =3D AUD_write(st->voice.out, st->buf + start, chu= nk); rpos +=3D written; to_transfer -=3D written; diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index 4835229326..929b856587 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -184,7 +184,7 @@ static void ac97_in_cb(void *opaque, int avail_b) MilkymistAC97State *s =3D opaque; uint8_t buf[4096]; uint32_t remaining =3D s->regs[R_U_REMAINING]; - int temp =3D audio_MIN(remaining, avail_b); + int temp =3D MIN(remaining, avail_b); uint32_t addr =3D s->regs[R_U_ADDR]; int transferred =3D 0; =20 @@ -198,7 +198,7 @@ static void ac97_in_cb(void *opaque, int avail_b) while (temp) { int acquired, to_copy; =20 - to_copy =3D audio_MIN(temp, sizeof(buf)); + to_copy =3D MIN(temp, sizeof(buf)); acquired =3D AUD_read(s->voice_in, buf, to_copy); if (!acquired) { break; @@ -227,7 +227,7 @@ static void ac97_out_cb(void *opaque, int free_b) MilkymistAC97State *s =3D opaque; uint8_t buf[4096]; uint32_t remaining =3D s->regs[R_D_REMAINING]; - int temp =3D audio_MIN(remaining, free_b); + int temp =3D MIN(remaining, free_b); uint32_t addr =3D s->regs[R_D_ADDR]; int transferred =3D 0; =20 @@ -241,7 +241,7 @@ static void ac97_out_cb(void *opaque, int free_b) while (temp) { int copied, to_copy; =20 - to_copy =3D audio_MIN(temp, sizeof(buf)); + to_copy =3D MIN(temp, sizeof(buf)); cpu_physical_memory_read(addr, buf, to_copy); copied =3D AUD_write(s->voice_out, buf, to_copy); if (!copied) { diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 01127304c2..6bb1455c1b 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -103,7 +103,7 @@ static void pcspk_callback(void *opaque, int free) } =20 while (free > 0) { - n =3D audio_MIN(s->samples - s->play_pos, (unsigned int)free); + n =3D MIN(s->samples - s->play_pos, (unsigned int)free); n =3D AUD_write(s->voice, &s->sample_buf[s->play_pos], n); if (!n) break; diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 6b604979cf..5182eba8eb 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1168,7 +1168,7 @@ static int write_audio (SB16State *s, int nchan, int = dma_pos, int copied; size_t to_copy; =20 - to_copy =3D audio_MIN (temp, left); + to_copy =3D MIN (temp, left); if (to_copy > sizeof (tmpbuf)) { to_copy =3D sizeof (tmpbuf); } diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index dfb4156ff4..ab04bfa2c3 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -69,7 +69,7 @@ static inline void wm8750_in_load(WM8750State *s) { if (s->idx_in + s->req_in <=3D sizeof(s->data_in)) return; - s->idx_in =3D audio_MAX(0, (int) sizeof(s->data_in) - s->req_in); + s->idx_in =3D MAX(0, (int) sizeof(s->data_in) - s->req_in); AUD_read(*s->in[0], s->data_in + s->idx_in, sizeof(s->data_in) - s->idx_in); } @@ -100,7 +100,7 @@ static void wm8750_audio_out_cb(void *opaque, int free_= b) wm8750_out_flush(s); } else s->req_out =3D free_b - s->idx_out; -=20 + s->data_req(s->opaque, s->req_out >> 2, s->req_in >> 2); } =20 --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938533; cv=none; d=zoho.com; s=zohoarc; b=TGYcYNA58jCc4dy5g7h7DZ2CnjKJBgsraSRnDH185Vju695dgHkrviktfu5EI7epJeeoJF9I9zDNQBKVk+FHlToMstr+EVS+/R1l2YIxh41PcC4Qyw+Lj1NqnBzIpo8zTX9APc8YsDqFiqAE2xOR3oVzvkaOpS1WUbKrW2ZBsHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938533; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6OHafAEHZIuHozFrMT2v5DQsOPGlwWydb4OAeYtBXa8=; b=LxR2Ic9reYgI7mqf09+c8ewUXxmfy5YEkMH9hQii4TY0GxpnUEKrmAsPOzFIjdYVSnrEsfAV5IobWUyw3JqSoyIrY1sUaH1WFpwU3cBisxyOsAolNlXcaav4EE+ZKcKitdBI8LIgYzRE1aKICj0NBQOrw+2wHdoUwjLhyOaqb0o= 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 1564938533509290.0910381637028; Sun, 4 Aug 2019 10:08:53 -0700 (PDT) Received: from localhost ([::1]:48906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huK04-0003p4-Ig for importer@patchew.org; Sun, 04 Aug 2019 13:08:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56756) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw8-0002Q5-Bk for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw3-00048m-1s for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:54691) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw2-00042R-HU for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:42 -0400 Received: by mail-wm1-x343.google.com with SMTP id p74so72554998wme.4 for ; Sun, 04 Aug 2019 10:04:38 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6OHafAEHZIuHozFrMT2v5DQsOPGlwWydb4OAeYtBXa8=; b=bgv9f/c3iqngAVC8QQDJNQSKZE6Q6MPZ/L8dfcK+AzWJpeyeaZrJSb7aI8V+S3sw9t OwlNER/Vu2JmaY6py+LDdX7DBskGcaQfgM0LQk00Lz7cRlsmEbOZABnhyqBfwixfUr2p 8IpejLoVAXrrQcl6MiSdxJobeGlqIH2gZACUir3DiMhBEbaopeZ+JmI7qkMquvnG67lS IVDkDMfhAyFPD9xVHjRoiWZsVrY47aKeoRHMi+OcdC66RU7oZyHgJ+X/reZ5j+fYlcm5 5pDU13V134Gj0zpqIsYIOQP0bAg0zanNAetQwkUxyDpoejTFmwKx6JxK6PJzUKdmu1HL adMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6OHafAEHZIuHozFrMT2v5DQsOPGlwWydb4OAeYtBXa8=; b=Jss8Iypz0jcAuy8jE4yua7VEfdlL9/5udj/EM0k3sd6b02+5MJajdSjiKaPXdQQA89 GogEl9Rb5bkSxj0UXMzT+Bd8ITR9McW23qsv5d9pvq3zicC41voYnfcdypnwQMMeo9Jv HH3EuVh9tONVvW/0igHxi2k7hZ84DtS+aeyGKAxJXQfVbKrN+Zjo8r/o22LJkQXRRLcR j+/B1xvCXagupz/qTv99/g4xIND8rV/+9z1bUpPwaoksJWslohGbdAhTT34/Z8OdzbXY 70P/MnZajlPHTrhl/9zUsBhQVG9ncMzk+gOTo7QcPtigsaQrWQUPDiQ2cYRV805i0cl5 5/eg== X-Gm-Message-State: APjAAAXehRsnVN54jCpSVDq6ZtcLnhbAD6KZdqATFsjC0017KoWo2ta6 Z8SuL2ribsY411qbohzjJNFD78KW7nA= X-Google-Smtp-Source: APXvYqyy3oYRjsXZT3ZwEmcfhEP1jKxkllYFGLf4d12HF8gJzaHSX+TNWvhSAK72eI9ePQUmGEoWwg== X-Received: by 2002:a1c:2d8b:: with SMTP id t133mr14311798wmt.57.1564938277289; Sun, 04 Aug 2019 10:04:37 -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: Sun, 4 Aug 2019 19:04:22 +0200 Message-Id: <6bde77dcba080901bedf42beca3c9d71822fc261.1564925486.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::343 Subject: [Qemu-devel] [PATCH v3 10/14] audio: do not run each backend in audio_run X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) audio_run is called manually by alsa and oss backends when polling. In this case only the requesting backend should be run, not all of them. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 2 +- audio/alsaaudio.c | 7 +++++-- audio/audio.c | 14 +++++--------- audio/ossaudio.c | 12 ++++++------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 9f01f6ad00..7e00c1332e 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -221,7 +221,7 @@ int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_bu= f, int audio_bug (const char *funcname, int cond); void *audio_calloc (const char *funcname, int nmemb, size_t size); =20 -void audio_run (const char *msg); +void audio_run(AudioState *s, const char *msg); =20 #define VOICE_ENABLE 1 #define VOICE_DISABLE 2 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 6b9e0f06af..3daa7c8f8f 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -39,6 +39,7 @@ struct pollhlp { struct pollfd *pfds; int count; int mask; + AudioState *s; }; =20 typedef struct ALSAVoiceOut { @@ -199,11 +200,11 @@ static void alsa_poll_handler (void *opaque) break; =20 case SND_PCM_STATE_PREPARED: - audio_run ("alsa run (prepared)"); + audio_run(hlp->s, "alsa run (prepared)"); break; =20 case SND_PCM_STATE_RUNNING: - audio_run ("alsa run (running)"); + audio_run(hlp->s, "alsa run (running)"); break; =20 default: @@ -749,6 +750,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as, return -1; } =20 + alsa->pollhlp.s =3D hw->s; alsa->handle =3D handle; alsa->dev =3D dev; return 0; @@ -850,6 +852,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) return -1; } =20 + alsa->pollhlp.s =3D hw->s; alsa->handle =3D handle; alsa->dev =3D dev; return 0; diff --git a/audio/audio.c b/audio/audio.c index cb0222ab4a..07b35ffa03 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -835,7 +835,7 @@ static void audio_timer (void *opaque) } s->timer_last =3D now; =20 - audio_run("timer"); + audio_run(s, "timer"); audio_reset_timer(s); } =20 @@ -1237,15 +1237,11 @@ static void audio_run_capture (AudioState *s) } } =20 -void audio_run (const char *msg) +void audio_run(AudioState *s, const char *msg) { - AudioState *s; - - QTAILQ_FOREACH(s, &audio_states, list) { - audio_run_out(s); - audio_run_in(s); - audio_run_capture(s); - } + audio_run_out(s); + audio_run_in(s); + audio_run_capture(s); =20 #ifdef DEBUG_POLL { diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 29139ef1f5..456fba7480 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -110,28 +110,28 @@ static void oss_anal_close (int *fdp) =20 static void oss_helper_poll_out (void *opaque) { - (void) opaque; - audio_run ("oss_poll_out"); + AudioState *s =3D opaque; + audio_run(s, "oss_poll_out"); } =20 static void oss_helper_poll_in (void *opaque) { - (void) opaque; - audio_run ("oss_poll_in"); + AudioState *s =3D opaque; + audio_run(s, "oss_poll_in"); } =20 static void oss_poll_out (HWVoiceOut *hw) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; =20 - qemu_set_fd_handler (oss->fd, NULL, oss_helper_poll_out, NULL); + qemu_set_fd_handler(oss->fd, NULL, oss_helper_poll_out, hw->s); } =20 static void oss_poll_in (HWVoiceIn *hw) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; =20 - qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL); + qemu_set_fd_handler(oss->fd, oss_helper_poll_in, NULL, hw->s); } =20 static int oss_write (SWVoiceOut *sw, void *buf, int len) --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938412; cv=none; d=zoho.com; s=zohoarc; b=Z/YKFiRsx7PcQZK0L5uFRbjbINfevXCwDk93CsxpzIYJxYNzK32w434c0ZhGsakgMbAtDBB7HEDRbuzlk4Ikdlo2JThWFuFddgETGYRv9xD63PXLM3Wa8fTvfyJkmUZ19bZdgkguxL8U2whO5U2yg+4BS1a/VV/zG/I7NI7d22A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938412; 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=ekJ/SBxG8GTjRh8Vu78bcqvOQnslaCMLS0npQReHn+JNNfuMAYFy1JjMHcSS1xGyfQqeTfD5Ecr2po9WPjM72SI/VsaHPffzXwBcMFh4eq79nHGG0NHMnhWUc6ceL8RzMukSZqAdC5JtA7JGZyhmjLETSCWAHLpAmaTTIso4KMM= 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 1564938412430642.2922176124118; Sun, 4 Aug 2019 10:06:52 -0700 (PDT) Received: from localhost ([::1]:48872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJy7-0007B5-GN for importer@patchew.org; Sun, 04 Aug 2019 13:06:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56684) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw4-0002O6-Ox for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw2-00048S-M8 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:44 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw1-00043e-GY for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:42 -0400 Received: by mail-wm1-x343.google.com with SMTP id x15so72600648wmj.3 for ; Sun, 04 Aug 2019 10:04:39 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:37 -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=RwaRG2qYtLUixMlm3Jqs8/v9h39o2jombLpO7EJyAOtGYkEYJTBFR9izb6KIILBGb/ NmjjPb4ckSxcYwBj43RngO+NY68rScNlpqsAoBI7UXv3CbzfWz1gRjqRzDwzuXLgJMkj QDaja65cGjpXdzVQLZ4zH2aZgZbKUlVe5Imd4dT7OLM3b8aUoZ4sUd31Nv9ldxktwA4z 26tmA47Ft72xe9oWDeeBgApFajofK27uEJ9g/JxUU37M/cOqE28+m0s63DyITJlDiFWf 1eJfv/00ZjkGQHH65Bnh/JvbG68Q/0u7kcaxLGGykd3V37ajb23iJpe85ymovEqkxKU8 DZfw== 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=YCtZx4DHP+MHSYTKql9/lq+ypa+aR0k+0tR7grRoDtOf0j5RRgudbF/bR1peaYmEAZ vRnJZYhtHaFLC9AYUCgIoms4Jt9nClKPd16tp4UQ+zEwLi1dgLJZHE0dhOYYeKeQoAIQ d19KAL+tBw+oybxwShDmh7Yw0smNvtirulcbTU/LdNPsiZrluktWWSu1oNPrS7uurPBx 19D97LWFxzbpRwpKtGwFS5vVPRlEh6E76a7YzoxXxHEQvSAih6nX7sdaYJv4ScQn4A9V qqW6jzTul1tw65dPjjgAa1fAi1+4eWF5Lw2P/LOZ/YhcXuwjCUc5GYourxh1NXCWbMM1 Hwuw== X-Gm-Message-State: APjAAAWaaMhxXfXTPQROLzdyd3BqIF6+o/ph3RxH5ut5V/f+tiGKRo0C tKw6q+4udvrbN9oO/bnK5DTHx/MJ06A= X-Google-Smtp-Source: APXvYqxbrm+Lihzs2eQqqNmnTyIKlxALZO4wN0FVs/00BTOh7PgjY26zDf3a2H5+8oiRSqaPCCbbYg== X-Received: by 2002:a05:600c:224d:: with SMTP id a13mr14084735wmm.62.1564938278038; Sun, 04 Aug 2019 10:04:38 -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: Sun, 4 Aug 2019 19:04:23 +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::343 Subject: [Qemu-devel] [PATCH v3 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 Tue Apr 30 01:16:34 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=1564938472; cv=none; d=zoho.com; s=zohoarc; b=m98EgeeNG/KCbxiWvtelutFVYBdyApHxJaWH1O8wcHs6QzmathUtNjSCd1CjP5pwUjl2uLst1Oz0d4lq2g+KoISA2Wu2QDQ9IPDzyOxy+zeiI6+EmYlYOu4PpAtHqUvd8AzQ+lHDUex0Xxexi1cTBQe49GhWzU2CCtClQvgZq7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938472; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VY86o4VDQLjRZx45nc8Bf0PJBI7xJZDkLJjCJv/44bI=; b=hzYnRvLDBPHb8zGn71HpFgIl+JFVOp1tTDUTzppoKKtl+3eNHvAbJnNwUcwsBe+HH+cD1R0YZDFU32lkdsG0mAdRfrpQvSJoBa7XRhkB3NzNd46fkLbwDbtPEagcwrHzGvLrJTZBVI6i5Fko8Xz5ADDYQ8ghsRzNQZ0AQskwklU= 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 1564938472676388.73140368220743; Sun, 4 Aug 2019 10:07:52 -0700 (PDT) Received: from localhost ([::1]:48890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJz5-0001JD-MW for importer@patchew.org; Sun, 04 Aug 2019 13:07:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56767) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw9-0002QD-AO for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw3-00049S-As for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:40516) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw3-00046L-09 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:43 -0400 Received: by mail-wm1-x342.google.com with SMTP id v19so70881965wmj.5 for ; Sun, 04 Aug 2019 10:04:40 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VY86o4VDQLjRZx45nc8Bf0PJBI7xJZDkLJjCJv/44bI=; b=VpXk/1ABUQToyr0q8Z/5iqx9cPijWbvR8pm9wqkKOQsycaXJJ8pGfd+eggzUhDa341 AUHzGHhw4BZCPsqIfXiNcwCBGphZ6xpV20alASdIW4N5zBcGKM+j8mfaFbpw0rr16Htj fXLBgi6j8yxeWv3XXVAT6SYHzKj2CR1svvkrra1pgDAIgOB/gSdG34mALRzZBG38Q4MT VqeBAAjHXji2mtcITOiPNdzM9RwUzICK6LuxN18F+eaEmSM6puXqr0DcPz61bcE9tZVw yHpcHHnN/T2nLPMXe/qqo3J6i4HmXk7ZTfTjyKJRp3YSgOjN496r4YnnhAmwH6QGoH+4 T/aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VY86o4VDQLjRZx45nc8Bf0PJBI7xJZDkLJjCJv/44bI=; b=H2g3ZsNIvMnBw1aUuBZ1aT2gaOmHEV4jcSgu4EjyHdNYjicXPH7cmfruWhuihbPicB 5uwobOUZ7QtpZ5JKqoeLOWF5vuY24Tc2F/urZ84JV7kWU1HRiYtzMMe0Pm2YHSmLpnQp hXhZ3w5AuDeA0uY+CUZ/NsctEuvUXzAvNWCcjqWcQ5pOW675Kcy1t7+YX/VfvJK0UJUy Q4W6ZCaS67nKj5G4EiD0h1B0Pm0k4Pf+68Bbva7l5KsYwqnz2NBB9YxN31F0RSbcPcY0 6t+Z0hPGMIPg0gRnn1IkWEBWtvitKv1LvwegSIexi7bV9ZL04OZAdK5uQmXIFq1f+YqR fzRA== X-Gm-Message-State: APjAAAWLEyfCqqV5YOuMGurgVF3rKEkWX5UxW+gGP8KO4WM5qmwAzMf3 f4kJfTtHsI21j0atr4Ni8jC9afgam38= X-Google-Smtp-Source: APXvYqzZss6guGnhV9ibyV8Eka7SQ6Az98jjZ2zO81ke6oyXr010DTc2NGRaQC3lyO1BKbBnbEw1Qw== X-Received: by 2002:a7b:c202:: with SMTP id x2mr13848321wmi.49.1564938278975; Sun, 04 Aug 2019 10:04:38 -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: Sun, 4 Aug 2019 19:04:24 +0200 Message-Id: <07e99c2877870cb486a07881a77d3ce0bc594daa.1564925486.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 v3 12/14] audio: remove read and write pcm_ops X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) They just called audio_pcm_sw_read/write anyway, so it makes no sense to have them too. (The noaudio's read is the only exception, but it should work with the generic code too.) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_int.h | 5 ----- audio/alsaaudio.c | 12 ------------ audio/audio.c | 8 ++++---- audio/coreaudio.c | 6 ------ audio/dsoundaudio.c | 12 ------------ audio/noaudio.c | 19 ------------------- audio/ossaudio.c | 12 ------------ audio/paaudio.c | 12 ------------ audio/sdlaudio.c | 6 ------ audio/spiceaudio.c | 12 ------------ audio/wavaudio.c | 6 ------ 11 files changed, 4 insertions(+), 106 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 7e00c1332e..003b7ab8cc 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -150,13 +150,11 @@ struct audio_pcm_ops { int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opa= que); void (*fini_out)(HWVoiceOut *hw); int (*run_out) (HWVoiceOut *hw, int live); - int (*write) (SWVoiceOut *sw, void *buf, int size); int (*ctl_out) (HWVoiceOut *hw, int cmd, ...); =20 int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaq= ue); void (*fini_in) (HWVoiceIn *hw); int (*run_in) (HWVoiceIn *hw); - int (*read) (SWVoiceIn *sw, void *buf, int size); int (*ctl_in) (HWVoiceIn *hw, int cmd, ...); }; =20 @@ -210,11 +208,8 @@ audio_driver *audio_driver_lookup(const char *name); void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings = *as); void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len); =20 -int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len); int audio_pcm_hw_get_live_in (HWVoiceIn *hw); =20 -int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len); - int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, int live, int pending); =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 3daa7c8f8f..e9e3a4819c 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -270,11 +270,6 @@ static int alsa_poll_in (HWVoiceIn *hw) return alsa_poll_helper (alsa->handle, &alsa->pollhlp, POLLIN); } =20 -static int alsa_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness) { switch (fmt) { @@ -988,11 +983,6 @@ static int alsa_run_in (HWVoiceIn *hw) return read_samples; } =20 -static int alsa_read (SWVoiceIn *sw, void *buf, int size) -{ - return audio_pcm_sw_read (sw, buf, size); -} - static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...) { ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; @@ -1076,13 +1066,11 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { .init_out =3D alsa_init_out, .fini_out =3D alsa_fini_out, .run_out =3D alsa_run_out, - .write =3D alsa_write, .ctl_out =3D alsa_ctl_out, =20 .init_in =3D alsa_init_in, .fini_in =3D alsa_fini_in, .run_in =3D alsa_run_in, - .read =3D alsa_read, .ctl_in =3D alsa_ctl_in, }; =20 diff --git a/audio/audio.c b/audio/audio.c index 07b35ffa03..254499dfa1 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -594,7 +594,7 @@ static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw) } } =20 -int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size) +static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size) { HWVoiceIn *hw =3D sw->hw; int samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D 0; @@ -696,7 +696,7 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, i= nt *nb_live) /* * Soft voice (playback) */ -int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int size) +static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf, int size) { int hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, b= lck; int ret =3D 0, pos =3D 0, total =3D 0; @@ -854,7 +854,7 @@ int AUD_write (SWVoiceOut *sw, void *buf, int size) return 0; } =20 - return sw->hw->pcm_ops->write(sw, buf, size); + return audio_pcm_sw_write(sw, buf, size); } =20 int AUD_read (SWVoiceIn *sw, void *buf, int size) @@ -869,7 +869,7 @@ int AUD_read (SWVoiceIn *sw, void *buf, int size) return 0; } =20 - return sw->hw->pcm_ops->read(sw, buf, size); + return audio_pcm_sw_read(sw, buf, size); } =20 int AUD_get_buffer_size_out (SWVoiceOut *sw) diff --git a/audio/coreaudio.c b/audio/coreaudio.c index f0ab4014a8..091fe84a34 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -489,11 +489,6 @@ static OSStatus audioDeviceIOProc( return 0; } =20 -static int coreaudio_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) { @@ -692,7 +687,6 @@ static struct audio_pcm_ops coreaudio_pcm_ops =3D { .init_out =3D coreaudio_init_out, .fini_out =3D coreaudio_fini_out, .run_out =3D coreaudio_run_out, - .write =3D coreaudio_write, .ctl_out =3D coreaudio_ctl_out }; =20 diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 07260f881e..11594c3095 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -454,11 +454,6 @@ static int dsound_ctl_out (HWVoiceOut *hw, int cmd, ..= .) return 0; } =20 -static int dsound_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int dsound_run_out (HWVoiceOut *hw, int live) { int err; @@ -645,11 +640,6 @@ static int dsound_ctl_in (HWVoiceIn *hw, int cmd, ...) return 0; } =20 -static int dsound_read (SWVoiceIn *sw, void *buf, int len) -{ - return audio_pcm_sw_read (sw, buf, len); -} - static int dsound_run_in (HWVoiceIn *hw) { int err; @@ -856,13 +846,11 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { .init_out =3D dsound_init_out, .fini_out =3D dsound_fini_out, .run_out =3D dsound_run_out, - .write =3D dsound_write, .ctl_out =3D dsound_ctl_out, =20 .init_in =3D dsound_init_in, .fini_in =3D dsound_fini_in, .run_in =3D dsound_run_in, - .read =3D dsound_read, .ctl_in =3D dsound_ctl_in }; =20 diff --git a/audio/noaudio.c b/audio/noaudio.c index 14a0e4ab29..cbb02d9e49 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -61,11 +61,6 @@ static int no_run_out (HWVoiceOut *hw, int live) return decr; } =20 -static int no_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write(sw, buf, len); -} - static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_o= paque) { audio_pcm_init_info (&hw->info, as); @@ -118,18 +113,6 @@ static int no_run_in (HWVoiceIn *hw) return samples; } =20 -static int no_read (SWVoiceIn *sw, void *buf, int size) -{ - /* use custom code here instead of audio_pcm_sw_read() to avoid - * useless resampling/mixing */ - int samples =3D size >> sw->info.shift; - int total =3D sw->hw->total_samples_captured - sw->total_hw_samples_ac= quired; - int to_clear =3D MIN (samples, total); - sw->total_hw_samples_acquired +=3D total; - audio_pcm_info_clear_buf (&sw->info, buf, to_clear); - return to_clear << sw->info.shift; -} - static int no_ctl_in (HWVoiceIn *hw, int cmd, ...) { (void) hw; @@ -151,13 +134,11 @@ static struct audio_pcm_ops no_pcm_ops =3D { .init_out =3D no_init_out, .fini_out =3D no_fini_out, .run_out =3D no_run_out, - .write =3D no_write, .ctl_out =3D no_ctl_out, =20 .init_in =3D no_init_in, .fini_in =3D no_fini_in, .run_in =3D no_run_in, - .read =3D no_read, .ctl_in =3D no_ctl_in }; =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 456fba7480..b99edbec17 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -134,11 +134,6 @@ static void oss_poll_in (HWVoiceIn *hw) qemu_set_fd_handler(oss->fd, oss_helper_poll_in, NULL, hw->s); } =20 -static int oss_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int aud_to_ossfmt (AudioFormat fmt, int endianness) { switch (fmt) { @@ -788,11 +783,6 @@ static int oss_run_in (HWVoiceIn *hw) return read_samples; } =20 -static int oss_read (SWVoiceIn *sw, void *buf, int size) -{ - return audio_pcm_sw_read (sw, buf, size); -} - static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; @@ -855,13 +845,11 @@ static struct audio_pcm_ops oss_pcm_ops =3D { .init_out =3D oss_init_out, .fini_out =3D oss_fini_out, .run_out =3D oss_run_out, - .write =3D oss_write, .ctl_out =3D oss_ctl_out, =20 .init_in =3D oss_init_in, .fini_in =3D oss_fini_in, .run_in =3D oss_run_in, - .read =3D oss_read, .ctl_in =3D oss_ctl_in }; =20 diff --git a/audio/paaudio.c b/audio/paaudio.c index c8ae1a6eca..efb72ced30 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -295,11 +295,6 @@ static int qpa_run_out (HWVoiceOut *hw, int live) return decr; } =20 -static int qpa_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - /* capture */ static void *qpa_thread_in (void *arg) { @@ -388,11 +383,6 @@ static int qpa_run_in (HWVoiceIn *hw) return incr; } =20 -static int qpa_read (SWVoiceIn *sw, void *buf, int len) -{ - return audio_pcm_sw_read (sw, buf, len); -} - static pa_sample_format_t audfmt_to_pa (AudioFormat afmt, int endianness) { int format; @@ -1016,13 +1006,11 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { .init_out =3D qpa_init_out, .fini_out =3D qpa_fini_out, .run_out =3D qpa_run_out, - .write =3D qpa_write, .ctl_out =3D qpa_ctl_out, =20 .init_in =3D qpa_init_in, .fini_in =3D qpa_fini_in, .run_in =3D qpa_run_in, - .read =3D qpa_read, .ctl_in =3D qpa_ctl_in }; =20 diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 42f7614124..c7fd487e0e 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -217,11 +217,6 @@ static void sdl_callback (void *opaque, Uint8 *buf, in= t len) } } =20 -static int sdl_write_out (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int sdl_run_out (HWVoiceOut *hw, int live) { int decr; @@ -342,7 +337,6 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { .init_out =3D sdl_init_out, .fini_out =3D sdl_fini_out, .run_out =3D sdl_run_out, - .write =3D sdl_write_out, .ctl_out =3D sdl_ctl_out, }; =20 diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6f4a0558f8..6e7f13cffa 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -193,11 +193,6 @@ static int line_out_run (HWVoiceOut *hw, int live) return decr; } =20 -static int line_out_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - static int line_out_ctl (HWVoiceOut *hw, int cmd, ...) { SpiceVoiceOut *out =3D container_of (hw, SpiceVoiceOut, hw); @@ -326,11 +321,6 @@ static int line_in_run (HWVoiceIn *hw) return num_samples; } =20 -static int line_in_read (SWVoiceIn *sw, void *buf, int size) -{ - return audio_pcm_sw_read (sw, buf, size); -} - static int line_in_ctl (HWVoiceIn *hw, int cmd, ...) { SpiceVoiceIn *in =3D container_of (hw, SpiceVoiceIn, hw); @@ -378,13 +368,11 @@ static struct audio_pcm_ops audio_callbacks =3D { .init_out =3D line_out_init, .fini_out =3D line_out_fini, .run_out =3D line_out_run, - .write =3D line_out_write, .ctl_out =3D line_out_ctl, =20 .init_in =3D line_in_init, .fini_in =3D line_in_fini, .run_in =3D line_in_run, - .read =3D line_in_read, .ctl_in =3D line_in_ctl, }; =20 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index bbf3f3b346..17ab921cef 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -84,11 +84,6 @@ static int wav_run_out (HWVoiceOut *hw, int live) return decr; } =20 -static int wav_write_out (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - /* VICE code: Store number as little endian. */ static void le_store (uint8_t *buf, uint32_t val, int len) { @@ -240,7 +235,6 @@ static struct audio_pcm_ops wav_pcm_ops =3D { .init_out =3D wav_init_out, .fini_out =3D wav_fini_out, .run_out =3D wav_run_out, - .write =3D wav_write_out, .ctl_out =3D wav_ctl_out, }; =20 --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938539; cv=none; d=zoho.com; s=zohoarc; b=dapGxqxUKYpIPIWCtPIG99xYoy2m55z/tIeECylWmMiZYXAsWcQccYAcnTHe5WRd/5X6LQAXQzpQxuc3M+4X9J1TlLyNQidzHJ4crIKV9jC8XWulvG5+pmzLekPE5Lfz8UKxzFfAF/Oto4cQM3YZ+wv/sf1oohbbBO6HTuLIyIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938539; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aIu37KvQweuy5+WCYiKp8sjLXR2aWElS7r2AFXikGH8=; b=STxHyKpX+fFlAPPkGw1YfbDchFG1pFCKBlHa/Tk197hLjg1sA5DCcShri9o1rrZwW8K2vvSvB4Gh+hcUc5sGSh5kB+LyXPc5u5XFVfU7VlA2/XmdWRhFNgb3yb5sGHZX6dt3H2nGqDdBOnBObpze++qMO3V4ADat9lZimkEKXwA= 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 1564938539174892.984174811357; Sun, 4 Aug 2019 10:08:59 -0700 (PDT) Received: from localhost ([::1]:48908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huK0A-00041y-2R for importer@patchew.org; Sun, 04 Aug 2019 13:08:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56800) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJwB-0002QN-Nj for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw3-000497-65 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:49 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:45524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw2-000473-Ij for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:43 -0400 Received: by mail-wr1-x436.google.com with SMTP id f9so3141921wre.12 for ; Sun, 04 Aug 2019 10:04:41 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aIu37KvQweuy5+WCYiKp8sjLXR2aWElS7r2AFXikGH8=; b=a6GQtF8nqRYgah6kxUVeOmAOXDM6ayvgCrxoituYuvc3WYkgQO4N3YmsPel1rwfZru gcAiIEXNspG7aE8kQemJAiCoqPqW2+yu2Mmavpdzypkjoky6wbHsNaHOYWGf91z87lHo xpEWOnKuWHwvVlT2lSgeef3wyT2MWFTOEB7V6UTp3jV6+xyTtNPVqBEx3CWJMNaRsscS fwUj38UCfkAk6au9dZpAZpwF/qyJEq5LT0qspYc8srCYVKNLgXwpCAa7ZXYZe0B0U7iP GR297nJhs14SYCHJu2MzxxxHFQsKRgvz4M00WPVnenusK6fvrRVTo338mIiurEb95nR8 OA/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aIu37KvQweuy5+WCYiKp8sjLXR2aWElS7r2AFXikGH8=; b=gAASYkatrvo8EY1oMi8IswQPl0S3cMOvuaG86UNQCZbabtlUBKuzLNNKVbCpx9xF9J IjZbfnxmWFcsTUlzAhDrHRtj6aLUGuHn/nM2ZE0PQbhSgVpLxKDZ74M3UB+q/h9HD0Sf qRr3MSGi1TRDyO/jEBMhLpAJPf+8L5zm5MS+zrtUMimPIlb14MLASqr5b/c7yayBJU2z NWiDAXacyBIUyS4KAThofWkaGekKpxk8Io3qdWSbmthbVvD7S5u7fnQqvDtbGZjbWFh0 WSaynyShVYl7tEJcrUWa7OMDQuGX7Uagl2QkIOyMvK11Kjtp//9KaYteI9BG/lJ22j6u 7cZw== X-Gm-Message-State: APjAAAVBFsoePcQi1bFeGpjenK/iKvA0DsgS9x2vNEC1W9ZHKjO8eON4 jYf0J5I7X0ExCNbS9fDmYGd9G13Jchw= X-Google-Smtp-Source: APXvYqyZR1/oI3EYko8lIrOPV2vg0ojd5AVQh/vYsuvkm6kAhFz2rlOvj6tj/XFEHvygHuqRk7ML3A== X-Received: by 2002:adf:eb51:: with SMTP id u17mr15246534wrn.257.1564938279953; Sun, 04 Aug 2019 10:04:39 -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: Sun, 4 Aug 2019 19:04:25 +0200 Message-Id: <77ff4b0fa47bdf2766d2e0d5d3dafe759bd35a39.1564925486.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::436 Subject: [Qemu-devel] [PATCH v3 13/14] audio: use size_t where makes sense X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Gerd Hoffmann , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio.h | 4 +- audio/audio_int.h | 26 +++---- audio/audio_template.h | 14 ++-- audio/mixeng.h | 9 +-- audio/rate_template.h | 2 +- include/sysemu/replay.h | 4 +- audio/alsaaudio.c | 26 +++---- audio/audio.c | 156 ++++++++++++++++++++-------------------- audio/coreaudio.c | 10 +-- audio/dsoundaudio.c | 11 +-- audio/noaudio.c | 16 ++--- audio/ossaudio.c | 45 ++++++------ audio/paaudio.c | 44 ++++++------ audio/sdlaudio.c | 20 +++--- audio/spiceaudio.c | 12 ++-- audio/wavaudio.c | 8 +-- replay/replay-audio.c | 16 ++--- replay/replay.c | 2 +- 18 files changed, 212 insertions(+), 213 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index 4a95758516..2db27bba7b 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -112,7 +112,7 @@ SWVoiceOut *AUD_open_out ( ); =20 void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw); -int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size); +size_t AUD_write (SWVoiceOut *sw, void *pcm_buf, size_t size); int AUD_get_buffer_size_out (SWVoiceOut *sw); void AUD_set_active_out (SWVoiceOut *sw, int on); int AUD_is_active_out (SWVoiceOut *sw); @@ -133,7 +133,7 @@ SWVoiceIn *AUD_open_in ( ); =20 void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw); -int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size); +size_t AUD_read (SWVoiceIn *sw, void *pcm_buf, size_t size); void AUD_set_active_in (SWVoiceIn *sw, int on); int AUD_is_active_in (SWVoiceIn *sw); =20 diff --git a/audio/audio_int.h b/audio/audio_int.h index 003b7ab8cc..a674c5374a 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -61,12 +61,12 @@ typedef struct HWVoiceOut { =20 f_sample *clip; =20 - int rpos; + size_t rpos; uint64_t ts_helper; =20 struct st_sample *mix_buf; =20 - int samples; + size_t samples; QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head; QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head; int ctl_caps; @@ -82,13 +82,13 @@ typedef struct HWVoiceIn { =20 t_sample *conv; =20 - int wpos; - int total_samples_captured; + size_t wpos; + size_t total_samples_captured; uint64_t ts_helper; =20 struct st_sample *conv_buf; =20 - int samples; + size_t samples; QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head; int ctl_caps; struct audio_pcm_ops *pcm_ops; @@ -103,7 +103,7 @@ struct SWVoiceOut { int64_t ratio; struct st_sample *buf; void *rate; - int total_hw_samples_mixed; + size_t total_hw_samples_mixed; int active; int empty; HWVoiceOut *hw; @@ -120,7 +120,7 @@ struct SWVoiceIn { struct audio_pcm_info info; int64_t ratio; void *rate; - int total_hw_samples_acquired; + size_t total_hw_samples_acquired; struct st_sample *buf; f_sample *clip; HWVoiceIn *hw; @@ -149,12 +149,12 @@ struct audio_driver { struct audio_pcm_ops { int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opa= que); void (*fini_out)(HWVoiceOut *hw); - int (*run_out) (HWVoiceOut *hw, int live); + size_t (*run_out)(HWVoiceOut *hw, size_t live); int (*ctl_out) (HWVoiceOut *hw, int cmd, ...); =20 int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaq= ue); void (*fini_in) (HWVoiceIn *hw); - int (*run_in) (HWVoiceIn *hw); + size_t (*run_in)(HWVoiceIn *hw); int (*ctl_in) (HWVoiceIn *hw, int cmd, ...); }; =20 @@ -208,10 +208,10 @@ audio_driver *audio_driver_lookup(const char *name); void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings = *as); void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len); =20 -int audio_pcm_hw_get_live_in (HWVoiceIn *hw); +size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw); =20 -int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, - int live, int pending); +size_t audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, + size_t live, size_t pending); =20 int audio_bug (const char *funcname, int cond); void *audio_calloc (const char *funcname, int nmemb, size_t size); @@ -224,7 +224,7 @@ void audio_run(AudioState *s, const char *msg); =20 #define VOICE_VOLUME_CAP (1 << VOICE_VOLUME) =20 -static inline int audio_ring_dist (int dst, int src, int len) +static inline size_t audio_ring_dist(size_t dst, size_t src, size_t len) { return (dst >=3D src) ? (dst - src) : (len - src + dst); } diff --git a/audio/audio_template.h b/audio/audio_template.h index 54f07338e7..2562bf5f00 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -75,16 +75,16 @@ static void glue (audio_pcm_hw_free_resources_, TYPE) (= HW *hw) HWBUF =3D NULL; } =20 -static int glue (audio_pcm_hw_alloc_resources_, TYPE) (HW *hw) +static bool glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw) { HWBUF =3D audio_calloc(__func__, hw->samples, sizeof(struct st_sample)= ); if (!HWBUF) { - dolog ("Could not allocate " NAME " buffer (%d samples)\n", - hw->samples); - return -1; + dolog("Could not allocate " NAME " buffer (%zu samples)\n", + hw->samples); + return false; } =20 - return 0; + return true; } =20 static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw) @@ -265,7 +265,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState= *s, } =20 if (audio_bug(__func__, hw->samples <=3D 0)) { - dolog ("hw->samples=3D%d\n", hw->samples); + dolog("hw->samples=3D%zd\n", hw->samples); goto err1; } =20 @@ -279,7 +279,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState= *s, [hw->info.swap_endianness] [audio_bits_to_index (hw->info.bits)]; =20 - if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) { + if (!glue(audio_pcm_hw_alloc_resources_, TYPE)(hw)) { goto err1; } =20 diff --git a/audio/mixeng.h b/audio/mixeng.h index b53a5ef99a..18e62c7c49 100644 --- a/audio/mixeng.h +++ b/audio/mixeng.h @@ -33,6 +33,7 @@ struct st_sample { mixeng_real l; mixeng_real r; }; struct mixeng_volume { int mute; int64_t r; int64_t l; }; struct st_sample { int64_t l; int64_t r; }; #endif +typedef struct st_sample st_sample; =20 typedef void (t_sample) (struct st_sample *dst, const void *src, int sampl= es); typedef void (f_sample) (void *dst, const struct st_sample *src, int sampl= es); @@ -41,10 +42,10 @@ extern t_sample *mixeng_conv[2][2][2][3]; extern f_sample *mixeng_clip[2][2][2][3]; =20 void *st_rate_start (int inrate, int outrate); -void st_rate_flow (void *opaque, struct st_sample *ibuf, struct st_sample = *obuf, - int *isamp, int *osamp); -void st_rate_flow_mix (void *opaque, struct st_sample *ibuf, struct st_sam= ple *obuf, - int *isamp, int *osamp); +void st_rate_flow(void *opaque, st_sample *ibuf, st_sample *obuf, + size_t *isamp, size_t *osamp); +void st_rate_flow_mix(void *opaque, st_sample *ibuf, st_sample *obuf, + size_t *isamp, size_t *osamp); void st_rate_stop (void *opaque); void mixeng_clear (struct st_sample *buf, int len); void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *= vol); diff --git a/audio/rate_template.h b/audio/rate_template.h index 6e93588877..f94c940c61 100644 --- a/audio/rate_template.h +++ b/audio/rate_template.h @@ -28,7 +28,7 @@ * Return number of samples processed. */ void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf, - int *isamp, int *osamp) + size_t *isamp, size_t *osamp) { struct rate *rate =3D opaque; struct st_sample *istart, *iend; diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index 3a7c58e423..5c0a91e44f 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -179,9 +179,9 @@ void replay_net_packet_event(ReplayNetState *rns, unsig= ned flags, /* Audio */ =20 /*! Saves/restores number of played samples of audio out operation. */ -void replay_audio_out(int *played); +void replay_audio_out(size_t *played); /*! Saves/restores recorded samples of audio in operation. */ -void replay_audio_in(int *recorded, void *samples, int *wpos, int size); +void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t= size); =20 /* VM state operations */ =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index e9e3a4819c..591344dccd 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -681,10 +681,10 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) } } =20 -static int alsa_run_out (HWVoiceOut *hw, int live) +static size_t alsa_run_out(HWVoiceOut *hw, size_t live) { ALSAVoiceOut *alsa =3D (ALSAVoiceOut *) hw; - int decr; + size_t decr; snd_pcm_sframes_t avail; =20 avail =3D alsa_get_avail (alsa->handle); @@ -739,8 +739,8 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as, =20 alsa->pcm_buf =3D audio_calloc(__func__, obt.samples, 1 << hw->info.sh= ift); if (!alsa->pcm_buf) { - dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\= n", - hw->samples, 1 << hw->info.shift); + dolog("Could not allocate DAC buffer (%zu samples, each %d bytes)\= n", + hw->samples, 1 << hw->info.shift); alsa_anal_close1 (&handle); return -1; } @@ -841,8 +841,8 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) =20 alsa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.sh= ift); if (!alsa->pcm_buf) { - dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\= n", - hw->samples, 1 << hw->info.shift); + dolog("Could not allocate ADC buffer (%zu samples, each %d bytes)\= n", + hw->samples, 1 << hw->info.shift); alsa_anal_close1 (&handle); return -1; } @@ -863,17 +863,17 @@ static void alsa_fini_in (HWVoiceIn *hw) alsa->pcm_buf =3D NULL; } =20 -static int alsa_run_in (HWVoiceIn *hw) +static size_t alsa_run_in(HWVoiceIn *hw) { ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; int hwshift =3D hw->info.shift; int i; - int live =3D audio_pcm_hw_get_live_in (hw); - int dead =3D hw->samples - live; - int decr; + size_t live =3D audio_pcm_hw_get_live_in (hw); + size_t dead =3D hw->samples - live; + size_t decr; struct { - int add; - int len; + size_t add; + size_t len; } bufs[2] =3D { { .add =3D hw->wpos, .len =3D 0 }, { .add =3D 0, .len =3D 0 } @@ -913,7 +913,7 @@ static int alsa_run_in (HWVoiceIn *hw) } } =20 - decr =3D MIN (dead, avail); + decr =3D MIN(dead, avail); if (!decr) { return 0; } diff --git a/audio/audio.c b/audio/audio.c index 254499dfa1..d3c639211d 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -526,10 +526,10 @@ static int audio_attach_capture (HWVoiceOut *hw) /* * Hard voice (capture) */ -static int audio_pcm_hw_find_min_in (HWVoiceIn *hw) +static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw) { SWVoiceIn *sw; - int m =3D hw->total_samples_captured; + size_t m =3D hw->total_samples_captured; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active) { @@ -539,28 +539,28 @@ static int audio_pcm_hw_find_min_in (HWVoiceIn *hw) return m; } =20 -int audio_pcm_hw_get_live_in (HWVoiceIn *hw) +size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) { - int live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in (hw= ); - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + size_t live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in = (hw); + if (audio_bug(__func__, live > hw->samples)) { + dolog("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } return live; } =20 -int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, - int live, int pending) +size_t audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, + size_t live, size_t pending) { - int left =3D hw->samples - pending; - int len =3D MIN (left, live); - int clipped =3D 0; + size_t left =3D hw->samples - pending; + size_t len =3D MIN (left, live); + size_t clipped =3D 0; =20 while (len) { struct st_sample *src =3D hw->mix_buf + hw->rpos; uint8_t *dst =3D advance (pcm_buf, hw->rpos << hw->info.shift); - int samples_till_end_of_buf =3D hw->samples - hw->rpos; - int samples_to_clip =3D MIN (len, samples_till_end_of_buf); + size_t samples_till_end_of_buf =3D hw->samples - hw->rpos; + size_t samples_to_clip =3D MIN (len, samples_till_end_of_buf); =20 hw->clip (dst, src, samples_to_clip); =20 @@ -574,14 +574,14 @@ int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_= buf, /* * Soft voice (capture) */ -static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw) +static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) { HWVoiceIn *hw =3D sw->hw; - int live =3D hw->total_samples_captured - sw->total_hw_samples_acquire= d; - int rpos; + ssize_t live =3D hw->total_samples_captured - sw->total_hw_samples_acq= uired; + ssize_t rpos; =20 if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + dolog("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } =20 @@ -594,17 +594,17 @@ static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw) } } =20 -static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, int size) +static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) { HWVoiceIn *hw =3D sw->hw; - int samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D 0; + size_t samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D = 0; struct st_sample *src, *dst =3D sw->buf; =20 rpos =3D audio_pcm_sw_get_rpos_in (sw) % hw->samples; =20 live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live_in=3D%d hw->samples=3D%d\n", live, hw->samples); + if (audio_bug(__func__, live > hw->samples)) { + dolog("live_in=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } =20 @@ -618,9 +618,9 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf, = int size) =20 while (swlim) { src =3D hw->conv_buf + rpos; - isamp =3D hw->wpos - rpos; - /* XXX: <=3D ? */ - if (isamp <=3D 0) { + if (hw->wpos > rpos) { + isamp =3D hw->wpos - rpos; + } else { isamp =3D hw->samples - rpos; } =20 @@ -629,11 +629,6 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf,= int size) } osamp =3D swlim; =20 - if (audio_bug(__func__, osamp < 0)) { - dolog ("osamp=3D%d\n", osamp); - return 0; - } - st_rate_flow (sw->rate, src, dst, &isamp, &osamp); swlim -=3D osamp; rpos =3D (rpos + isamp) % hw->samples; @@ -654,10 +649,10 @@ static int audio_pcm_sw_read(SWVoiceIn *sw, void *buf= , int size) /* * Hard voice (playback) */ -static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep) +static size_t audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep) { SWVoiceOut *sw; - int m =3D INT_MAX; + size_t m =3D SIZE_MAX; int nb_live =3D 0; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { @@ -671,9 +666,9 @@ static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, i= nt *nb_livep) return m; } =20 -static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live) +static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live) { - int smin; + size_t smin; int nb_live1; =20 smin =3D audio_pcm_hw_find_min_out (hw, &nb_live1); @@ -682,10 +677,10 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw,= int *nb_live) } =20 if (nb_live1) { - int live =3D smin; + size_t live =3D smin; =20 - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + if (audio_bug(__func__, live > hw->samples)) { + dolog("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); return 0; } return live; @@ -696,10 +691,10 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw,= int *nb_live) /* * Soft voice (playback) */ -static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf, int size) +static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) { - int hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, b= lck; - int ret =3D 0, pos =3D 0, total =3D 0; + size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim= , blck; + size_t ret =3D 0, pos =3D 0, total =3D 0; =20 if (!sw) { return size; @@ -708,8 +703,8 @@ static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf= , int size) hwsamples =3D sw->hw->samples; =20 live =3D sw->total_hw_samples_mixed; - if (audio_bug(__func__, live < 0 || live > hwsamples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hwsamples); + if (audio_bug(__func__, live > hwsamples)) { + dolog("live=3D%zu hw->samples=3D%zu\n", live, hwsamples); return 0; } =20 @@ -763,7 +758,7 @@ static int audio_pcm_sw_write(SWVoiceOut *sw, void *buf= , int size) =20 #ifdef DEBUG_OUT dolog ( - "%s: write size %d ret %d total sw %d\n", + "%s: write size %zu ret %zu total sw %zu\n", SW_NAME (sw), size >> sw->info.shift, ret, @@ -842,7 +837,7 @@ static void audio_timer (void *opaque) /* * Public API */ -int AUD_write (SWVoiceOut *sw, void *buf, int size) +size_t AUD_write(SWVoiceOut *sw, void *buf, size_t size) { if (!sw) { /* XXX: Consider options */ @@ -857,7 +852,7 @@ int AUD_write (SWVoiceOut *sw, void *buf, int size) return audio_pcm_sw_write(sw, buf, size); } =20 -int AUD_read (SWVoiceIn *sw, void *buf, int size) +size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size) { if (!sw) { /* XXX: Consider options */ @@ -966,17 +961,17 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) } } =20 -static int audio_get_avail (SWVoiceIn *sw) +static size_t audio_get_avail (SWVoiceIn *sw) { - int live; + size_t live; =20 if (!sw) { return 0; } =20 live =3D sw->hw->total_samples_captured - sw->total_hw_samples_acquire= d; - if (audio_bug(__func__, live < 0 || live > sw->hw->samples)) { - dolog ("live=3D%d sw->hw->samples=3D%d\n", live, sw->hw->samples); + if (audio_bug(__func__, live > sw->hw->samples)) { + dolog("live=3D%zu sw->hw->samples=3D%zu\n", live, sw->hw->samples); return 0; } =20 @@ -989,9 +984,9 @@ static int audio_get_avail (SWVoiceIn *sw) return (((int64_t) live << 32) / sw->ratio) << sw->info.shift; } =20 -static int audio_get_free (SWVoiceOut *sw) +static size_t audio_get_free(SWVoiceOut *sw) { - int live, dead; + size_t live, dead; =20 if (!sw) { return 0; @@ -999,8 +994,8 @@ static int audio_get_free (SWVoiceOut *sw) =20 live =3D sw->total_hw_samples_mixed; =20 - if (audio_bug(__func__, live < 0 || live > sw->hw->samples)) { - dolog ("live=3D%d sw->hw->samples=3D%d\n", live, sw->hw->samples); + if (audio_bug(__func__, live > sw->hw->samples)) { + dolog("live=3D%zu sw->hw->samples=3D%zu\n", live, sw->hw->samples); return 0; } =20 @@ -1015,9 +1010,10 @@ static int audio_get_free (SWVoiceOut *sw) return (((int64_t) dead << 32) / sw->ratio) << sw->info.shift; } =20 -static void audio_capture_mix_and_clear (HWVoiceOut *hw, int rpos, int sam= ples) +static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos, + size_t samples) { - int n; + size_t n; =20 if (hw->enabled) { SWVoiceCap *sc; @@ -1028,17 +1024,17 @@ static void audio_capture_mix_and_clear (HWVoiceOut= *hw, int rpos, int samples) =20 n =3D samples; while (n) { - int till_end_of_hw =3D hw->samples - rpos2; - int to_write =3D MIN (till_end_of_hw, n); - int bytes =3D to_write << hw->info.shift; - int written; + size_t till_end_of_hw =3D hw->samples - rpos2; + size_t to_write =3D MIN(till_end_of_hw, n); + size_t bytes =3D to_write << hw->info.shift; + size_t written; =20 sw->buf =3D hw->mix_buf + rpos2; written =3D audio_pcm_sw_write (sw, NULL, bytes); if (written - bytes) { - dolog ("Could not mix %d bytes into a capture " - "buffer, mixed %d\n", - bytes, written); + dolog("Could not mix %zu bytes into a capture " + "buffer, mixed %zu\n", + bytes, written); break; } n -=3D to_write; @@ -1047,9 +1043,9 @@ static void audio_capture_mix_and_clear (HWVoiceOut *= hw, int rpos, int samples) } } =20 - n =3D MIN (samples, hw->samples - rpos); - mixeng_clear (hw->mix_buf + rpos, n); - mixeng_clear (hw->mix_buf, samples - n); + n =3D MIN(samples, hw->samples - rpos); + mixeng_clear(hw->mix_buf + rpos, n); + mixeng_clear(hw->mix_buf, samples - n); } =20 static void audio_run_out (AudioState *s) @@ -1058,16 +1054,16 @@ static void audio_run_out (AudioState *s) SWVoiceOut *sw; =20 while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { - int played; - int live, free, nb_live, cleanup_required, prev_rpos; + size_t played, live, prev_rpos, free; + int nb_live, cleanup_required; =20 live =3D audio_pcm_hw_get_live_out (hw, &nb_live); if (!nb_live) { live =3D 0; } =20 - if (audio_bug(__func__, live < 0 || live > hw->samples)) { - dolog ("live=3D%d hw->samples=3D%d\n", live, hw->samples); + if (audio_bug(__func__, live > hw->samples)) { + dolog ("live=3D%zu hw->samples=3D%zu\n", live, hw->samples); continue; } =20 @@ -1102,13 +1098,13 @@ static void audio_run_out (AudioState *s) played =3D hw->pcm_ops->run_out (hw, live); replay_audio_out(&played); if (audio_bug(__func__, hw->rpos >=3D hw->samples)) { - dolog ("hw->rpos=3D%d hw->samples=3D%d played=3D%d\n", - hw->rpos, hw->samples, played); + dolog("hw->rpos=3D%zu hw->samples=3D%zu played=3D%zu\n", + hw->rpos, hw->samples, played); hw->rpos =3D 0; } =20 #ifdef DEBUG_OUT - dolog ("played=3D%d\n", played); + dolog("played=3D%zu\n", played); #endif =20 if (played) { @@ -1123,8 +1119,8 @@ static void audio_run_out (AudioState *s) } =20 if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) { - dolog ("played=3D%d sw->total_hw_samples_mixed=3D%d\n", - played, sw->total_hw_samples_mixed); + dolog("played=3D%zu sw->total_hw_samples_mixed=3D%zu\n", + played, sw->total_hw_samples_mixed); played =3D sw->total_hw_samples_mixed; } =20 @@ -1164,7 +1160,7 @@ static void audio_run_in (AudioState *s) =20 while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { SWVoiceIn *sw; - int captured =3D 0, min; + size_t captured =3D 0, min; =20 if (replay_mode !=3D REPLAY_MODE_PLAY) { captured =3D hw->pcm_ops->run_in(hw); @@ -1179,7 +1175,7 @@ static void audio_run_in (AudioState *s) sw->total_hw_samples_acquired -=3D min; =20 if (sw->active) { - int avail; + size_t avail; =20 avail =3D audio_get_avail (sw); if (avail > 0) { @@ -1195,15 +1191,15 @@ static void audio_run_capture (AudioState *s) CaptureVoiceOut *cap; =20 for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { - int live, rpos, captured; + size_t live, rpos, captured; HWVoiceOut *hw =3D &cap->hw; SWVoiceOut *sw; =20 captured =3D live =3D audio_pcm_hw_get_live_out (hw, NULL); rpos =3D hw->rpos; while (live) { - int left =3D hw->samples - rpos; - int to_capture =3D MIN (live, left); + size_t left =3D hw->samples - rpos; + size_t to_capture =3D MIN(live, left); struct st_sample *src; struct capture_callback *cb; =20 @@ -1226,8 +1222,8 @@ static void audio_run_capture (AudioState *s) } =20 if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)= ) { - dolog ("captured=3D%d sw->total_hw_samples_mixed=3D%d\n", - captured, sw->total_hw_samples_mixed); + dolog("captured=3D%zu sw->total_hw_samples_mixed=3D%zu\n", + captured, sw->total_hw_samples_mixed); captured =3D sw->total_hw_samples_mixed; } =20 diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 091fe84a34..d1be58b40a 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -43,9 +43,9 @@ typedef struct coreaudioVoiceOut { UInt32 audioDevicePropertyBufferFrameSize; AudioStreamBasicDescription outputStreamBasicDescription; AudioDeviceIOProcID ioprocid; - int live; - int decr; - int rpos; + size_t live; + size_t decr; + size_t rpos; } coreaudioVoiceOut; =20 #if MAC_OS_X_VERSION_MAX_ALLOWED >=3D MAC_OS_X_VERSION_10_6 @@ -397,9 +397,9 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, c= onst char *fn_name) return 0; } =20 -static int coreaudio_run_out (HWVoiceOut *hw, int live) +static size_t coreaudio_run_out(HWVoiceOut *hw, size_t live) { - int decr; + size_t decr; coreaudioVoiceOut *core =3D (coreaudioVoiceOut *) hw; =20 if (coreaudio_lock (core, "coreaudio_run_out")) { diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 11594c3095..67aa1d0ad5 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -454,19 +454,20 @@ static int dsound_ctl_out (HWVoiceOut *hw, int cmd, .= ..) return 0; } =20 -static int dsound_run_out (HWVoiceOut *hw, int live) +static size_t dsound_run_out(HWVoiceOut *hw, size_t live) { int err; HRESULT hr; DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; - int len, hwshift; + size_t len; + int hwshift; DWORD blen1, blen2; DWORD len1, len2; DWORD decr; DWORD wpos, ppos, old_pos; LPVOID p1, p2; - int bufsize; + size_t bufsize; dsound *s =3D ds->s; AudiodevDsoundOptions *dso =3D &s->dev->u.dsound; =20 @@ -640,13 +641,13 @@ static int dsound_ctl_in (HWVoiceIn *hw, int cmd, ...) return 0; } =20 -static int dsound_run_in (HWVoiceIn *hw) +static size_t dsound_run_in(HWVoiceIn *hw) { int err; HRESULT hr; DSoundVoiceIn *ds =3D (DSoundVoiceIn *) hw; LPDIRECTSOUNDCAPTUREBUFFER dscb =3D ds->dsound_capture_buffer; - int live, len, dead; + size_t live, len, dead; DWORD blen1, blen2; DWORD len1, len2; DWORD decr; diff --git a/audio/noaudio.c b/audio/noaudio.c index cbb02d9e49..0fb2629cf2 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -41,10 +41,10 @@ typedef struct NoVoiceIn { int64_t old_ticks; } NoVoiceIn; =20 -static int no_run_out (HWVoiceOut *hw, int live) +static size_t no_run_out(HWVoiceOut *hw, size_t live) { NoVoiceOut *no =3D (NoVoiceOut *) hw; - int decr, samples; + size_t decr, samples; int64_t now; int64_t ticks; int64_t bytes; @@ -52,7 +52,7 @@ static int no_run_out (HWVoiceOut *hw, int live) now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ticks =3D now - no->old_ticks; bytes =3D muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_S= ECOND); - bytes =3D MIN(bytes, INT_MAX); + bytes =3D MIN(bytes, SIZE_MAX); samples =3D bytes >> hw->info.shift; =20 no->old_ticks =3D now; @@ -92,12 +92,12 @@ static void no_fini_in (HWVoiceIn *hw) (void) hw; } =20 -static int no_run_in (HWVoiceIn *hw) +static size_t no_run_in(HWVoiceIn *hw) { NoVoiceIn *no =3D (NoVoiceIn *) hw; - int live =3D audio_pcm_hw_get_live_in (hw); - int dead =3D hw->samples - live; - int samples =3D 0; + size_t live =3D audio_pcm_hw_get_live_in(hw); + size_t dead =3D hw->samples - live; + size_t samples =3D 0; =20 if (dead) { int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); @@ -106,7 +106,7 @@ static int no_run_in (HWVoiceIn *hw) muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SEC= OND); =20 no->old_ticks =3D now; - bytes =3D MIN (bytes, INT_MAX); + bytes =3D MIN (bytes, SIZE_MAX); samples =3D bytes >> hw->info.shift; samples =3D MIN (samples, dead); } diff --git a/audio/ossaudio.c b/audio/ossaudio.c index b99edbec17..1696933688 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -411,13 +411,14 @@ static void oss_write_pending (OSSVoiceOut *oss) } } =20 -static int oss_run_out (HWVoiceOut *hw, int live) +static size_t oss_run_out(HWVoiceOut *hw, size_t live) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; - int err, decr; + int err; + size_t decr; struct audio_buf_info abinfo; struct count_info cntinfo; - int bufsize; + size_t bufsize; =20 bufsize =3D hw->samples << hw->info.shift; =20 @@ -476,8 +477,8 @@ static void oss_fini_out (HWVoiceOut *hw) if (oss->mmapped) { err =3D munmap (oss->pcm_buf, hw->samples << hw->info.shift); if (err) { - oss_logerr (errno, "Failed to unmap buffer %p, size %d\n", - oss->pcm_buf, hw->samples << hw->info.shift); + oss_logerr(errno, "Failed to unmap buffer %p, size %zu\n", + oss->pcm_buf, hw->samples << hw->info.shift); } } else { @@ -543,8 +544,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, 0 ); if (oss->pcm_buf =3D=3D MAP_FAILED) { - oss_logerr (errno, "Failed to map %d bytes of DAC\n", - hw->samples << hw->info.shift); + oss_logerr(errno, "Failed to map %zu bytes of DAC\n", + hw->samples << hw->info.shift); } else { int err; @@ -568,8 +569,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, if (!oss->mmapped) { err =3D munmap (oss->pcm_buf, hw->samples << hw->info.shif= t); if (err) { - oss_logerr (errno, "Failed to unmap buffer %p size %d\= n", - oss->pcm_buf, hw->samples << hw->info.shif= t); + oss_logerr(errno, "Failed to unmap buffer %p size %zu\= n", + oss->pcm_buf, hw->samples << hw->info.shift= ); } } } @@ -581,7 +582,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, 1 << hw->info.shift); if (!oss->pcm_buf) { dolog ( - "Could not allocate DAC buffer (%d samples, each %d bytes)= \n", + "Could not allocate DAC buffer (%zu samples, each %d bytes= )\n", hw->samples, 1 << hw->info.shift ); @@ -693,8 +694,8 @@ static int oss_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) hw->samples =3D (obt.nfrags * obt.fragsize) >> hw->info.shift; oss->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shi= ft); if (!oss->pcm_buf) { - dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\= n", - hw->samples, 1 << hw->info.shift); + dolog("Could not allocate ADC buffer (%zu samples, each %d bytes)\= n", + hw->samples, 1 << hw->info.shift); oss_anal_close (&fd); return -1; } @@ -714,17 +715,17 @@ static void oss_fini_in (HWVoiceIn *hw) oss->pcm_buf =3D NULL; } =20 -static int oss_run_in (HWVoiceIn *hw) +static size_t oss_run_in(HWVoiceIn *hw) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; int hwshift =3D hw->info.shift; int i; - int live =3D audio_pcm_hw_get_live_in (hw); - int dead =3D hw->samples - live; + size_t live =3D audio_pcm_hw_get_live_in (hw); + size_t dead =3D hw->samples - live; size_t read_samples =3D 0; struct { - int add; - int len; + size_t add; + size_t len; } bufs[2] =3D { { .add =3D hw->wpos, .len =3D 0 }, { .add =3D 0, .len =3D 0 } @@ -751,9 +752,9 @@ static int oss_run_in (HWVoiceIn *hw) =20 if (nread > 0) { if (nread & hw->info.align) { - dolog ("warning: Misaligned read %zd (requested %d), " - "alignment %d\n", nread, bufs[i].add << hwshift, - hw->info.align + 1); + dolog("warning: Misaligned read %zd (requested %zu), " + "alignment %d\n", nread, bufs[i].add << hwshift, + hw->info.align + 1); } read_samples +=3D nread >> hwshift; hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift); @@ -766,9 +767,9 @@ static int oss_run_in (HWVoiceIn *hw) case EAGAIN: break; default: - oss_logerr ( + oss_logerr( errno, - "Failed to read %d bytes of audio (to %p)\n", + "Failed to read %zu bytes of audio (to %p)\n", bufs[i].len, p ); break; diff --git a/audio/paaudio.c b/audio/paaudio.c index efb72ced30..bfef9acaad 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -30,30 +30,30 @@ typedef struct { =20 typedef struct { HWVoiceOut hw; - int done; - int live; - int decr; - int rpos; + size_t done; + size_t live; + size_t decr; + size_t rpos; pa_stream *stream; void *pcm_buf; struct audio_pt pt; paaudio *g; - int samples; + size_t samples; } PAVoiceOut; =20 typedef struct { HWVoiceIn hw; - int done; - int dead; - int incr; - int wpos; + size_t done; + size_t dead; + size_t incr; + size_t wpos; pa_stream *stream; void *pcm_buf; struct audio_pt pt; const void *read_data; size_t read_index, read_length; paaudio *g; - int samples; + size_t samples; } PAVoiceIn; =20 static void qpa_conn_fini(PAConnection *c); @@ -219,7 +219,7 @@ static void *qpa_thread_out (void *arg) } =20 for (;;) { - int decr, to_mix, rpos; + size_t decr, to_mix, rpos; =20 for (;;) { if (pa->done) { @@ -244,7 +244,7 @@ static void *qpa_thread_out (void *arg) =20 while (to_mix) { int error; - int chunk =3D MIN (to_mix, hw->samples - rpos); + size_t chunk =3D MIN (to_mix, hw->samples - rpos); struct st_sample *src =3D hw->mix_buf + rpos; =20 hw->clip (pa->pcm_buf, src, chunk); @@ -273,9 +273,9 @@ static void *qpa_thread_out (void *arg) return NULL; } =20 -static int qpa_run_out (HWVoiceOut *hw, int live) +static size_t qpa_run_out(HWVoiceOut *hw, size_t live) { - int decr; + size_t decr; PAVoiceOut *pa =3D (PAVoiceOut *) hw; =20 if (audio_pt_lock(&pa->pt, __func__)) { @@ -306,7 +306,7 @@ static void *qpa_thread_in (void *arg) } =20 for (;;) { - int incr, to_grab, wpos; + size_t incr, to_grab, wpos; =20 for (;;) { if (pa->done) { @@ -331,7 +331,7 @@ static void *qpa_thread_in (void *arg) =20 while (to_grab) { int error; - int chunk =3D MIN (to_grab, hw->samples - wpos); + size_t chunk =3D MIN (to_grab, hw->samples - wpos); void *buf =3D advance (pa->pcm_buf, wpos); =20 if (qpa_simple_read (pa, buf, @@ -359,9 +359,9 @@ static void *qpa_thread_in (void *arg) return NULL; } =20 -static int qpa_run_in (HWVoiceIn *hw) +static size_t qpa_run_in(HWVoiceIn *hw) { - int live, incr, dead; + size_t live, incr, dead; PAVoiceIn *pa =3D (PAVoiceIn *) hw; =20 if (audio_pt_lock(&pa->pt, __func__)) { @@ -582,8 +582,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, pa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shif= t); pa->rpos =3D hw->rpos; if (!pa->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog("Could not allocate buffer (%zu bytes)\n", + hw->samples << hw->info.shift); goto fail2; } =20 @@ -650,8 +650,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) pa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shif= t); pa->wpos =3D hw->wpos; if (!pa->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog("Could not allocate buffer (%zu bytes)\n", + hw->samples << hw->info.shift); goto fail2; } =20 diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index c7fd487e0e..14b11f0335 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -41,8 +41,8 @@ =20 typedef struct SDLVoiceOut { HWVoiceOut hw; - int live; - int decr; + size_t live; + size_t decr; } SDLVoiceOut; =20 static struct SDLAudioState { @@ -184,22 +184,22 @@ static void sdl_callback (void *opaque, Uint8 *buf, i= nt len) SDLVoiceOut *sdl =3D opaque; SDLAudioState *s =3D &glob_sdl; HWVoiceOut *hw =3D &sdl->hw; - int samples =3D len >> hw->info.shift; - int to_mix, decr; + size_t samples =3D len >> hw->info.shift; + size_t to_mix, decr; =20 if (s->exit || !sdl->live) { return; } =20 - /* dolog ("in callback samples=3D%d live=3D%d\n", samples, sdl->live);= */ + /* dolog ("in callback samples=3D%zu live=3D%zu\n", samples, sdl->live= ); */ =20 to_mix =3D MIN(samples, sdl->live); decr =3D to_mix; while (to_mix) { - int chunk =3D MIN(to_mix, hw->samples - hw->rpos); + size_t chunk =3D MIN(to_mix, hw->samples - hw->rpos); struct st_sample *src =3D hw->mix_buf + hw->rpos; =20 - /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */ + /* dolog ("in callback to_mix %zu, chunk %zu\n", to_mix, chunk); */ hw->clip(buf, src, chunk); hw->rpos =3D (hw->rpos + chunk) % hw->samples; to_mix -=3D chunk; @@ -209,7 +209,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int= len) sdl->live -=3D decr; sdl->decr +=3D decr; =20 - /* dolog ("done len=3D%d\n", len); */ + /* dolog ("done len=3D%zu\n", len); */ =20 /* SDL2 does not clear the remaining buffer for us, so do it on our ow= n */ if (samples) { @@ -217,9 +217,9 @@ static void sdl_callback (void *opaque, Uint8 *buf, int= len) } } =20 -static int sdl_run_out (HWVoiceOut *hw, int live) +static size_t sdl_run_out(HWVoiceOut *hw, size_t live) { - int decr; + size_t decr; SDLVoiceOut *sdl =3D (SDLVoiceOut *) hw; =20 SDL_LockAudio(); diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6e7f13cffa..d9db1a39e6 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -153,11 +153,11 @@ static void line_out_fini (HWVoiceOut *hw) spice_server_remove_interface (&out->sin.base); } =20 -static int line_out_run (HWVoiceOut *hw, int live) +static size_t line_out_run (HWVoiceOut *hw, size_t live) { SpiceVoiceOut *out =3D container_of (hw, SpiceVoiceOut, hw); - int rpos, decr; - int samples; + size_t rpos, decr; + size_t samples; =20 if (!live) { return 0; @@ -276,12 +276,12 @@ static void line_in_fini (HWVoiceIn *hw) spice_server_remove_interface (&in->sin.base); } =20 -static int line_in_run (HWVoiceIn *hw) +static size_t line_in_run(HWVoiceIn *hw) { SpiceVoiceIn *in =3D container_of (hw, SpiceVoiceIn, hw); - int num_samples; + size_t num_samples; int ready; - int len[2]; + size_t len[2]; uint64_t delta_samp; const uint32_t *samples; =20 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 17ab921cef..b6eeeb4e26 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -40,10 +40,10 @@ typedef struct WAVVoiceOut { int total_samples; } WAVVoiceOut; =20 -static int wav_run_out (HWVoiceOut *hw, int live) +static size_t wav_run_out(HWVoiceOut *hw, size_t live) { WAVVoiceOut *wav =3D (WAVVoiceOut *) hw; - int rpos, decr, samples; + size_t rpos, decr, samples; uint8_t *dst; struct st_sample *src; int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); @@ -139,8 +139,8 @@ static int wav_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, hw->samples =3D 1024; wav->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shi= ft); if (!wav->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog("Could not allocate buffer (%zu bytes)\n", + hw->samples << hw->info.shift); return -1; } =20 diff --git a/replay/replay-audio.c b/replay/replay-audio.c index b113836de4..efe1628727 100644 --- a/replay/replay-audio.c +++ b/replay/replay-audio.c @@ -16,18 +16,18 @@ #include "sysemu/sysemu.h" #include "audio/audio.h" =20 -void replay_audio_out(int *played) +void replay_audio_out(size_t *played) { if (replay_mode =3D=3D REPLAY_MODE_RECORD) { g_assert(replay_mutex_locked()); replay_save_instructions(); replay_put_event(EVENT_AUDIO_OUT); - replay_put_dword(*played); + replay_put_qword(*played); } else if (replay_mode =3D=3D REPLAY_MODE_PLAY) { g_assert(replay_mutex_locked()); replay_account_executed_instructions(); if (replay_next_event_is(EVENT_AUDIO_OUT)) { - *played =3D replay_get_dword(); + *played =3D replay_get_qword(); replay_finish_event(); } else { error_report("Missing audio out event in the replay log"); @@ -36,7 +36,7 @@ void replay_audio_out(int *played) } } =20 -void replay_audio_in(int *recorded, void *samples, int *wpos, int size) +void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t= size) { int pos; uint64_t left, right; @@ -44,8 +44,8 @@ void replay_audio_in(int *recorded, void *samples, int *w= pos, int size) g_assert(replay_mutex_locked()); replay_save_instructions(); replay_put_event(EVENT_AUDIO_IN); - replay_put_dword(*recorded); - replay_put_dword(*wpos); + replay_put_qword(*recorded); + replay_put_qword(*wpos); for (pos =3D (*wpos - *recorded + size) % size ; pos !=3D *wpos ; pos =3D (pos + 1) % size) { audio_sample_to_uint64(samples, pos, &left, &right); @@ -56,8 +56,8 @@ void replay_audio_in(int *recorded, void *samples, int *w= pos, int size) g_assert(replay_mutex_locked()); replay_account_executed_instructions(); if (replay_next_event_is(EVENT_AUDIO_IN)) { - *recorded =3D replay_get_dword(); - *wpos =3D replay_get_dword(); + *recorded =3D replay_get_qword(); + *wpos =3D replay_get_qword(); for (pos =3D (*wpos - *recorded + size) % size ; pos !=3D *wpos ; pos =3D (pos + 1) % size) { left =3D replay_get_qword(); diff --git a/replay/replay.c b/replay/replay.c index 8b172b2d1b..a1135a9943 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -22,7 +22,7 @@ =20 /* Current version of the replay mechanism. Increase it when file format changes. */ -#define REPLAY_VERSION 0xe02007 +#define REPLAY_VERSION 0xe02008 /* Size of replay log header */ #define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t)) =20 --=20 2.22.0 From nobody Tue Apr 30 01:16:34 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=1564938412; cv=none; d=zoho.com; s=zohoarc; b=Fy4O3oIg8CkcAS0YVWl26Im2kL3J6QXKyWGWdJHBInBQQwc0rdxEtVHgUROQF6hAiokYoG5JuMlBJcWr3NQuDkRlMzGHzU1vH8WVvj/cjvMJc6UsnrPWvgR3jfjQto8LsojO0M1dZxb47qkz3kP7uzoKsmk4c9VsHu/HRbuK1K0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564938412; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N/mwlriTgvMl6h8mnLx3KY4L68sc0uS+YQp6dXqnv9w=; b=BP+a8qgXcoYXRUUjUdGyjEwnGu1KP/1s2HFy4SLpPZb0aPV9e/6xLzHd+AKSlr86OLTdMy7q1iqpO8SW8YlYEBHiDGjedfvvY5vNRxglQk9TtYQwp440rS5FRJFCSiw1PU/gKb9KxFmqmxdtbVaIKQJEjXanE2EoBrKBAwyUgP0= 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 1564938412402883.7012206799978; Sun, 4 Aug 2019 10:06:52 -0700 (PDT) Received: from localhost ([::1]:48870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJy7-00078w-Em for importer@patchew.org; Sun, 04 Aug 2019 13:06:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56685) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huJw4-0002O7-P5 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huJw3-00049G-7G for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:44 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1huJw2-000478-VL for qemu-devel@nongnu.org; Sun, 04 Aug 2019 13:04:43 -0400 Received: by mail-wr1-x444.google.com with SMTP id 31so82085279wrm.1 for ; Sun, 04 Aug 2019 10:04:41 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-632c-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:632c::5]) by smtp.gmail.com with ESMTPSA id s10sm104876106wmf.8.2019.08.04.10.04.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2019 10:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N/mwlriTgvMl6h8mnLx3KY4L68sc0uS+YQp6dXqnv9w=; b=MF4r1FDwikQNNKRSMiiVeJgr3g2uk0LxGNy5owgz+yRbPtFVg+lwmHepKJ4EKKSZJr /gure/jV0U5r9zuUiyOiE/LbozXesoWkRGAPoG9cQeiLB6P6xxU0GKwWMk+VLhxL4Lov M/zDT4ApfbEk2ken8GThaNgcCh3FwZe6TQjcI+a+6vnCPxWCyu1hh91hpIijRrXmkRWG riRd/JwSxj1ixVLMQyiYtGx/NTzT13FzDuGIQ8dXJUSOaE81zx9yQXokYRRlc31FLMpO p7UCfhF+7tpkuVIMmW9cu2FDczOk7yKqTl774tA22NYd/N2AQwxcvrIpPyqPDEtQJbNy Uvjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N/mwlriTgvMl6h8mnLx3KY4L68sc0uS+YQp6dXqnv9w=; b=onGyN5HzuXKOSWn5Wp0x2QdmMYSJOjwklqtHQIs6zjjHr0uuy/iZ9UYpzAWel4rW7Y AimCKFDgpQbYj4AWquBNuARDqlr11iV0nGPnfxj+GAmJRFu9ak64Yo5MkmITajT8JVX2 3Hgso10qT7MhUKcvOXd/gWYoF894cBdYuTVLKjEuJa+XAgYZTVmgWvyrvi8a87PXbbUi VhLbUpADJfvcvQe7HnE+hcyX1QdIY0oLSUyJoFWWM4MiP0+f4Z0s3CjY2/1/qb5eDxo5 5l3jaMovcDPaapLH2l4vO2KdSytr++eAl0TXRYwwJVONtRcm6fAL4g2z1/EgPL02L/R0 srjw== X-Gm-Message-State: APjAAAUEs78yE/91M9oX+3c3tvlGJ9vrnf2HsnxT1ddKWwb+TvyzwoLS fD0hYLFywmrO70lbYkH0F2tUB1qw6Qc= X-Google-Smtp-Source: APXvYqyYJsNb2fUTvMX1aey9HiS2nq+j7H5a1ZDY46xljzHqE5l+jm4qwsIoC2J8Xc3I1lA+yV88oA== X-Received: by 2002:adf:e790:: with SMTP id n16mr138639602wrm.120.1564938280652; Sun, 04 Aug 2019 10:04:40 -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: Sun, 4 Aug 2019 19:04:26 +0200 Message-Id: <752d0beb8a35abc89cbe0618a21e496c072a317e.1564925487.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 v3 14/14] audio: fix memory leak reported by ASAN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index d3c639211d..ebe49f3ca1 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1343,6 +1343,12 @@ static void free_audio_state(AudioState *s) qapi_free_Audiodev(s->dev); s->dev =3D NULL; } + + if (s->ts) { + timer_free(s->ts); + s->ts =3D NULL; + } + g_free(s); } =20 --=20 2.22.0