From nobody Sun Nov 9 14:50:02 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 1550698810874332.5401216665588; Wed, 20 Feb 2019 13:40:10 -0800 (PST) Received: from localhost ([127.0.0.1]:49236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwZb7-0007P4-7O for importer@patchew.org; Wed, 20 Feb 2019 16:40:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwZZ4-0006Ck-Pi for qemu-devel@nongnu.org; Wed, 20 Feb 2019 16:38:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwZZ2-0000lR-PN for qemu-devel@nongnu.org; Wed, 20 Feb 2019 16:38:02 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:33170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwZZ1-0000Qo-N2 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 16:38:00 -0500 Received: by mail-wm1-x343.google.com with SMTP id h22so5603218wmb.0 for ; Wed, 20 Feb 2019 13:37:52 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6fd0-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6fd0::5]) by smtp.gmail.com with ESMTPSA id o18sm66452489wrg.40.2019.02.20.13.37.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 13:37:50 -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=9G97o07Kfc75ryIFxOJlOsClJCP6chXirCy+ZvOezmk=; b=qkMgFRruPzfNea7eozcXqQ9/dQgev3iqxS1o+s/38NFz6m30CxwlP4bKdRIXsdA4ro G/Ra6tkNlfTQb0SNEDKhca+P3Niyjm5+JhxeC58AysB+gazoEwdUXhNjIDa/beuTb3Zq JYzNZYB6oTgqRKvvtikzlrKcjncE08wOyQimKHLfiX9Tt4Hg75yEO0s0a+VWr+CxzcCl Rs3U4CkrVR1n6G2IA7qv0fpfkHJ8KCNWazgcZkrKnKxvjrHz7gwFkZ5GarOmwHi/FlrX qzZboiuS+6LRd4gz+vVierllIElIrfRg3iWfQz8KYh21rZ0p5v6tIEjqQIYHPgar6I75 VwIw== 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=9G97o07Kfc75ryIFxOJlOsClJCP6chXirCy+ZvOezmk=; b=LdqAiKRgi51Jh1mbUHaISyiqRxMuI0wTWeE0mI1j0nn08cWYdTAL2+YqTBTiARzs9/ 6eHnYhlWoAadJKv9kX72oY5ADvYkhKYfbGuNzpVUsBcqiNa4WlQkzkj2MWhSR/II3y1r sarDcoYUBmtnSLZaUqLSll49LLa+gxS7vkl/IlwkulpWGMTO8jYvm8ModuNY50pYiF3T JGHl2CIYymLRvKyMqyj1NfSUGfsORIRVx2t/b8rvSid4w7tk2o80xf9UDCPQq6NJLm0/ ft2wSFmSDg35QsG62SNYIdLNOcfLbF3Q0lesfLFzaUqEJj82a9QcTvNT6EM33aQCqwbn +g0w== X-Gm-Message-State: AHQUAuYxpMVdz39EHV3EO/9pY6lGFgtb37dJksjoPEe773JWxOGG+ZUg RpByzBAGZVKvx4X/rQj86czAqLZVKSk= X-Google-Smtp-Source: AHgI3IagIh4Y1TsEDkUly/zmm4loHgh8Unop13KaU/gArMAW9KK2zR48CkdKgYmXd8HO1FUpnoqCnw== X-Received: by 2002:a1c:9acd:: with SMTP id c196mr8410165wme.145.1550698671113; Wed, 20 Feb 2019 13:37:51 -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: Wed, 20 Feb 2019 22:37:35 +0100 Message-Id: <5360bea19c08b79cb618e0cd304bebd36643cf3e.1550698466.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::343 Subject: [Qemu-devel] [PATCH v5 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 | 28 +++++++++++++++++++++++++ audio/coreaudio.c | 49 ++++++++++---------------------------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 91ec6a3de1..086011fbff 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( @@ -156,6 +167,19 @@ 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->u.coreaudio.out->buffer_len, + &dev->u.coreaudio.out->has_buffer_len, + qapi_AudiodevCoreaudioPerDirectionOptions_base(dev->u.coreaudio.ou= t)); + get_int("QEMU_COREAUDIO_BUFFER_COUNT", + &dev->u.coreaudio.out->buffer_count, + &dev->u.coreaudio.out->has_buffer_count); +} + /* general */ static void handle_per_direction( AudiodevPerDirectionOptions *pdo, const char *prefix) @@ -201,6 +225,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..1ee43b7d5f 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; + AudiodevCoreaudioPerDirectionOptions *cpdo =3D dev->u.coreaudio.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( + qapi_AudiodevCoreaudioPerDirectionOptions_base(cpdo), 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 (cpdo->has_buffer_count ? cpdo->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