From nobody Wed Oct 1 04:58:45 2025 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548716181119264.9355969817726; Mon, 28 Jan 2019 14:56:21 -0800 (PST) Received: from localhost ([127.0.0.1]:39792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goFpE-0008JK-2d for importer@patchew.org; Mon, 28 Jan 2019 17:56:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goFdA-0007oK-Qa for qemu-devel@nongnu.org; Mon, 28 Jan 2019 17:43:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goFd7-0003Pd-1A for qemu-devel@nongnu.org; Mon, 28 Jan 2019 17:43:52 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46768) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goFd6-0003Ny-Mh for qemu-devel@nongnu.org; Mon, 28 Jan 2019 17:43:48 -0500 Received: by mail-wr1-x442.google.com with SMTP id l9so19893289wrt.13 for ; Mon, 28 Jan 2019 14:43:45 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-2152-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:2152::5]) by smtp.gmail.com with ESMTPSA id k7sm100088187wrl.51.2019.01.28.14.43.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 14:43:44 -0800 (PST) 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=/WpCKV8MsWS/5GWJUv56eUCSrUMworAvsqT17LI1kn8=; b=UVgtYJcxq/zb2YrAmzCGnl+uSlUeNNW1xF3MgacVembQr5MN2kbnOCyxFQ6QaCnase /W6NXdx5cXU2f0Exzp+dz0pXJwNQw0wOPYQJPjzIqBjCyD+8bOgptcb+mbHk+zheL77y eomvzNNhAfdQbeItwCDgUjxrSfNaUFSUWgGyQ3ARZXb6wggkFewsnDrDWxHaR5k0T1k+ pOz0CJAqh6tkwAywZmvrBKdNC0UsjuQsxS57K0l4DPMr8b034yeghkVa5ysUcg/V4Bt/ JJbUs6epxFDqKJx0rKnl1LceHetyKrK6jy349WhcHilYHohNvjPUXbiNs9a2TPdte58S RBhw== 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=/WpCKV8MsWS/5GWJUv56eUCSrUMworAvsqT17LI1kn8=; b=av5enGJpeuptUPYkDhYlFEGnP9apSsnR4cB1YaiNH+3+dBUt6MRnLT+iGkCKNmT4zs ErlOitsc6uawXcAiJXoV7AqMr4ut1Tw5880HxbHEKXT+Ub7lwhcBqNRFsc7HRIW1caGp fJZrOPoh5v5KLqGX6hTgQvTMw3rYZUFO3YEwfTShu+e2bD9/XKTdm149SUiVYOeKjA5Z FXX+HlrhSDgp2I2U/wolP+r4hJ3i8wVkLTLaYvTAAwkQt5OWSBuFO5JocV4ropNk/1Kn bbTkZYcHbXQtjn6XZzyeVeq5QIOWGK57KSn/p4Eun0okZmLgrzT+3yxlJi4JSFheaNcK aN5Q== X-Gm-Message-State: AJcUukdxfQ2dh7+yrWnRqcjAFG0OZELlzh6B2WnC5eCBPZoD6I6sg1B+ Kli7pwoVM5HP+HXWY4aSKaUXSYCS4LOQSA== X-Google-Smtp-Source: ALg8bN52UrcE6v8CHXQemoDmOKNbfLmIdK2G8Pzy6OCnlB88NSFltGhMDA3LE4Hy9xwWChK0DQgUDw== X-Received: by 2002:a5d:6a42:: with SMTP id t2mr25268758wrw.50.1548715424390; Mon, 28 Jan 2019 14:43:44 -0800 (PST) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2019 23:43:29 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v4 06/14] coreaudio: port to -audiodev config X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_legacy.c | 24 ++++++++++++++++++++++ audio/coreaudio.c | 48 +++++++++----------------------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 8319dc5240..301934bf0c 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -109,6 +109,17 @@ static uint32_t frames_to_usecs(uint32_t frames, return (frames * 1000000 + freq / 2) / freq; } =20 + +static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_= dst, + AudiodevPerDirectionOptions *pdo) +{ + const char *val =3D getenv(env); + if (val) { + *dst =3D frames_to_usecs(toui32(val), pdo); + *has_dst =3D true; + } +} + /* backend specific functions */ /* ALSA */ static void handle_alsa_per_direction( @@ -166,6 +177,15 @@ static void handle_alsa(Audiodev *dev) &aopt->threshold, &aopt->has_threshold); } =20 +/* coreaudio */ +static void handle_coreaudio(Audiodev *dev) +{ + get_frames_to_usecs("QEMU_COREAUDIO_BUFFER_SIZE", &dev->out->buffer_le= n, + &dev->out->has_buffer_len, dev->out); + get_int("QEMU_COREAUDIO_BUFFER_COUNT", + &dev->out->buffer_count, &dev->out->has_buffer_count); +} + /* general */ static void handle_per_direction( AudiodevPerDirectionOptions *pdo, const char *prefix) @@ -213,6 +233,10 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_alsa(e->dev); break; =20 + case AUDIODEV_DRIVER_COREAUDIO: + handle_coreaudio(e->dev); + break; + default: break; } diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 7d4225dbee..a7c1e418b6 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -36,11 +36,6 @@ #define MAC_OS_X_VERSION_10_6 1060 #endif =20 -typedef struct { - int buffer_frames; - int nbuffers; -} CoreaudioConf; - typedef struct coreaudioVoiceOut { HWVoiceOut hw; pthread_mutex_t mutex; @@ -507,7 +502,9 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as, int err; const char *typ =3D "playback"; AudioValueRange frameRange; - CoreaudioConf *conf =3D drv_opaque; + Audiodev *dev =3D drv_opaque; + AudiodevPerDirectionOptions *pdo =3D dev->out; + int frames; =20 /* create mutex */ err =3D pthread_mutex_init(&core->mutex, NULL); @@ -538,16 +535,16 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct = audsettings *as, return -1; } =20 - if (frameRange.mMinimum > conf->buffer_frames) { + frames =3D audio_buffer_frames(pdo, as, 11610); + if (frameRange.mMinimum > frames) { core->audioDevicePropertyBufferFrameSize =3D (UInt32) frameRange.m= Minimum; dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMini= mum); - } - else if (frameRange.mMaximum < conf->buffer_frames) { + } else if (frameRange.mMaximum < frames) { core->audioDevicePropertyBufferFrameSize =3D (UInt32) frameRange.m= Maximum; dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMa= ximum); } else { - core->audioDevicePropertyBufferFrameSize =3D conf->buffer_frames; + core->audioDevicePropertyBufferFrameSize =3D frames; } =20 /* set Buffer Frame Size */ @@ -568,7 +565,8 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as, "Could not get device buffer frame size\n"); return -1; } - hw->samples =3D conf->nbuffers * core->audioDevicePropertyBufferFrameS= ize; + hw->samples =3D (pdo->has_buffer_count ? pdo->buffer_count : 4) * + core->audioDevicePropertyBufferFrameSize; =20 /* get StreamFormat */ status =3D coreaudio_get_streamformat(core->outputDeviceID, @@ -680,40 +678,15 @@ static int coreaudio_ctl_out (HWVoiceOut *hw, int cmd= , ...) return 0; } =20 -static CoreaudioConf glob_conf =3D { - .buffer_frames =3D 512, - .nbuffers =3D 4, -}; - static void *coreaudio_audio_init(Audiodev *dev) { - CoreaudioConf *conf =3D g_malloc(sizeof(CoreaudioConf)); - *conf =3D glob_conf; - - return conf; + return dev; } =20 static void coreaudio_audio_fini (void *opaque) { - g_free(opaque); } =20 -static struct audio_option coreaudio_options[] =3D { - { - .name =3D "BUFFER_SIZE", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.buffer_frames, - .descr =3D "Size of the buffer in frames" - }, - { - .name =3D "BUFFER_COUNT", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.nbuffers, - .descr =3D "Number of buffers" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops coreaudio_pcm_ops =3D { .init_out =3D coreaudio_init_out, .fini_out =3D coreaudio_fini_out, @@ -725,7 +698,6 @@ static struct audio_pcm_ops coreaudio_pcm_ops =3D { static struct audio_driver coreaudio_audio_driver =3D { .name =3D "coreaudio", .descr =3D "CoreAudio http://developer.apple.com/audio/coreau= dio.html", - .options =3D coreaudio_options, .init =3D coreaudio_audio_init, .fini =3D coreaudio_audio_fini, .pcm_ops =3D &coreaudio_pcm_ops, --=20 2.20.1