From nobody Fri Nov 7 03:56:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154559894986490.96001209844894; Sun, 23 Dec 2018 13:02:29 -0800 (PST) Received: from localhost ([127.0.0.1]:42212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbAtD-0004Sc-0y for importer@patchew.org; Sun, 23 Dec 2018 16:02:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbAjp-0007SE-Vs for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbAjo-0001tg-E3 for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:41 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33891) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbAjo-0001n7-7P for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:40 -0500 Received: by mail-wr1-x444.google.com with SMTP id j2so10134010wrw.1 for ; Sun, 23 Dec 2018 12:52:38 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-24a3-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:24a3::5]) by smtp.gmail.com with ESMTPSA id g198sm25456920wmd.23.2018.12.23.12.52.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Dec 2018 12:52:37 -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=wAHDeK1AOwR0vXP1Q2B9ENZRD49lzQs0kBC9KBs6zNk=; b=g0N9klN64bxalaHUWGsOnR0IUER9T6NxzSFBDrl/avsm+7d/8AVJPz/nSDMPpEPgr/ 4klBl1Kf7bq1ilmUQ1Um1JlPkWlOyCH+zqObpToUrIqkUBSIHsdJskuQo2kjIDuGrwDA tGy3QyAghKsLizJqZytiHAjZM/vt8o/dw3Z9IDmn0f2+aSjJZip5m/FyWOGodmQk02Wv GfuDn6q8C/WYadKR258PxIXcS9/hns+pBJ5E1WASJC/kjuOP/f862P+EgBq6Ju7E/q83 hk7tr70i+N8JZLqxRi3B2AL9yHCLSBnGwjQQ+vqsBOtsyPxJRzATPw3h+4ypYC3nLK/B 2ZQQ== 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=wAHDeK1AOwR0vXP1Q2B9ENZRD49lzQs0kBC9KBs6zNk=; b=i0syIcxq9V9EfNROwwwXxe1chFJFOP0GTBu5+fPOUCaiqY2cI0iBcs49lDIMaLy4n+ 23qE7GxQpaMND1ce1Wgk3BL+Mrdbn+xIS79ex5h/+8jqG39vasoVtGS/fwHmK1oBzY7D FJUjoLitQE+7G8K4gB0D3KXlW3XqiyjjetW7Dgy5jXc3m0U2zV1T9o9nssaN0g3S6N0J T4nQvMHiFlT5AdHAtwfLRFvr+p7v/1mVVO/xltZpO/hB6lwgWoZuIEePzCxoHwjALhFC irGcQhGZ0n5rO8D89gtXKpOS1S+2TiXjFqrK0UY68YEmqqCuebcCHjXBCZpsYG6hnDl3 9i3A== X-Gm-Message-State: AJcUukdBWIe1naPHFxl6EtaYvsQsFl40ZqD0jEcCmK/BWmumRmzN7mbu 9k7SqaAD5mchg/eDXBmGAVp0RwA+TZg= X-Google-Smtp-Source: ALg8bN4JtlTJLcF4WjVtNzomq3JKButZ5z78Qpj+Z5OWp7zLAl9EA8zQ4HNIzFxXZ7r2lPVPi1S5Nw== X-Received: by 2002:a5d:65ce:: with SMTP id e14mr9315913wrw.150.1545598357852; Sun, 23 Dec 2018 12:52:37 -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: Sun, 23 Dec 2018 21:51:44 +0100 Message-Id: <017477fdfa5850f2fe1ebfd99fc6e2cca58ce004.1545598229.git.DirtY.iCE.hu@gmail.com> 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::444 Subject: [Qemu-devel] [PATCH v2 08/52] 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 | 10 ++++++++++ audio/coreaudio.c | 47 ++++++++++---------------------------------- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index f91ce0c3e2..42b55035e3 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -63,6 +63,14 @@ SimpleEnvMap alsa_map[] =3D { { /* End of list */ } }; =20 +SimpleEnvMap coreaudio_map[] =3D { + { "QEMU_COREAUDIO_BUFFER_SIZE", "buffer-len", + ENV_TRANSFORM_FRAMES_TO_USECS_OUT }, + { "QEMU_COREAUDIO_BUFFER_COUNT", "buffer-count" }, + + { /* End of list */ } +}; + static unsigned long long toull(const char *str) { unsigned long long ret; @@ -233,6 +241,8 @@ static void legacy_opt(const char *drv) if (strcmp(drv, "alsa") =3D=3D 0) { handle_env_opts(opts, alsa_map); handle_alsa(opts); + } else if (strcmp(drv, "coreaudio") =3D=3D 0) { + handle_env_opts(opts, coreaudio_map); } } =20 diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 7d4225dbee..e00b8847d7 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,17 @@ 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 +566,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 +679,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 +699,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