From nobody Fri Nov 7 04:14:04 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 1547681988303735.0473175507658; Wed, 16 Jan 2019 15:39:48 -0800 (PST) Received: from localhost ([127.0.0.1]:59733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjumh-0005S5-2O for importer@patchew.org; Wed, 16 Jan 2019 18:39:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjukf-00040A-Ae for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjukd-0002ls-Cq for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:41 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:52844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjukc-0002el-QX for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:39 -0500 Received: by mail-wm1-x341.google.com with SMTP id m1so3893853wml.2 for ; Wed, 16 Jan 2019 15:37:32 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-e4b0-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:e4b0::5]) by smtp.gmail.com with ESMTPSA id s66sm30760437wmf.34.2019.01.16.15.37.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 15:37:30 -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=lDoXiYIV/EvJD3wV7LMocT/bjRg8AZPAp31z7dESMdg=; b=BSytpkVe36YMEd5lv9HkHoig0vMClfA+N+rZepmERPxtZG1+7f8Q3yahiKs+3fycHt vL+5tbKY4tln87VUsrSwSVEFGWdWZ415PNUrlF2MahPO26SHgbLjZ/jWwy6pTGCdLXZP fq7q9YNrwgLhcdoVl72k7zkT4r9m2EAgTdbTezlf8jRVFMWu2nP7qtexqZuT5mlL5A82 e6+r4fQS/OhoVKQi8Rf2IYxQ/KBpRtmWUGiC4Zg7BwGe6z8uRLMbO/7Zg/OpKf6kk9yj hYmSD2IBVu5QYNdRa9c2au0GHYN0v/2GXH0Ic+m9CRJg6sht3tLMxoLXW1E+tp0hmpmv 3USg== 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=lDoXiYIV/EvJD3wV7LMocT/bjRg8AZPAp31z7dESMdg=; b=Oud7QDpzZiVM9TY4+74R/1uTRtwGqIA+8BN6ltkMh0sJ0sO0Ep0pseVoCQN6y1uLcv dQZG/wj1+6HiL7xwsF5mV5IHzUYLoQVY7mxRFU5cilDOMZqu9umOvTIrCn71peRMhWlL okgNmLEBgvZh8/85H/lNnXMImZTUC9D0VU4m4VVS1F4UE1RtSWn3LEIc5RLbB8N4BZFz bgBNp5WHmfBwLlTa7cT7WxCO74jusjBMGuo17yCYIZ0z5BhYcEV+/JS8Ibz7OwAXXjyX 5xBei+6VMXcYPB6YF2ECC1kcrbB1iFhLz+YG+VT7t9uCHVLInzGNWkP2EqFcAq0Y9t5l GjrA== X-Gm-Message-State: AJcUukej1OvP+LSN46Y8nKBDGKMxXnzLvFjbLnn80QJsIo1+WEJftR6M xx5ZDpKd/zyBc3KbMrfp3Q62Zj3yccs= X-Google-Smtp-Source: ALg8bN4U7Y6WpyG4gPTKZLLgSebzxzNN11DKKg4X+gCNOExS+vErWpab3uaFHSBYXpbI6SitfxU9Rw== X-Received: by 2002:a1c:888d:: with SMTP id k135mr9723776wmd.137.1547681851000; Wed, 16 Jan 2019 15:37:31 -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: Thu, 17 Jan 2019 00:36:39 +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::341 Subject: [Qemu-devel] [PATCH v3 06/50] 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 | 47 ++++++++++---------------------------------- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 5117bdecb7..955fb18241 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..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