From nobody Fri May 17 16:56:24 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=1562698687; cv=none; d=zoho.com; s=zohoarc; b=gvQ7WCvUQEb2SflXXPNgqmjlwLaKzgEEysfCf4yjW3Vwlk7dSPa/wKQzOAMsGyllurJ16pU/M5C0Gi8d06Wp3w51PJXbZ4OXCywY+4WO/MImquPFmk1rfvzjcJayzsdlvUBB61FQc+2ojVUAEme6xUecta1+xlToBKjyApayFtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698687; 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=3V5YRnSw4hFn6jMam6ZLFiYCS4Rbm72fNAuCHU5bams=; b=NP7cI9MlANkpaOM8CHwandXsWf5jv/zlOxG6XO5cFXocjOPt8mxxxFBKAUZgJiHrH/grzRqb/N6wd8RWW4j0jx730rF+p59bAKoc/w8ofbqB7XrPcVBS3Qy/aIlkzw7QWnBoV93lXaSAkWhJZxAs55pjZ2pDQcIFujLUjTAAPC0= 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 1562698687758538.5270356544227; Tue, 9 Jul 2019 11:58:07 -0700 (PDT) Received: from localhost ([::1]:52872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvJW-0001v4-P2 for importer@patchew.org; Tue, 09 Jul 2019 14:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36923) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyN-0004Gm-PO for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyK-0003ef-9F for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:15 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38636) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyJ-0003UE-Pp for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:12 -0400 Received: by mail-wr1-x443.google.com with SMTP id g17so11961891wrr.5 for ; Tue, 09 Jul 2019 11:35:55 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:53 -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=3V5YRnSw4hFn6jMam6ZLFiYCS4Rbm72fNAuCHU5bams=; b=uucu7+pkl2UcSu+GX8Vx612lKr6rlXAjGAz/DT0QLg2/jiVv2XD15fivqL5caVKKKR JPhgd+86N9b7gDq2jBHG04b3gAJQFn5U6ODTi7VmfjreAKjBrRRj9PDip3cX488tXcAJ S85ZbP2OOPFE455NGUNn9C8iJ3DGwBSgGNX89WMwfIaAqcZ43Fz4oL1K9PnmsZYtdbJB +yVI3Y0VCtCZ/tGyxWzGcKZFXgaUeA/tBWmFIEEbrEawbCO5pc2Zsy2uyx89HEvPmx+E qTFAOuvzG2EyBiX3ve9aFb/bTQ4OICKbLi1KH5CPvEojaH4i/W/SKQSjetK28ksXts+r glhw== 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=3V5YRnSw4hFn6jMam6ZLFiYCS4Rbm72fNAuCHU5bams=; b=IkgsBtZwmT+eeMXx9D3L/12omnSbeUrnAnkqh5juqnH3ixDO3jGqYKoGYfWl9khEst dTJ/rgpYbdtKZjfxs5YaQVznbMfQzc+vTZwTh26FjT82Qwr3fBsNy6KoVJFp7+SM6Y6r aZUgIANRtuEI13xjJCXvzUYmOTYd6bcPDjSgtkBILgAEspYfWin/IE/IBSqKJP7kpTaj 3E6SgMjgx5hX3U3xQKEjQc+QwVYpAFhTvx426NiLXZbzyDt7aP+rTn8nGGYaYjz8lKg+ MVBnL0AlwcnYaGsFDTxSnkJXnNxnZx8xEpebt6A9+VZDxVpJ2ryq0xIA9iLUa/q72HZ0 cSEg== X-Gm-Message-State: APjAAAVTP+C/GK12yDgDapudZyiJI0A5DRtDA4Tnw58hHLNzJZC5UF0R ta+512eAYkqcCLuUsVvbyVqs7jDp X-Google-Smtp-Source: APXvYqw/k9YXkpzLyxUkxvy0RLvvyW8qcVwdz9xihSNlQb1/pkrreW4yojBs24OcrqkAdan/vR3ZPA== X-Received: by 2002:adf:91c2:: with SMTP id 60mr5427161wri.334.1562697353655; Tue, 09 Jul 2019 11:35:53 -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: Tue, 9 Jul 2019 20:35:41 +0200 Message-Id: <3844fbf5012201fa9509d07cff315b4f0b42ddca.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH 01/11] 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: 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 Fri May 17 16:56:24 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=1562699214; cv=none; d=zoho.com; s=zohoarc; b=GVx0JkTwp2dMlu2Yg04INDKVeK9la49CfxyccJK0HFs982FZ8kWoEnIZks2EH82Ac1pMIcYVacWPvdlTmNRxy3aTQAq66mbxLcH/PSyWZcEvg1cbdvNPQmUGbes6h0KCwzeR+ml2AfKJ2nNH4LlQCaipYbF0Huq+4qN/Gt4RItM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562699214; 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=yEw1lXf6KF00BmxTMCjGr7FoL6nKQ6cuLcyNA5vjh7c=; b=Y4yoIymKvHCAtgvY3BWjEoa4mE4IzDkSzSrDXvorPLqIIqATkNnyerveCRj8qJHCXXGDTTjz3wEb6OXRlXNnpXABzmVVl8jXgiT/setJ21/hmoUnRJNL3+gPN9my2hSvXArPcBVDGecR0Yl+AIZw+0N/P+hce7tUm8EnV+aM+08= 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 1562699214795101.88814393563223; Tue, 9 Jul 2019 12:06:54 -0700 (PDT) Received: from localhost ([::1]:52932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvRq-0008IW-EZ for importer@patchew.org; Tue, 09 Jul 2019 15:06:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36989) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyP-0004L1-FH for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyK-0003f0-C4 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:17 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyJ-0003Ua-P0 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:12 -0400 Received: by mail-wm1-x342.google.com with SMTP id z23so4280649wma.4 for ; Tue, 09 Jul 2019 11:35:55 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:54 -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=yEw1lXf6KF00BmxTMCjGr7FoL6nKQ6cuLcyNA5vjh7c=; b=FBZ/ZEaVWC4KDK19YoWNTR2+WaRjkBSYzyAHhEOjqzdmwz3Rc1HqFWOyEK4bbm/ceL 92epDlCIeCaHC9lPKEGt2mC/6uXJUUgJXoWxrl2ywM1GZ8PCjcuLq85j/JrCBIfF9WU2 3kJdCo26FxxEyfBELs/WlMxuCHvp86a12fLDsWdA6wZroxDNpvMopwUS539q2422nflf WWwaUdlb0DGKAKm2OjgerV2kjgh6vQ2XFdcTpk2RzWqOry60uN/xMUVMLKsu+AlmJRoE RTzwNyn71TNonHK8y1XBg/PenhaoK+4lbE3o0biXCfYdZxX/N8h/oRbr+3zfe498hgfK eaMg== 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=yEw1lXf6KF00BmxTMCjGr7FoL6nKQ6cuLcyNA5vjh7c=; b=WzYNk/0nJ1SBvRgiG8zKFPdgGtU1jgbv26DdXex1P3M+AKuu/ocaFqF+f/elIwFsaS B8aIQBphil5yvdQI3ow7zsUxdfrkg+ocielBkVQyKkVePVbC6S8d1lueDGzo+ieahvSD 6RhdZGftpW2QsKQnQ8Vvq7ZaDv3JsH97m0GYe0S0x5MeZnYI1DWkboXeSlz+ydOdKHRt uoBsFnN/Tk9u6nI1rT4gLXp3TH/5Qe27leoWJZoimONwErdOSs6ycOZnZjrvK3hhtSTM lUJGOc91tFMWhP7t69ZSrC5zAXJM/JtUmQqN9Uq+XgLyuTFD8VPb5/XHhmgAhirHsVmh 0Xyg== X-Gm-Message-State: APjAAAVtIy3tv6cKUMiUO77u3Ry6q/hMVvI5oifuko6Lu5P5yeyf5SBS 2HtYk3qGlc9H/WfxiOUhvQHxphu4 X-Google-Smtp-Source: APXvYqxGz45ivc57xoLsqEsVZA29eGZ2hwwtfuvpjkM9paSb2N8Yc5cCsqOcLoe1P54zHWejjtj1nw== X-Received: by 2002:a1c:b155:: with SMTP id a82mr984680wmf.35.1562697354443; Tue, 09 Jul 2019 11:35:54 -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: Tue, 9 Jul 2019 20:35:42 +0200 Message-Id: <597ee579c3d14ff6f0892ee9e1905cdb0e0990ad.1562695780.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 02/11] 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: 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) 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 Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.h | 12 +++-- audio/audio_int.h | 2 + audio/audio_template.h | 2 +- ui/vnc.h | 2 + audio/audio.c | 102 +++++++++++++++++++++++++++++++---------- audio/wavcapture.c | 6 +-- monitor/misc.c | 12 ++++- ui/vnc.c | 15 +++++- hmp-commands.hx | 11 +++-- qemu-options.hx | 5 ++ 10 files changed, 131 insertions(+), 38 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/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/audio/audio.c b/audio/audio.c index 8d2f580788..e9dd7c8b32 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..f97810d370 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1148,7 +1148,17 @@ static void hmp_wavcapture(Monitor *mon, const QDict= *qdict) int bits =3D qdict_get_try_int(qdict, "bits", -1); int has_channels =3D qdict_haskey(qdict, "nchannels"); int nchannels =3D qdict_get_try_int(qdict, "nchannels", -1); + const char *audiodev =3D qdict_get_try_str(qdict, "audiodev"); CaptureState *s; + AudioState *as =3D NULL; + + if (audiodev) { + as =3D audio_state_by_name(audiodev); + if (!as) { + monitor_printf(mon, "Invalid audiodev specified\n"); + return; + } + } =20 s =3D g_malloc0 (sizeof (*s)); =20 @@ -1156,7 +1166,7 @@ static void hmp_wavcapture(Monitor *mon, const QDict = *qdict) bits =3D has_bits ? bits : 16; nchannels =3D has_channels ? nchannels : 2; =20 - if (wav_start_capture (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 38f92bfca3..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(&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..23196da3fe 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,freq:i?,bits:i?,nchannels:i?,audiodev:s?", + .params =3D "path [frequency [bits [channels [audiodev]]]]", .help =3D "capture audio to a wave file (default frequency= =3D44100 bits=3D16 channels=3D2)", .cmd =3D hmp_wavcapture, }, STEXI -@item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channel= s}]]] +@item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channel= s} [@var{audiodev}]]]] @findex wavcapture -Capture audio into @var{filename}. Using sample rate @var{frequency} -bits per sample @var{bits} and number of channels @var{channels}. +Capture audio into @var{filename} from @var{audiodev}. Using sample rate +@var{frequency} bits per sample @var{bits} and number of channels +@var{channels}. =20 Defaults: @itemize @minus diff --git a/qemu-options.hx b/qemu-options.hx index 9621e934c0..0111055aa4 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1978,6 +1978,11 @@ 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. + @end table ETEXI =20 --=20 2.22.0 From nobody Fri May 17 16:56:24 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=1562698851; cv=none; d=zoho.com; s=zohoarc; b=WZiN3Ht++v4QSsFL6JWR4IRn9Fm83FWtWuwCfcFgb1TgU8D6nPNSFm9imShl203WFjY1UoYdbr1ixqqxUhhFruVmbsknclE8Kpm4J6CJfLffbKnuFwwpsSeq0bRnQafzrLP562w13vQIePvCLmI//2hFpw3PtY4zikyC3PkRci0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698851; 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=TZIl0foCHkb2oerndplBi0WwQQXiiCPRHz7GhA+SGls=; b=GM7dULLE26nOBBj+jD2I8Doghl/jcsVq95TCRwDI7MQtdxAu0wFf9fbX2IRsMkH7X8VH85bST7kjlsbidf/gYN91MYLRDzXZ6MDx3zpfACtHpFzWSb0Zx+yrLn8uNH1OgOtGFJ3H4ALJBCFNGfhLEpKwkWRmmSToWAlWQwftxDA= 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 1562698851504319.32209753030054; Tue, 9 Jul 2019 12:00:51 -0700 (PDT) Received: from localhost ([::1]:52890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvM5-0003QH-Aw for importer@patchew.org; Tue, 09 Jul 2019 15:00:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36925) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyN-0004Gs-Px for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyK-0003ez-C4 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:15 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyJ-0003Us-PR for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:12 -0400 Received: by mail-wr1-x442.google.com with SMTP id n4so22144064wrs.3 for ; Tue, 09 Jul 2019 11:35:56 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:54 -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=TZIl0foCHkb2oerndplBi0WwQQXiiCPRHz7GhA+SGls=; b=eTtcKSX/yCUhYJwp5fS/QtFyKAUIc6RlJ9hYmBXUtffT34dECEywk/H8/ynlWYWjJl S1JnQtOBiapbZFxxZMZKBO6P8ap95XPmJPhZazrX4fp6XNn1Yfj80NfAFPm92jdm5jVa +ex6cED9UaaxNIvO6Fpol6EICLUkEPW5XwHIOVpo5j1EqPNlluhSHP4fXN+LjU9ztrTv Sfii/CcnDniv8OhAWMinUWwCrHXmxt/zdK35Gv0iUaOzcGCFwtJ/hvbJk6R82/lZna8x pY8pMNWs6oC+XcPt/JQtARaEFMgJQVc5YSs16YEH9YEnTT/HBjnIBYycCVloJUiI3Wxo dVhg== 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=TZIl0foCHkb2oerndplBi0WwQQXiiCPRHz7GhA+SGls=; b=n7FTZNVIXVGFZdM/CYFlblpbt/4B/Vu8HrGmRFMrofbbZGCc3qWnDF5QFKRPifMRs6 azv5XVk0azmFwVXOv158OymxU/uDfngiXIT8GdbA1vgLeX0weM3y8LkxWZ0NaIJwzlGO UK2WTiZRmSKgTM+liZT/C63kXOWYLm4FJYtqFkO2p/bWhx1DzdCgZU7Ti9wphHWHjcdr lmTNBWdCbeSyQ5E42V9drRoXfH9jdnhzuTqpxIN/QFB+M5o4xdvv2fONG2YpB4/GrLjp sWr3ua4/9fc0VglKvP3j+kVCyondHd8CkxfHuU85lrNA/sGCiyL7lCvuh+sdOJmZb+vJ R+mg== X-Gm-Message-State: APjAAAUx2t+WaXUohjIU4iCSr68Oi4mFogvFMvdYZ4p0ZH4wy5vvbhzn wVnqefjUZYnjrxC6MV3FwjRlUC93Cyk= X-Google-Smtp-Source: APXvYqzcg25dmLuecek3yf+/whT0Qf+AZCyh1C+dy2U6T721Bq7l6wFPsZ7neBVVvsWTT7iZ87QNKw== X-Received: by 2002:a5d:4b0a:: with SMTP id v10mr26503508wrq.308.1562697355313; Tue, 09 Jul 2019 11:35:55 -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: Tue, 9 Jul 2019 20:35:43 +0200 Message-Id: <4f1ee2a0876bca759311c0efb31fbe7a6850fbad.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH 03/11] 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: Paolo Bonzini , Michael Walle , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Eduardo Habkost 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 Fri May 17 16:56:24 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=1562698970; cv=none; d=zoho.com; s=zohoarc; b=WHJpRloWJ09AwiPAzbHMxskPGVQGKH2xpkKMmAhFfVHbYwFvDbYT82Oql0rdwCfkI4g0iv7FNF4mCFJMM4ihXBh8FbaYSCAz66pG+KPhCG2p/NFo7M2hHLgfK7j1SNOkLL2416g3txYYSGARmTWoZ3PIUs6WkYc+sJRwstlI4Ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698970; 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=zsBcPNs+1x+yv7NMQ8AGJb0tgkK4rOlJqlsW/76+UOs=; b=kCg3tDzKbpldAQk9SfPKeRA855UsgkRlP5lhKmu46aP6UGfP0VYuIAX+mNXW3OOGSrOOwZcF6vs7Ooc1HxT6JgCrl56zKB3IVYQyj53I8VyK65GnGfLl3arafwgdmK7chRNM6xyVWncYy2SkaH0UXU/m8ot4Sn2r/6ObAyXzSpE= 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 1562698970353724.6500610222315; Tue, 9 Jul 2019 12:02:50 -0700 (PDT) Received: from localhost ([::1]:52910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvO0-0005U7-1f for importer@patchew.org; Tue, 09 Jul 2019 15:02:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37029) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyQ-0004Mh-7B for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyK-0003fE-BZ for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:18 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:43833) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyJ-0003VG-Pd for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:12 -0400 Received: by mail-wr1-x443.google.com with SMTP id p13so2941991wru.10 for ; Tue, 09 Jul 2019 11:35:57 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:55 -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=zsBcPNs+1x+yv7NMQ8AGJb0tgkK4rOlJqlsW/76+UOs=; b=vbnf/Ah7pA9ab/hIGfwM6+b6l1y3ntSY/5jUD5CW0QSRLMwEc41F5m3W0A2caZwgJk iNWcHY/xVa5ldHo1iq4hNHK6MwtcHKEloBl8w0orzoAyTTMhCf5w0zEESTJAwiC1/tkF 41bUYLgz/HsGQ8ahRLTZ0jBhQgkvEZvNuzXcGIKJpEb3yCfmfVF9THVilrq73UA3iq+T 5bL8JnaCwNYDPz73/i79d7J07eMvdVFPR39NUP1YUBr5zHeNTWF/XjOqqer3H61o3taX /8XeaG8P4yh7cVsgyRrPgEFa4uorvL2w5Vw81I3JoPvXuiL84T+c0f0sSPUquync4aO7 IZpg== 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=zsBcPNs+1x+yv7NMQ8AGJb0tgkK4rOlJqlsW/76+UOs=; b=hCXZdIDGepKBOe21dM3GlJO1xnZ5XJVFqaW5JJ11QsypAPR/plZi8EalW7QMXIzAk6 1E08fDhS4Cg5IsoOVxgUFRTEw15gzWJN/VTFrcJvoQW16/3ou3zMkYJ8YLQaztvF3JEY zeKZvWi7wjhu+2qZLarl4bf5lcqpnsW1BiBhJAIfy2emmAidvkR1DkIALW9+QgDZoK9R ZKIbCsVBOWKq1tW6sQglkNKPZTL2vsUfLXfwn0ugfxFRrVB4SFmFvgBkeWpxD1tLRIP+ 66nauGFD35bj8XEg3Bw5RfEG/MEVnu32xpk0dlctf+Tioan6w2cP5Iq/fshVaATgBQPj Uu5g== X-Gm-Message-State: APjAAAXiICoBa3dfJ0EinDoz2lJj6hpnbc5y6vm/IygVBMrlf0yGNkls PQaKiGqSYYMOYGk+/53Z12RjTY2a X-Google-Smtp-Source: APXvYqza/WH6m3ieWnnwO8UhQR0g2QgORmZp8kzYP1l2/ObjTZLYDXkF83uhhu49gMo2K+yc2eDWeQ== X-Received: by 2002:adf:ce05:: with SMTP id p5mr280446wrn.197.1562697356165; Tue, 09 Jul 2019 11:35:56 -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: Tue, 9 Jul 2019 20:35:44 +0200 Message-Id: <25d0165508ec9a4dbac572adcee97dd4c342b55b.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH 04/11] 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 --- audio/audio.c | 24 ++-- audio/paaudio.c | 329 +++++++++++++++++++++++++++--------------------- 2 files changed, 203 insertions(+), 150 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index e9dd7c8b32..82dd0e3e13 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 diff --git a/audio/paaudio.c b/audio/paaudio.c index 5fc886bb33..cc3a34c2ea 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -11,10 +11,21 @@ #include "audio_int.h" #include "audio_pt_int.h" =20 -typedef struct { - Audiodev *dev; +typedef struct PAConnection { + char *server; + int refcount; + QTAILQ_ENTRY(PAConnection) list; + pa_threaded_mainloop *mainloop; pa_context *context; +} PAConnection; + +static QTAILQ_HEAD(PAConnectionHead, PAConnection) pa_conns =3D + QTAILQ_HEAD_INITIALIZER(pa_conns); + +typedef struct { + Audiodev *dev; + PAConnection *conn; } paaudio; =20 typedef struct { @@ -45,7 +56,7 @@ typedef struct { int samples; } PAVoiceIn; =20 -static void qpa_audio_fini(void *opaque); +static void qpa_conn_fini(PAConnection *c); =20 static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...) { @@ -108,11 +119,11 @@ static inline int PA_STREAM_IS_GOOD(pa_stream_state_t= x) =20 static int qpa_simple_read (PAVoiceIn *p, void *data, size_t length, int *= rerror) { - paaudio *g =3D p->g; + PAConnection *c =3D p->g->conn; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); =20 while (length > 0) { size_t l; @@ -121,11 +132,11 @@ static int qpa_simple_read (PAVoiceIn *p, void *data,= size_t length, int *rerror int r; =20 r =3D pa_stream_peek (p->stream, &p->read_data, &p->read_lengt= h); - CHECK_SUCCESS_GOTO (g, rerror, r =3D=3D 0, unlock_and_fail); + CHECK_SUCCESS_GOTO(c, rerror, r =3D=3D 0, unlock_and_fail); =20 if (!p->read_data) { - pa_threaded_mainloop_wait (g->mainloop); - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + pa_threaded_mainloop_wait(c->mainloop); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); } else { p->read_index =3D 0; } @@ -148,53 +159,53 @@ static int qpa_simple_read (PAVoiceIn *p, void *data,= size_t length, int *rerror p->read_length =3D 0; p->read_index =3D 0; =20 - CHECK_SUCCESS_GOTO (g, rerror, r =3D=3D 0, unlock_and_fail); + CHECK_SUCCESS_GOTO(c, rerror, r =3D=3D 0, unlock_and_fail); } } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return 0; =20 unlock_and_fail: - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return -1; } =20 static int qpa_simple_write (PAVoiceOut *p, const void *data, size_t lengt= h, int *rerror) { - paaudio *g =3D p->g; + PAConnection *c =3D p->g->conn; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); =20 while (length > 0) { size_t l; int r; =20 while (!(l =3D pa_stream_writable_size (p->stream))) { - pa_threaded_mainloop_wait (g->mainloop); - CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail); + pa_threaded_mainloop_wait(c->mainloop); + CHECK_DEAD_GOTO(c, p->stream, rerror, unlock_and_fail); } =20 - CHECK_SUCCESS_GOTO (g, rerror, l !=3D (size_t) -1, unlock_and_fail= ); + CHECK_SUCCESS_GOTO(c, rerror, l !=3D (size_t) -1, unlock_and_fail); =20 if (l > length) { l =3D length; } =20 r =3D pa_stream_write (p->stream, data, l, NULL, 0LL, PA_SEEK_RELA= TIVE); - CHECK_SUCCESS_GOTO (g, rerror, r >=3D 0, unlock_and_fail); + CHECK_SUCCESS_GOTO(c, rerror, r >=3D 0, unlock_and_fail); =20 data =3D (const uint8_t *) data + l; length -=3D l; } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return 0; =20 unlock_and_fail: - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); return -1; } =20 @@ -432,13 +443,13 @@ static AudioFormat pa_to_audfmt (pa_sample_format_t f= mt, int *endianness) =20 static void context_state_cb (pa_context *c, void *userdata) { - paaudio *g =3D userdata; + PAConnection *conn =3D userdata; =20 switch (pa_context_get_state(c)) { case PA_CONTEXT_READY: case PA_CONTEXT_TERMINATED: case PA_CONTEXT_FAILED: - pa_threaded_mainloop_signal (g->mainloop, 0); + pa_threaded_mainloop_signal(conn->mainloop, 0); break; =20 case PA_CONTEXT_UNCONNECTED: @@ -451,14 +462,14 @@ static void context_state_cb (pa_context *c, void *us= erdata) =20 static void stream_state_cb (pa_stream *s, void * userdata) { - paaudio *g =3D userdata; + PAConnection *c =3D userdata; =20 switch (pa_stream_get_state (s)) { =20 case PA_STREAM_READY: case PA_STREAM_FAILED: case PA_STREAM_TERMINATED: - pa_threaded_mainloop_signal (g->mainloop, 0); + pa_threaded_mainloop_signal(c->mainloop, 0); break; =20 case PA_STREAM_UNCONNECTED: @@ -469,13 +480,13 @@ static void stream_state_cb (pa_stream *s, void * use= rdata) =20 static void stream_request_cb (pa_stream *s, size_t length, void *userdata) { - paaudio *g =3D userdata; + PAConnection *c =3D userdata; =20 - pa_threaded_mainloop_signal (g->mainloop, 0); + pa_threaded_mainloop_signal(c->mainloop, 0); } =20 static pa_stream *qpa_simple_new ( - paaudio *g, + PAConnection *c, const char *name, pa_stream_direction_t dir, const char *dev, @@ -486,50 +497,48 @@ static pa_stream *qpa_simple_new ( { int r; pa_stream *stream; + pa_stream_flags_t flags; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - stream =3D pa_stream_new (g->context, name, ss, map); + stream =3D pa_stream_new(c->context, name, ss, map); if (!stream) { goto fail; } =20 - pa_stream_set_state_callback (stream, stream_state_cb, g); - pa_stream_set_read_callback (stream, stream_request_cb, g); - pa_stream_set_write_callback (stream, stream_request_cb, g); + pa_stream_set_state_callback(stream, stream_state_cb, c); + pa_stream_set_read_callback(stream, stream_request_cb, c); + pa_stream_set_write_callback(stream, stream_request_cb, c); + + flags =3D + PA_STREAM_INTERPOLATE_TIMING +#ifdef PA_STREAM_ADJUST_LATENCY + | PA_STREAM_ADJUST_LATENCY +#endif + | PA_STREAM_AUTO_TIMING_UPDATE; =20 if (dir =3D=3D PA_STREAM_PLAYBACK) { - r =3D pa_stream_connect_playback (stream, dev, attr, - PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY - |PA_STREAM_ADJUST_LATENCY -#endif - |PA_STREAM_AUTO_TIMING_UPDATE, NUL= L, NULL); + r =3D pa_stream_connect_playback(stream, dev, attr, flags, NULL, N= ULL); } else { - r =3D pa_stream_connect_record (stream, dev, attr, - PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY - |PA_STREAM_ADJUST_LATENCY -#endif - |PA_STREAM_AUTO_TIMING_UPDATE); + r =3D pa_stream_connect_record(stream, dev, attr, flags); } =20 if (r < 0) { goto fail; } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); =20 return stream; =20 fail: - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); =20 if (stream) { pa_stream_unref (stream); } =20 - *rerror =3D pa_context_errno (g->context); + *rerror =3D pa_context_errno(c->context); =20 return NULL; } @@ -545,6 +554,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, paaudio *g =3D pa->g =3D drv_opaque; AudiodevPaOptions *popts =3D &g->dev->u.pa; AudiodevPaPerDirectionOptions *ppdo =3D popts->out; + PAConnection *c =3D g->conn; =20 ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; @@ -558,7 +568,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.endianness); =20 pa->stream =3D qpa_simple_new ( - g, + c, "qemu", PA_STREAM_PLAYBACK, ppdo->has_name ? ppdo->name : NULL, @@ -612,6 +622,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) paaudio *g =3D pa->g =3D drv_opaque; AudiodevPaOptions *popts =3D &g->dev->u.pa; AudiodevPaPerDirectionOptions *ppdo =3D popts->in; + PAConnection *c =3D g->conn; =20 ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; @@ -625,7 +636,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.endianness); =20 pa->stream =3D qpa_simple_new ( - g, + c, "qemu", PA_STREAM_RECORD, ppdo->has_name ? ppdo->name : NULL, @@ -714,7 +725,7 @@ static int qpa_ctl_out (HWVoiceOut *hw, int cmd, ...) PAVoiceOut *pa =3D (PAVoiceOut *) hw; pa_operation *op; pa_cvolume v; - paaudio *g =3D pa->g; + PAConnection *c =3D pa->g->conn; =20 #ifdef PA_CHECK_VERSION /* macro is present in 0.9.16+ */ pa_cvolume_init (&v); /* function is present in 0.9.13+ */ @@ -734,28 +745,29 @@ static int qpa_ctl_out (HWVoiceOut *hw, int cmd, ...) v.values[0] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= l) / UINT32_MAX; v.values[1] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= r) / UINT32_MAX; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - op =3D pa_context_set_sink_input_volume (g->context, + op =3D pa_context_set_sink_input_volume(c->context, pa_stream_get_index (pa->stream), &v, NULL, NULL); - if (!op) - qpa_logerr (pa_context_errno (g->context), - "set_sink_input_volume() failed\n"); - else - pa_operation_unref (op); + if (!op) { + qpa_logerr(pa_context_errno(c->context), + "set_sink_input_volume() failed\n"); + } else { + pa_operation_unref(op); + } =20 - op =3D pa_context_set_sink_input_mute (g->context, + op =3D pa_context_set_sink_input_mute(c->context, pa_stream_get_index (pa->stream), sw->vol.mute, NULL, NULL); if (!op) { - qpa_logerr (pa_context_errno (g->context), - "set_sink_input_mute() failed\n"); + qpa_logerr(pa_context_errno(c->context), + "set_sink_input_mute() failed\n"); } else { - pa_operation_unref (op); + pa_operation_unref(op); } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); } } return 0; @@ -766,7 +778,7 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...) PAVoiceIn *pa =3D (PAVoiceIn *) hw; pa_operation *op; pa_cvolume v; - paaudio *g =3D pa->g; + PAConnection *c =3D pa->g->conn; =20 #ifdef PA_CHECK_VERSION pa_cvolume_init (&v); @@ -786,29 +798,29 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...) v.values[0] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= l) / UINT32_MAX; v.values[1] =3D ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.= r) / UINT32_MAX; =20 - pa_threaded_mainloop_lock (g->mainloop); + pa_threaded_mainloop_lock(c->mainloop); =20 - op =3D pa_context_set_source_output_volume (g->context, - pa_stream_get_index (pa->stream), + op =3D pa_context_set_source_output_volume(c->context, + pa_stream_get_index(pa->stream), &v, NULL, NULL); if (!op) { - qpa_logerr (pa_context_errno (g->context), - "set_source_output_volume() failed\n"); + qpa_logerr(pa_context_errno(c->context), + "set_source_output_volume() failed\n"); } else { pa_operation_unref(op); } =20 - op =3D pa_context_set_source_output_mute (g->context, + op =3D pa_context_set_source_output_mute(c->context, pa_stream_get_index (pa->stream), sw->vol.mute, NULL, NULL); if (!op) { - qpa_logerr (pa_context_errno (g->context), - "set_source_output_mute() failed\n"); + qpa_logerr(pa_context_errno(c->context), + "set_source_output_mute() failed\n"); } else { pa_operation_unref (op); } =20 - pa_threaded_mainloop_unlock (g->mainloop); + pa_threaded_mainloop_unlock(c->mainloop); } } return 0; @@ -828,11 +840,75 @@ static int qpa_validate_per_direction_opts(Audiodev *= dev, return 1; } =20 +/* common */ +static void *qpa_conn_init(const char *server) +{ + PAConnection *c =3D g_malloc0(sizeof(PAConnection)); + QTAILQ_INSERT_TAIL(&pa_conns, c, list); + + c->mainloop =3D pa_threaded_mainloop_new(); + if (!c->mainloop) { + goto fail; + } + + c->context =3D pa_context_new(pa_threaded_mainloop_get_api(c->mainloop= ), + server); + if (!c->context) { + goto fail; + } + + pa_context_set_state_callback(c->context, context_state_cb, c); + + if (pa_context_connect(c->context, server, 0, NULL) < 0) { + qpa_logerr(pa_context_errno(c->context), + "pa_context_connect() failed\n"); + goto fail; + } + + pa_threaded_mainloop_lock(c->mainloop); + + if (pa_threaded_mainloop_start(c->mainloop) < 0) { + goto unlock_and_fail; + } + + for (;;) { + pa_context_state_t state; + + state =3D pa_context_get_state(c->context); + + if (state =3D=3D PA_CONTEXT_READY) { + break; + } + + if (!PA_CONTEXT_IS_GOOD(state)) { + qpa_logerr(pa_context_errno(c->context), + "Wrong context state\n"); + goto unlock_and_fail; + } + + /* Wait until the context is ready */ + pa_threaded_mainloop_wait(c->mainloop); + } + + pa_threaded_mainloop_unlock(c->mainloop); + return c; + +unlock_and_fail: + pa_threaded_mainloop_unlock(c->mainloop); +fail: + AUD_log (AUDIO_CAP, "Failed to initialize PA context"); + qpa_conn_fini(c); + return NULL; +} + static void *qpa_audio_init(Audiodev *dev) { paaudio *g; AudiodevPaOptions *popts =3D &dev->u.pa; const char *server; + PAConnection *c; + + assert(dev->driver =3D=3D AUDIODEV_DRIVER_PA); =20 if (!popts->has_server) { char pidfile[64]; @@ -849,93 +925,64 @@ static void *qpa_audio_init(Audiodev *dev) } } =20 - assert(dev->driver =3D=3D AUDIODEV_DRIVER_PA); - - g =3D g_malloc(sizeof(paaudio)); - server =3D popts->has_server ? popts->server : NULL; - if (!qpa_validate_per_direction_opts(dev, popts->in)) { - goto fail; + return NULL; } if (!qpa_validate_per_direction_opts(dev, popts->out)) { - goto fail; + return NULL; } =20 + g =3D g_malloc0(sizeof(paaudio)); + server =3D popts->has_server ? popts->server : NULL; + g->dev =3D dev; - g->mainloop =3D NULL; - g->context =3D NULL; =20 - g->mainloop =3D pa_threaded_mainloop_new (); - if (!g->mainloop) { - goto fail; - } - - g->context =3D pa_context_new (pa_threaded_mainloop_get_api (g->mainlo= op), - server); - if (!g->context) { - goto fail; - } - - pa_context_set_state_callback (g->context, context_state_cb, g); - - if (pa_context_connect(g->context, server, 0, NULL) < 0) { - qpa_logerr (pa_context_errno (g->context), - "pa_context_connect() failed\n"); - goto fail; - } - - pa_threaded_mainloop_lock (g->mainloop); - - if (pa_threaded_mainloop_start (g->mainloop) < 0) { - goto unlock_and_fail; - } - - for (;;) { - pa_context_state_t state; - - state =3D pa_context_get_state (g->context); - - if (state =3D=3D PA_CONTEXT_READY) { + QTAILQ_FOREACH(c, &pa_conns, list) { + if (server =3D=3D NULL || c->server =3D=3D NULL ? + server =3D=3D c->server : + strcmp(server, c->server) =3D=3D 0) { + g->conn =3D c; break; } - - if (!PA_CONTEXT_IS_GOOD (state)) { - qpa_logerr (pa_context_errno (g->context), - "Wrong context state\n"); - goto unlock_and_fail; - } - - /* Wait until the context is ready */ - pa_threaded_mainloop_wait (g->mainloop); + } + if (!g->conn) { + g->conn =3D qpa_conn_init(server); + } + if (!g->conn) { + g_free(g); + return NULL; } =20 - pa_threaded_mainloop_unlock (g->mainloop); - + ++g->conn->refcount; return g; +} =20 -unlock_and_fail: - pa_threaded_mainloop_unlock (g->mainloop); -fail: - AUD_log (AUDIO_CAP, "Failed to initialize PA context"); - qpa_audio_fini(g); - return NULL; +static void qpa_conn_fini(PAConnection *c) +{ + if (c->mainloop) { + pa_threaded_mainloop_stop(c->mainloop); + } + + if (c->context) { + pa_context_disconnect(c->context); + pa_context_unref(c->context); + } + + if (c->mainloop) { + pa_threaded_mainloop_free(c->mainloop); + } + + QTAILQ_REMOVE(&pa_conns, c, list); + g_free(c); } =20 static void qpa_audio_fini (void *opaque) { paaudio *g =3D opaque; + PAConnection *c =3D g->conn; =20 - if (g->mainloop) { - pa_threaded_mainloop_stop (g->mainloop); - } - - if (g->context) { - pa_context_disconnect (g->context); - pa_context_unref (g->context); - } - - if (g->mainloop) { - pa_threaded_mainloop_free (g->mainloop); + if (--c->refcount =3D=3D 0) { + qpa_conn_fini(c); } =20 g_free(g); --=20 2.22.0 From nobody Fri May 17 16:56:24 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=1562698560; cv=none; d=zoho.com; s=zohoarc; b=ZhyrjCKiwQOhpFd7yBo0XEeGpxCSEqV3S8g8iT1S3mObU4FhJe+AJIe2nhekpo6OAtAZ8GuH1+A1VWkpCjmWs4iDHK8WPEnc+QefZg9G5q8MXkooYmEIybMI1FDd6ziDnLI6abknNuWV08aLaVfNR1nte3ZpiY+B9W0eG7A22hA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698560; 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=Ltlh1yijhRgVWTsTNrdWk8L+LDcH/2Yp9VpblYh/XoU=; b=U2iKzg60n+rXspDQzr0XnpuzZ9CviKR/nfitB9MLK7uyRdO/Prq/IRrs5c6XSGXlKNuj7xlC7xs/obn1wFghxV4xEPA5DxQLT/biZXJvTbaH71YAxlphKfo04vx4V8ldxfLXtNaZdBpdXPByN8VlGQDaxrymn9NkI/FH7Ck4LWk= 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 1562698560848945.7635573250002; Tue, 9 Jul 2019 11:56:00 -0700 (PDT) Received: from localhost ([::1]:52854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvHG-0007d7-PZ for importer@patchew.org; Tue, 09 Jul 2019 14:55:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36807) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyL-0004Cd-Up for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyK-0003en-As for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:13 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:38636) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyJ-0003VS-R9 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:12 -0400 Received: by mail-wr1-x441.google.com with SMTP id g17so11962029wrr.5 for ; Tue, 09 Jul 2019 11:35:57 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:56 -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=Ltlh1yijhRgVWTsTNrdWk8L+LDcH/2Yp9VpblYh/XoU=; b=CnLwaeVFF5UyXn115HNj5W23YmZD7Vhm/X8QZc+ptR7zQlwFbzzGZWFvrNFqa4RpGv FLIZAr/Rh10QKeH+x5oS4AuEFJxspx3F7BETy5XH6vHCL7jktyn7ro18Kym4iM5Cvy+d H/+9bUJcLjHbmqYjRCJ/MLuLRFzAT0k5ytOCzzQVLuI5JDxuZmYoS8Kq9KbO0vIKgGft 8W3QnogLpHbaKPx/MhDycrbVXIRp4tEU550m/BA1O7ITS8NikvVumgNRqzspuWUDjn2I nvP1AoX6SZI4yi/5f+HqHOQ1X3OWwt1DAbuE9z39DGCCSejL8hmxFVYQuAHKv7tb232r f+kg== 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=Ltlh1yijhRgVWTsTNrdWk8L+LDcH/2Yp9VpblYh/XoU=; b=VgVEE93rrnEFg/d+cOE/BmnRqAv492n641oQF2Hy3WoTR5EZHZnUiJAhg+3RoY+SU0 o6pcQ4s+Mm0gsDagKu81STfGcYukN+WkgNbK9zTGa5oA2T4DkhGIrFHEpiRU8fpabKLK qvdhK1qYZwbAGAoE2aAphxqC31XR174/27cbdtUPTlGqZJnrFVAZt26mGR6z1WJMf0vB BL/MQCvLUm6vvOcZPeQ75gMETZQ8xdEZCwwLvpzX8/Wb4nuecMk9/ijJtc00eUGOZu+X 9LYf52bUcHBxtrYpzx1a0wn26fBYcW4jFeRMqrm7irYHKPBLzyo7cR7kEHLQpQERPir+ KDcg== X-Gm-Message-State: APjAAAU4Eol7P/gRXTbFNQTAinGE1ucwfyD4Aan0Nh2Ejv6ceXinFPQT QHSy6A38yaUdFlzdztu+6VEzN6rK X-Google-Smtp-Source: APXvYqwfFCzZlVB3B0gWr40oqfsmrkVOpIN6fAZhmegloXWavqHgutLtGhCuqmiHtwpJdv96Xili7g== X-Received: by 2002:a5d:4602:: with SMTP id t2mr26228409wrq.38.1562697356854; Tue, 09 Jul 2019 11:35:56 -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: Tue, 9 Jul 2019 20:35:45 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH 05/11] 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Unless we disable stream moving, pulseaudio can easily move the stream on connect, effectively ignoring the source/sink specified by the user. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/paaudio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index cc3a34c2ea..24d98b344a 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -517,6 +517,11 @@ static pa_stream *qpa_simple_new ( #endif | PA_STREAM_AUTO_TIMING_UPDATE; =20 + if (dev) { + /* don't move the stream if the user specified a sink/source */ + flags |=3D PA_STREAM_DONT_MOVE; + } + if (dir =3D=3D PA_STREAM_PLAYBACK) { r =3D pa_stream_connect_playback(stream, dev, attr, flags, NULL, N= ULL); } else { --=20 2.22.0 From nobody Fri May 17 16:56:24 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=1562698447; cv=none; d=zoho.com; s=zohoarc; b=l6NFJYVDkMFfVrtLAeZvFYz8X3WgyjVx5vhxUCHg0ok/FNVe7EMO4yt9gBPWUqsslHnUxzsrmTF8uVdVFXny96JEmyf97G/UEbUEwJb6ufxx96RvYssXbi9FZjHS/zwRGZPsirRjJJaGpjVoeHTBNc0DmJx50g+eca3+yq693mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698447; 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=b0UIlwdOJH0003EaFwqDohvtU7bkw8Rr/9hyevQOR+E=; b=lIy7SHTRuDo9XvCgFBGZLd7oyivodun3TBE219zeonVv+59us/c2yYm4yc+Q9R1t0mg2pp8zWp2Gxe7R4iH8Vtrew7ronPx7LfrVaPMQAjHj8jmaa6N6l2tKPoCPT7SVQHdlFRXzg67eK4AQr1xO+PTQkZJGftcPlJVAnc8n5Gg= 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 1562698447193934.6816768019535; Tue, 9 Jul 2019 11:54:07 -0700 (PDT) Received: from localhost ([::1]:52846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvFZ-0006CN-T5 for importer@patchew.org; Tue, 09 Jul 2019 14:54:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36811) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyM-0004Cp-0q for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyJ-0003dA-IY for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:13 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyH-0003Vg-Iw for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:09 -0400 Received: by mail-wr1-x443.google.com with SMTP id z1so17477200wru.13 for ; Tue, 09 Jul 2019 11:35:58 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:57 -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=b0UIlwdOJH0003EaFwqDohvtU7bkw8Rr/9hyevQOR+E=; b=phqXkXhfheq993Oo9pjEzUo/ZSy2Mipud3u6zzjx5QUYgVAH/PTWBONRpz43cmk49V VMj5KaTOtHbjty+6M3MiwULJamdZnXqgNEM9mRA8IxroSRI4/p9cHKge4QtRg1Jjh6Nw nwav0Wg+SBadQfEWcfmcZGl4hm795dzYTXguQSUOg+rx9HKw6tzH7wo4odAK9NND+NCs DF5bT6mbKLpqNq2wskvgQsAaaH1aA0MmR7+SC+AzzBxpAm12Lk6trE21S+xi3C+Wc1sn EMEDW6/RZhwnC7SUMt3jmiXITPERrYFIVOt+WXFXzZOoMyN/hdXfUywa3kzHmkQammtp wP0Q== 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=b0UIlwdOJH0003EaFwqDohvtU7bkw8Rr/9hyevQOR+E=; b=A3MkXZYfo4oyRw7qB1TW7DI+ZxIxY1z4TLlohvKd/o/xnBF1KEZJv+DkpbhBrHCXgs 7h8mDmMhfBFoUontw4GvDK91ntuoLkAj8QYFd7bDLpPwCCAybT2gx65+NHEsAkpp6Ooy kBveZGJAOcWbVQ3nBdniLKl/CPovK+fSecK+IrQhj4QFMJeUAUUDpOrkeFMlh4kTddYn DXQH/RzpA8Jh6rEOV4LkqbZDGThZedVHkyl0uXRlXkLni62Sw7vrouw+P40CNoluDaKg iq2oBBICcKDv9c8DNKm+Tb1WbQIN9/pvSzzdj1EbrHYhAkgbarFKftvipl06Aw7i7P6A AxrQ== X-Gm-Message-State: APjAAAWvrmA5rQx33mvL3GEC3DX/KJaB2GkGgPBhu22tMRwiGgb/N4jW 3jQm1EAT2PNbwm72FOVuUtSnmUQ1 X-Google-Smtp-Source: APXvYqwCRGM3kKRYwxBuDgwT+rlCq9tla66HJtrxaKrOOIklkmPxTWuhF7UUV0K3daVF+NsHFCbwwQ== X-Received: by 2002:a5d:53c1:: with SMTP id a1mr27231739wrw.185.1562697357505; Tue, 09 Jul 2019 11:35:57 -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: Tue, 9 Jul 2019 20:35:46 +0200 Message-Id: <02a720bfd7c6bb09c9cedb505516f07f0b395838.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH 06/11] 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: 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..490bcd770e 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 dissconnect! err=3D%d\n", err); + } + pa_stream_unref(stream); + pa_threaded_mainloop_unlock(c->mainloop); +} + static void qpa_fini_out (HWVoiceOut *hw) { void *ret; @@ -696,7 +717,7 @@ static void qpa_fini_out (HWVoiceOut *hw) audio_pt_join(&pa->pt, &ret, __func__); =20 if (pa->stream) { - pa_stream_unref (pa->stream); + qpa_simple_disconnect(pa->g->conn, pa->stream); pa->stream =3D NULL; } =20 @@ -716,7 +737,7 @@ static void qpa_fini_in (HWVoiceIn *hw) audio_pt_join(&pa->pt, &ret, __func__); =20 if (pa->stream) { - pa_stream_unref (pa->stream); + qpa_simple_disconnect(pa->g->conn, pa->stream); pa->stream =3D NULL; } =20 --=20 2.22.0 From nobody Fri May 17 16:56:24 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=1562699459; cv=none; d=zoho.com; s=zohoarc; b=AT3n3PSabO/NlXBIVHgUp3RsXnUDIgLJ3b11bx6ug7hlYJgtFIWfUm44iyGmksg3pzKKGAN5PwnySpFnxwDmmuhzXGZuExjgKCLt5gUE87Jx72SZm+eAH0/XQjeaKxVg0qTbrC5922Tb3wa0U0XsPZjnHaTHZI5mrWV8uP+GrBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562699459; 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=K5vThfXlR4Qq387gOu9eXOu+S/m4S5yfacvAkB0HSso=; b=R+MmyDW35QK4xH8qVxMFu59JKdQHv+nHH2+2R415id2mVaLFiSjBwvSUrhbnlyHZOPfiWz+7sgprg2Y+c1ETfHNIniddCW/l+74HZ8FFgo1l6LD9xdr3NeaHPQ81QVz+RTEGZplB/lG6wpNAZy2zJn5tYeDlX4sGXNg8FNM8e24= 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 1562699459147844.8434249025394; Tue, 9 Jul 2019 12:10:59 -0700 (PDT) Received: from localhost ([::1]:53054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvVv-0003Ug-0w for importer@patchew.org; Tue, 09 Jul 2019 15:10:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37054) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyQ-0004Mv-Mf for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyK-0003fI-Dj for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:18 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:44364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyJ-0003WL-QY for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:12 -0400 Received: by mail-wr1-x42c.google.com with SMTP id p17so10938122wrf.11 for ; Tue, 09 Jul 2019 11:35:59 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:58 -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=K5vThfXlR4Qq387gOu9eXOu+S/m4S5yfacvAkB0HSso=; b=P8go0PQVZNQHHY9GY70BNCrXsi3ABbIHdUcFKUhuC7sskPnWkxzflgvMQHb2xpyR4S mNUGpyA60qZyzsI1A3IV8kiCQBuj16UNilGAJwqkM+pt3nVLARAvdvvR9+QGWj+qyY8U CzIwTZ+1GdTAdIwZoheHqZjp0E7ge7tq1/tbu9HljrshK2kyJ30CnS46gFB2TeD/Jhy0 K84/TNVSAW4cwdonwwPdvKFSeNjlhGZf6hoqeEX4L+F+eVB/NqU/8X8O2f1KvDoFELP4 K2NwwPEoNm11nBWgGHUYHSCthzeWFqcCvIcaFCOkKlBfO1j/3UfbUD3m+Cug3YmBa28s sy3A== 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=K5vThfXlR4Qq387gOu9eXOu+S/m4S5yfacvAkB0HSso=; b=hGWZbcPgftEUoJxzC9TnGN2x6pikbC/9zchYt3bYc4vPMQuNRuZ7h30b8NHvAd3Cf4 8e+5Xb8HCWKoQtogE3SC4A78gxKDt030lGJIhHMPkmhfLMYOuGvJvp+uOD4DwcK7pPnx UMfCv5VLQBiDlkmMBagL8EXYmrhKbFS1OtqfyCpSXUXCYnIYcIoOfLQOq1lCIk/GOkeN d6efeg5wixxF26fPBOJ9vnsNOoZe4UQWjaIamHef5t3Aqx7uoLsYVy6BZACRSoeXRPkM fMP16TxtXYni1UW26eQ/500+Mqp3bciyKfjDuoQMS9W19xtfjlhzJ3UiP1dfAY37Lrc0 MoBQ== X-Gm-Message-State: APjAAAWB8mhfHSDs1x1xF/AO72FkrtmJ/zAtmuKct/RQ99m5Jz94dDVu FG0kSc77QOIQtoq/OEq6aQOafxem X-Google-Smtp-Source: APXvYqy/mIv81Jr8g/6GKeoisixe1VVamQNxrmSg+PFkeI8E7QSGJlMnknIHwrpb5GMuQYbWRAoSrg== X-Received: by 2002:adf:ed11:: with SMTP id a17mr1561756wro.112.1562697358407; Tue, 09 Jul 2019 11:35:58 -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: Tue, 9 Jul 2019 20:35:47 +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::42c Subject: [Qemu-devel] [PATCH 07/11] 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: 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 82dd0e3e13..6bf30ac9b3 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 490bcd770e..9d46f11b0a 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 Fri May 17 16:56:24 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=1562698345; cv=none; d=zoho.com; s=zohoarc; b=kgGqwZDiF5VEmdu8pJWyRBmNUMBvDLRlcsRdFDLFzib/DQCMWBmci0tNMAomW5zHOALBsGxNppS6mn1gmv6clW7ba4fRyi5J7Imm4Mc2MPWjWS6L82EVEH/Ere+lHL/pCpixvt9XN4d2c0Aqtf8F10wxF9TSOV19Cm+72TVagkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698345; 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=LmbJOug2zkbiWUjvNY0y6Ru4b5pRTaqtC9D/nisqBi4=; b=XPI0NIlbOAs+erIzXnDWRQvDsYQegtP577AaGq5MRYgekj7nQVNT0CLXXcj7O7Gf3a2w13By+/RQKGr8aCKZHN4iTKDLH0cpZBE24KjeU7csHfpUneCYauWUKfRKqIIK3wGKahBF/d9P/2BZDT/szWfaQkxM91LTEfpFqDelQok= 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 1562698345859203.19766189341897; Tue, 9 Jul 2019 11:52:25 -0700 (PDT) Received: from localhost ([::1]:52822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvDv-0004GL-03 for importer@patchew.org; Tue, 09 Jul 2019 14:52:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36779) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyL-0004Ax-4k for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyJ-0003d0-J0 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:13 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35589) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyH-0003WT-H3 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:09 -0400 Received: by mail-wr1-x441.google.com with SMTP id y4so13518061wrm.2 for ; Tue, 09 Jul 2019 11:36:00 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:58 -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=LmbJOug2zkbiWUjvNY0y6Ru4b5pRTaqtC9D/nisqBi4=; b=WKdPifecwRx/IoSRh39vj45gzZk+9MrpL5j58ITu+wh6CKi4QrFc0iXEmpUGpoWCC8 RU/3d+pBCjSLDYZHFk4bqRt22paIC4o3LJxUrMddpf7goOehcJBgb/y9eaYXitaRLvou AH2GERIv1HK2Dy2MAWiSKODjXsuTRIzRdXFoqjsSsENZvksIfGUXkuKu67/GHs04zN7N bqPrtQzZ42kaBQ6Q9T91EvY1Yck15w4yb030cbtZgROUGl879lMmmAQdQckJHu/Cihph 6VECvhoNZCUcxEvJWcWEB+wvzCpBdoU8FedXuPFcDTdGaksYSfsfVQtDZDxNmVnB7ZFW wrgA== 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=LmbJOug2zkbiWUjvNY0y6Ru4b5pRTaqtC9D/nisqBi4=; b=qsORqlR+lwPquQTy/5M7m9nK9h4bS8Mqru27Sk10LyX8/ziqir3DiEY4yiukrAN36f 52WfkM+4KDYP4uBUTSIH0nFpav7f4pnoovxjb0xYdAqm+C7y6YiW3sSu6NLfkH2Oire8 6bIlM+UHbUJcnwNhSWrkkSo83+rnt9O9MHkLbrn9KKbe1RZx6J1tdZmYtzq6XVrnJZeQ +a5yBSiMlhXZCcYdROSpwyYca8ZQs/illty/DIb36AfXVyACExL2sbjhX1WY+oN/yC6L slmR4bQshFB2BvxpSgfGfO9BLyDDrUZyMr4UfAYurEcnBeM5na/Xc+KPlXj2SUcUanxy yNeg== X-Gm-Message-State: APjAAAU8hU42zvcVytx5w7SorM2Nh3aLmiDsDhjX6tZ9XVS+gOyWYcoB kFLDETy2iiRnXbtFKd1DaumzES17 X-Google-Smtp-Source: APXvYqyVmcoVsAolO4gFDZe8btTpWIoSJv1W3J9QsUv66tTiotT3obfU/eDgwy35gY7LYVYClJRRAA== X-Received: by 2002:adf:ebcd:: with SMTP id v13mr1674450wrn.263.1562697359072; Tue, 09 Jul 2019 11:35:59 -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: Tue, 9 Jul 2019 20:35:48 +0200 Message-Id: <185aa104b9cd1fbea627be06eefaf7cf29d67ad0.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH 08/11] 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: 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 6bf30ac9b3..d73cc086b6 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -835,7 +835,7 @@ static void audio_timer (void *opaque) } s->timer_last =3D now; =20 - audio_run("timer"); + audio_run(s, "timer"); audio_reset_timer(s); } =20 @@ -1237,15 +1237,11 @@ static void audio_run_capture (AudioState *s) } } =20 -void audio_run (const char *msg) +void audio_run(AudioState *s, const char *msg) { - AudioState *s; - - QTAILQ_FOREACH(s, &audio_states, list) { - audio_run_out(s); - audio_run_in(s); - audio_run_capture(s); - } + audio_run_out(s); + audio_run_in(s); + audio_run_capture(s); =20 #ifdef DEBUG_POLL { diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 29139ef1f5..456fba7480 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -110,28 +110,28 @@ static void oss_anal_close (int *fdp) =20 static void oss_helper_poll_out (void *opaque) { - (void) opaque; - audio_run ("oss_poll_out"); + AudioState *s =3D opaque; + audio_run(s, "oss_poll_out"); } =20 static void oss_helper_poll_in (void *opaque) { - (void) opaque; - audio_run ("oss_poll_in"); + AudioState *s =3D opaque; + audio_run(s, "oss_poll_in"); } =20 static void oss_poll_out (HWVoiceOut *hw) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; =20 - qemu_set_fd_handler (oss->fd, NULL, oss_helper_poll_out, NULL); + qemu_set_fd_handler(oss->fd, NULL, oss_helper_poll_out, hw->s); } =20 static void oss_poll_in (HWVoiceIn *hw) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; =20 - qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL); + qemu_set_fd_handler(oss->fd, oss_helper_poll_in, NULL, hw->s); } =20 static int oss_write (SWVoiceOut *sw, void *buf, int len) --=20 2.22.0 From nobody Fri May 17 16:56:24 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=1562698203; cv=none; d=zoho.com; s=zohoarc; b=cMpiMWZLbDSo4QxEl9gWHfYx55IseDPj+dOZ+JYaA0+tuatb5Yxxs+ayPEFUpWmz6WGgEbv1iQIcdJ4+oC9WNo1FH5tLhJzeDc0KaQs2tKtGXDesou214CHpoIQIO25EdYnZqthjxz+ztmLsysFk+wH3oet2MYaPGwQdFhD6lxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698203; 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=NFsbZz+vSV0dR/VsuT/cDCHXS4Tsui+1Dr2/Nb0Mgqg=; b=nTcCpOeHcSUWZuAt4GtGZqRiE4H/k2eM06cwbtow2XO+hbByR4tyUvc/qkKJF97t3TtHXwtC4R1AYM0m0BBOvRKeiiPWnuR/+zAR2RuEYMg3is4LgB2euyC4jHVrH/M9+M1KcH1qeMgcbf5sFpTDZZ7c0dYAWTSBcF/dLs6uUGo= 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 1562698203366810.606357555593; Tue, 9 Jul 2019 11:50:03 -0700 (PDT) Received: from localhost ([::1]:52810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvBf-0002E8-CX for importer@patchew.org; Tue, 09 Jul 2019 14:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36763) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyK-00049o-Ma for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyJ-0003d1-Kx for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:12 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:44087) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyH-0003Wk-IQ for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:09 -0400 Received: by mail-wr1-x441.google.com with SMTP id p17so10938166wrf.11 for ; Tue, 09 Jul 2019 11:36:00 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:35:59 -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=NFsbZz+vSV0dR/VsuT/cDCHXS4Tsui+1Dr2/Nb0Mgqg=; b=C/aEUY13tH+RUJjvY1OOH0juF7fjzi46PDZvZUDdmMSbBkXGcpszvl3SQDzLeAFvor E8oOhbadbXuXb67BcWoxqtrlxypfrnhOAUco+/QRfvrFaf2iZDElFbQgtzHo1wRaTgbM dce613cTwQaGOaRDeOt2pR4P6vWxIUnbgrVdu+PBnIatCjABVxfGMAP1Kcj2CRLmQu30 TtYM0nYg7p8fI/D/KNy9wmjLskmpxud62rrOd48C8cJJU/y1IQpt7ssNJLQbWN4z7Vxw J10UuUHIXtXyV/jQKIxWnQXUkB92DkKatF9xrU0Vs9iJQwmDsfqylbx6qluV9rkls+6S gamQ== 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=NFsbZz+vSV0dR/VsuT/cDCHXS4Tsui+1Dr2/Nb0Mgqg=; b=sKm/3T0Lvi9robNfyg1ZnYs/D9834ZIrZkzHCDgiJQNFNnuXlonXjwP6fjnyW6txR0 j/hW3jH/jvf+eRLOr7oEOEcijvsU9p4ch82nscvwwLGEjXlRMLu13ns/nh4IJ+IquSCG 09Kh12ODwJTqbBBSQ5wUSSyrvr97kRY5xVvr7Xn1kc6Nb1Z5gBaRLS5bkzZ/IIm16Ane zbM03QWCVl9NjN5RoU02nk/NxzeFEAESEKLfEuEl8KzmjRnmFead5nDfcpJN79rLmqBP /OzMfWyTzIgDvoTW5/JyZ3Oozff6qMMI9ZlBVCKG4sPJ8x40jUptY2Ch6DpIUcLXK+ae 96nQ== X-Gm-Message-State: APjAAAUB4juCYxjr8wSR3xdqIABjBz132nmb1zhx3zf9qNFTPFLDxgGe 3Yi0m5mP4BhKbmFREljMcy2zwC/l X-Google-Smtp-Source: APXvYqyzAgmhCSkroi/9G7/n7wu5cPR3XjyX7+JdZ1HraYMYlvbV4zekMdCOYkoiPbAUMAKmRbhVjw== X-Received: by 2002:adf:f98a:: with SMTP id f10mr1281434wrr.250.1562697359785; Tue, 09 Jul 2019 11:35:59 -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: Tue, 9 Jul 2019 20:35:49 +0200 Message-Id: <090ab2fb6a10d601e68012b4152c2dba7a902ca4.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH 09/11] 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 9d46f11b0a..d320d2e453 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -512,10 +512,8 @@ static pa_stream *qpa_simple_new ( =20 flags =3D PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY - | PA_STREAM_ADJUST_LATENCY -#endif - | PA_STREAM_AUTO_TIMING_UPDATE; + | PA_STREAM_AUTO_TIMING_UPDATE + | PA_STREAM_EARLY_REQUESTS; =20 if (dev) { /* don't move the stream if the user specified a sink/source */ --=20 2.22.0 From nobody Fri May 17 16:56:24 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=1562698653; cv=none; d=zoho.com; s=zohoarc; b=fKQNOeWD14xPlwLpndLKjS1zisjJClIT5Ig+Muy3CeUbmzmworvWUboIe3ZvVXqg2YAH26KkfqgNEsq1pQFVQZxqRUsjPf/Dx5u6127tmwP/DVKbxpqT2jdSwpbk2K1Z7/qmGLxt0Ha5/Xf4yyL1MWFbujErz/azLkFgT7Vj45I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562698653; 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=CGisyG8Oj2i3McJcTpliHuLEKd1p6QMEaWO+hjrPMu4=; b=PtgzBUX+QDfuBnnre8wGd5jasYvVmkG8nsTt62UIyxmL0qkfq3XelqABFa4CHTOBkquvCwK+ZDTBzi6cpjgxDWOHxk6cB9TqBXDrD6Mlrss/KfFaRl8IuKXrrTyUlUCsuE4D57VLKjF/ROUaRlKJDqiEG2vP1ydRaeu6Hyi8v90= 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 1562698653373127.00567729022225; Tue, 9 Jul 2019 11:57:33 -0700 (PDT) Received: from localhost ([::1]:52868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvIt-0000kB-3X for importer@patchew.org; Tue, 09 Jul 2019 14:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36913) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyN-0004G9-HL for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyJ-0003cz-J1 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:15 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:40747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyH-0003XD-GU for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:09 -0400 Received: by mail-wr1-x443.google.com with SMTP id r1so15765826wrl.7 for ; Tue, 09 Jul 2019 11:36:01 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.35.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CGisyG8Oj2i3McJcTpliHuLEKd1p6QMEaWO+hjrPMu4=; b=p1DuEUhPXk0hO0GhIy+nFcH0RxvKEUeXJO848hEGbIguQBKLpUdlAI4LCiJ62/Tmqt PGvqEPYRPn+G/bE2PJRzWipBgtQK2kwcKSsn1DnZdwW3sJEmi50qP62uoHJJ9ppfyMhX Ef5fag9GBx8iqFAI6BXy/+rpoAd0f/n87Pz8NVf1zLrJOJL8dDYAK7r0E2FWGT45xQQq B66tyC4k42I52hK4hw8RVawDB9uI4gKj8grk78vwh7wzb2lDH0dpYRT56hD+IrFzGhss iLmhE2/CecvPHcDFiRB/k/pdGFC6wuvJ1fafxLcHa0MFG4ia7ynN8d/cUIsazOOjYFNt qgOQ== 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=CGisyG8Oj2i3McJcTpliHuLEKd1p6QMEaWO+hjrPMu4=; b=NU6R69EQVNAE/+4B6AfaoIV7cACTlz/ICL+D6m69zCVxs2rc3ySQg+DG8nZzX4Wfki i9qrgK2yJRxH/eB/4Bc8SBTkaphvB9vrpR2Q274juxvZp03W91eslSF2nwCVjcXACYUe /fF0x7O4oso3B5iEJscQApeXpRpQQhRW5GS8w5WDnnLpdNzrWda26lrhRHErtugWDI22 BqJOSgeDhF7ucTZfOuOw7MxUlIcPhDMC5T01YiC0akaF1ghYZ7KgQrUyMRAc5FgNmJrM N84eIZImJyMdazw1Du1Rtzazu8Ybw7Awg4olyNQqf84BEKu+BtsAJVbscvXep5/elFqg 8MSw== X-Gm-Message-State: APjAAAWGWrMHUZccmp2PZzK9VXfgrTd44xssNtSAktA9jvnwyHmz0UdQ eD4KNfV1gwJQdDfjNmH3Z+SfovFJ X-Google-Smtp-Source: APXvYqwG1J2yytUIB05VtevV//CNy7iSOiHbLK///ei+9UEUVlzA0w8CoTCqvbtPGJ1nMfs8bYrWfw== X-Received: by 2002:a5d:620d:: with SMTP id y13mr27705798wru.243.1562697360652; Tue, 09 Jul 2019 11:36:00 -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: Tue, 9 Jul 2019 20:35:50 +0200 Message-Id: <0b7207b7ef4db3a894e9dbdefe4a007d8a19709c.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH 10/11] 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 d73cc086b6..b79f56fe64 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 d320d2e453..12471154ed 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 Fri May 17 16:56:24 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=1562699308; cv=none; d=zoho.com; s=zohoarc; b=ctzH1K68imGdszdn/iarOGU9lo4cIBdaHbC6axi3IHqzpHtoU6C51XxSef3HIoyguqS81UVA5l6qE9RtNuL7f9qKQt9+AppY9VCEoG1go73Mx/GZMGRSmmLhOViGHS8IQ3tF7Z9rlDpf9dBBa+Do6K9gONywkPCVB1l/3Dyys2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562699308; 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=wvXnq6hkLj8pTvXIvDl26WS4hTQGdiZjYzfOuS8kH/E=; b=Xa84Gzc+YNnk/3gYu7FSF+OHD5KMSOuaby51pYmnig9DKgN4zU5tw13AUqBp5gSp/syAthgM91PQ+kpP7XcAgNbtetMywQrtEkfyqZTfsE8S3cEWSrkkHm4hAV+Az5Lp1sN40Pzyk3uaPHrEPVw8r618FQb5MhyAuy2EoBrl+y4= 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 1562699308900540.5615648085275; Tue, 9 Jul 2019 12:08:28 -0700 (PDT) Received: from localhost ([::1]:52994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvTU-0001hK-PS for importer@patchew.org; Tue, 09 Jul 2019 15:08:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37063) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkuyR-0004N3-9Y for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkuyJ-0003da-Nh for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:19 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46296) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkuyH-0003Xq-Kc for qemu-devel@nongnu.org; Tue, 09 Jul 2019 14:36:11 -0400 Received: by mail-wr1-x442.google.com with SMTP id z1so17477413wru.13 for ; Tue, 09 Jul 2019 11:36:03 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6e3f-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6e3f::5]) by smtp.gmail.com with ESMTPSA id c12sm20565042wrd.21.2019.07.09.11.36.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 11:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wvXnq6hkLj8pTvXIvDl26WS4hTQGdiZjYzfOuS8kH/E=; b=Rurvh/aiNDo3RnKIlTyRDuthCnC376SXrRJz8tHA5ixcjIGYqGHfSxdchZTU5/JBEQ Rhjh0xPs64+OyUVW7pSPaXCa0H4d5zkYQF8Q+epRGaqPI2rCy6w62pSlMzE8IQK30qRX 7UVp65WPmKeB3cXLOTT6cWGNTtKqIRji8Zve2wglbhjzobXHO95PCQbr2+ihtzrSBmY7 92/dLQ5HsYR9hrkKGPOmrlodreWFQJOqmY9/F4Xl1sEQc9dfC+VSEtr9G5YUaqEaIJCF b21It+DUET4bTkSBy4qsTrsxGwIrd74Alcn91F59prRz1hVxD5uQE6LcxJ3AkKaksDQt 4XPQ== 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=wvXnq6hkLj8pTvXIvDl26WS4hTQGdiZjYzfOuS8kH/E=; b=FK+0ChHPpsoX9Gej53OfKfnpPM4BlzpMzA1Y7X35ZidphUrMlNeEkaeuoRwpAsN3IN cDFktP9UJm5Y61Bv/F2CGn3A9lOUsR0dJNqRIHzckTgG+7DRB5SN3OwhOikcFvcAlLNY RzxtLF4hYcHU6iw4/RtMI/TVeTUFTvvJuCzOm4FvAsDNoZu/+0N2gD82w0pahpUayGlX DW5c7MpqWo6Y7oaJI3hhHt3H3GS5Cn+kLYMGi3jvHwD0a/RpDE8IHGrB8ENKW1nXSVRc V0Wa395roC+AROghCWCXzqGh4nS7M8UGd4BVmwRSLo4D3iYlbMGRGoMLaE/OfUnb4bGa F0FA== X-Gm-Message-State: APjAAAWrGpT/hChca33+N1R/ISQWH4gbQowhZ8FCDwxH6IbH9m6ga9aT XaPhDG7ycynEIVLOhtSvWDMN0PxniMM= X-Google-Smtp-Source: APXvYqzmyKhFuPFwNTUPVTuAA735Br1biKOjuEv+CwgsBFOypYUUEay9oNUHrovfRvipo3mdA/EZ4g== X-Received: by 2002:a5d:4b0a:: with SMTP id v10mr26503772wrq.308.1562697361609; Tue, 09 Jul 2019 11:36:01 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Tue, 9 Jul 2019 20:35:51 +0200 Message-Id: <226b14a2fa0c8b905066df39d71822fa3c7374a1.1562695780.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH 11/11] 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 b79f56fe64..a497cb024e 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 12471154ed..dfe89d9ee5 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