get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2196846/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2196846,
    "url": "http://patchwork.ozlabs.org/api/patches/2196846/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260216-audio-v1-72-e676662e4514@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260216-audio-v1-72-e676662e4514@redhat.com>",
    "list_archive_url": null,
    "date": "2026-02-16T11:16:01",
    "name": "[72/85] audio/mixeng: replace redundant pcm_info fields with AudioFormat",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "c4b52b5c641e5d83b97738f814ab605180e4f8d2",
    "submitter": {
        "id": 66774,
        "url": "http://patchwork.ozlabs.org/api/people/66774/?format=api",
        "name": "Marc-André Lureau",
        "email": "marcandre.lureau@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260216-audio-v1-72-e676662e4514@redhat.com/mbox/",
    "series": [
        {
            "id": 492294,
            "url": "http://patchwork.ozlabs.org/api/series/492294/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=492294",
            "date": "2026-02-16T11:14:52",
            "name": "audio: cleanups & add a manual test",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/492294/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2196846/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2196846/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=O1MlrzIA;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fF0p96Yvcz1xwF\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 16 Feb 2026 22:26:09 +1100 (AEDT)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vrwfg-0000VJ-H9; Mon, 16 Feb 2026 06:21:44 -0500",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1vrwdB-0007Y4-Uw\n for qemu-devel@nongnu.org; Mon, 16 Feb 2026 06:19:10 -0500",
            "from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1vrwd9-0008RN-7S\n for qemu-devel@nongnu.org; Mon, 16 Feb 2026 06:19:09 -0500",
            "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-iL9B9r0ONgGtNee3MF5IxA-1; Mon,\n 16 Feb 2026 06:19:03 -0500",
            "from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 5860C1800613; Mon, 16 Feb 2026 11:19:01 +0000 (UTC)",
            "from localhost (unknown [10.45.242.26])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id E746719560A2; Mon, 16 Feb 2026 11:18:59 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1771240746;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=69TpAbLc835uRq+7bqGvGaCCGAehwUooI9PZV8h2xkQ=;\n b=O1MlrzIAAHsASqNtzy14RNseaSwOaicWvtaLgWTY3IspLCejUL0Ah58XY3LZXM7ODXgqeo\n V2pZZrktPYjO9OGKPLvnM742wczSSVyKYJ93ebln54j8wVuBSPotqEzRrsDE5YertermZ3\n qmP29WiWu1vDjoqyndnEqESZbBjTQoY=",
        "X-MC-Unique": "iL9B9r0ONgGtNee3MF5IxA-1",
        "X-Mimecast-MFC-AGG-ID": "iL9B9r0ONgGtNee3MF5IxA_1771240741",
        "From": "=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>",
        "Date": "Mon, 16 Feb 2026 12:16:01 +0100",
        "Subject": "[PATCH 72/85] audio/mixeng: replace redundant pcm_info fields with\n AudioFormat",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "8bit",
        "Message-Id": "<20260216-audio-v1-72-e676662e4514@redhat.com>",
        "References": "<20260216-audio-v1-0-e676662e4514@redhat.com>",
        "In-Reply-To": "<20260216-audio-v1-0-e676662e4514@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "Gerd Hoffmann <kraxel@redhat.com>,  Eduardo Habkost <eduardo@habkost.net>,\n Paolo Bonzini <pbonzini@redhat.com>,\n =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= <berrange@redhat.com>, =?utf-8?q?Phil?=\n\t=?utf-8?q?ippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>,\n  John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>,\n  Christian Schoenebeck <qemu_oss@crudebyte.com>,\n  Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>,\n  Thomas Huth <huth@tuxfamily.org>, Alexandre Ratchov <alex@caoua.org>,\n\t=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>,\n  Laurent Vivier <laurent@vivier.eu>, \"Michael S. Tsirkin\" <mst@redhat.com>,\n  Manos Pitsidianakis <manos.pitsidianakis@linaro.org>,\n  Alistair Francis <alistair@alistair23.me>,\n  \"Edgar E. Iglesias\" <edgar.iglesias@gmail.com>,\n  Peter Maydell <peter.maydell@linaro.org>, qemu-arm@nongnu.org, =?utf-8?q?M?=\n\t=?utf-8?q?arc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n  Mark Cave-Ayland <mark.caveayland@nutanix.com>",
        "X-Developer-Signature": "v=1; a=openpgp-sha256; l=14827;\n i=marcandre.lureau@redhat.com; h=from:subject:message-id;\n bh=6RvKes4eeAZsnFIGHb2No0aVPDEgHxjZ5PZuEzoitnE=;\n b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBpkvxRIdt9pEaFKX1LeDM3omLSV9e2u5tzZsVB1\n 4mVsA571qOJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaZL8UQAKCRDa6OEJdZac\n 5VDID/9xRrLsopHx1gJXXggw5OnMkQNTCEvUa0/IEMNo2ohrXBnZgn9lzWrwC8cjxaPVPrRYhPS\n SQU43wTIXCfuq1Fvu+wMUwnDCTXfxkwvS+ooqniRlXDZBFCuv1E9957y1n7N18Zg3FIDm4YkCTf\n +Lyj0yFrLfGCrv6UHv/0lelAxAITl4I2e2XmZYtP1AzEmk6JTNscx/xCaQGM+u7dDC/HTyCzshT\n Hf5hunwj17bMeEUgqvmI3ZjYzRVrBUmZKHqolkqVpuOFcAjkgSAMbeUoTL68I6CZVr5xpKlZPy6\n BafwwW3pWqpU/HmByGk7aHqC87owTbNfsaA1RozLSK/DTIMHlqi+wvRYPkmhK61SL6snm4l/zSg\n 8n/EMkFW3sUUK07Zy3rr3APbgthDxgfLejvVfG33FSAPxjZWMKLtLnmgN/2XC4aHupMkwhH8kgN\n qt+A6+Cpq+YIO9ZOsxFMArB1P80cxZWaJWYEzCNibegbzaDFupqNv6KzTAjW51bewZ/B0BSoGFS\n cIwSJUlaGDIM+Y+WRi7w+laOldovlh0F0kfq3Ci3dccVyShCc8pdE2r07hmHPvQaHrGvtC1Ynbe\n YQH2skUVP+yTOx7krxd7B9DKE67t+t2MNkRqcuPFbhcBpr94TksQ3w9nHxH4BMzhOYDpfeIY83g\n ncV3/or0QAR6Mtw==",
        "X-Developer-Key": "i=marcandre.lureau@redhat.com; a=openpgp;\n fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5",
        "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.12",
        "Received-SPF": "pass client-ip=170.10.133.124;\n envelope-from=marcandre.lureau@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com",
        "X-Spam_score_int": "-20",
        "X-Spam_score": "-2.1",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "qemu development <qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "The audio_pcm_info structure stored three fields (bits, is_signed,\nis_float) that were always derived from the AudioFormat enum. This\nredundancy meant the same information was represented twice, with no\ntype-level guarantee that they stayed in sync.\n\nReplace these fields with a single AudioFormat field, and add helper\nfunctions to extract the derived properties when needed:\n- audio_format_bits()\n- audio_format_is_signed()\n- audio_format_is_float()\n\nThis improves type safety by making AudioFormat the single source of\ntruth, eliminating the possibility of inconsistent state between the\nformat enum and its derived boolean/integer representations.\n\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nReviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>\nReviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>\n---\n audio/audio_int.h       |   4 +-\n audio/audio_template.h  |  12 +--\n include/qemu/audio.h    |  49 +++++++++++\n audio/audio-mixeng-be.c | 218 ++++++++++++++----------------------------------\n audio/dbusaudio.c       |  12 +--\n audio/coreaudio.m       |   2 +-\n 6 files changed, 126 insertions(+), 171 deletions(-)",
    "diff": "diff --git a/audio/audio_int.h b/audio/audio_int.h\nindex 5334c4baad2..dd5f2220d75 100644\n--- a/audio/audio_int.h\n+++ b/audio/audio_int.h\n@@ -45,9 +45,7 @@ struct audio_callback {\n };\n \n struct audio_pcm_info {\n-    int bits;\n-    bool is_signed;\n-    bool is_float;\n+    AudioFormat af;\n     int freq;\n     int nchannels;\n     int bytes_per_frame;\ndiff --git a/audio/audio_template.h b/audio/audio_template.h\nindex 08d60422589..3da91a4782c 100644\n--- a/audio/audio_template.h\n+++ b/audio/audio_template.h\n@@ -173,7 +173,7 @@ static int glue (audio_pcm_sw_init_, TYPE) (\n     sw->empty = true;\n #endif\n \n-    if (sw->info.is_float) {\n+    if (audio_format_is_float(hw->info.af)) {\n #ifdef DAC\n         sw->conv = mixeng_conv_float[sw->info.nchannels == 2]\n             [sw->info.swap_endianness];\n@@ -188,9 +188,9 @@ static int glue (audio_pcm_sw_init_, TYPE) (\n         sw->clip = mixeng_clip\n #endif\n             [sw->info.nchannels == 2]\n-            [sw->info.is_signed]\n+            [audio_format_is_signed(hw->info.af)]\n             [sw->info.swap_endianness]\n-            [audio_bits_to_index(sw->info.bits)];\n+            [audio_format_to_index(hw->info.af)];\n     }\n \n     sw->name = g_strdup (name);\n@@ -300,7 +300,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixengBackend *s,\n         goto err1;\n     }\n \n-    if (hw->info.is_float) {\n+    if (audio_format_is_float(hw->info.af)) {\n #ifdef DAC\n         hw->clip = mixeng_clip_float[hw->info.nchannels == 2]\n             [hw->info.swap_endianness];\n@@ -315,9 +315,9 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixengBackend *s,\n         hw->conv = mixeng_conv\n #endif\n             [hw->info.nchannels == 2]\n-            [hw->info.is_signed]\n+            [audio_format_is_signed(hw->info.af)]\n             [hw->info.swap_endianness]\n-            [audio_bits_to_index(hw->info.bits)];\n+            [audio_format_to_index(hw->info.af)];\n     }\n \n     glue(audio_pcm_hw_alloc_resources_, TYPE)(hw);\ndiff --git a/include/qemu/audio.h b/include/qemu/audio.h\nindex b6b6ee9b560..9e4566d60aa 100644\n--- a/include/qemu/audio.h\n+++ b/include/qemu/audio.h\n@@ -185,6 +185,55 @@ bool audio_be_set_dbus_server(AudioBackend *be,\n \n const char *audio_application_name(void);\n \n+static inline int audio_format_bits(AudioFormat fmt)\n+{\n+    switch (fmt) {\n+    case AUDIO_FORMAT_S8:\n+    case AUDIO_FORMAT_U8:\n+        return 8;\n+\n+    case AUDIO_FORMAT_S16:\n+    case AUDIO_FORMAT_U16:\n+        return 16;\n+\n+    case AUDIO_FORMAT_F32:\n+    case AUDIO_FORMAT_S32:\n+    case AUDIO_FORMAT_U32:\n+        return 32;\n+\n+    case AUDIO_FORMAT__MAX:\n+        break;\n+    }\n+\n+    g_assert_not_reached();\n+}\n+\n+static inline bool audio_format_is_float(AudioFormat fmt)\n+{\n+    return fmt == AUDIO_FORMAT_F32;\n+}\n+\n+static inline bool audio_format_is_signed(AudioFormat fmt)\n+{\n+    switch (fmt) {\n+    case AUDIO_FORMAT_S8:\n+    case AUDIO_FORMAT_S16:\n+    case AUDIO_FORMAT_S32:\n+    case AUDIO_FORMAT_F32:\n+        return true;\n+\n+    case AUDIO_FORMAT_U8:\n+    case AUDIO_FORMAT_U16:\n+    case AUDIO_FORMAT_U32:\n+        return false;\n+\n+    case AUDIO_FORMAT__MAX:\n+        break;\n+    }\n+\n+    g_assert_not_reached();\n+}\n+\n #define DEFINE_AUDIO_PROPERTIES(_s, _f)         \\\n     DEFINE_PROP_AUDIODEV(\"audiodev\", _s, _f)\n \ndiff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c\nindex d02cfe3c509..931d5b206f2 100644\n--- a/audio/audio-mixeng-be.c\n+++ b/audio/audio-mixeng-be.c\n@@ -62,23 +62,28 @@ int audio_bug (const char *funcname, int cond)\n     return cond;\n }\n \n-static inline int audio_bits_to_index (int bits)\n+/*\n+ * Convert audio format to mixeng_clip index. Used by audio_pcm_sw_init_ and\n+ * audio_mixeng_backend_add_capture()\n+ */\n+static int audio_format_to_index(AudioFormat af)\n {\n-    switch (bits) {\n-    case 8:\n+    switch (af) {\n+    case AUDIO_FORMAT_U8:\n+    case AUDIO_FORMAT_S8:\n         return 0;\n-\n-    case 16:\n+    case AUDIO_FORMAT_U16:\n+    case AUDIO_FORMAT_S16:\n         return 1;\n-\n-    case 32:\n+    case AUDIO_FORMAT_U32:\n+    case AUDIO_FORMAT_S32:\n         return 2;\n-\n-    default:\n-        audio_bug (\"bits_to_index\", 1);\n-        AUD_log (NULL, \"invalid bits %d\\n\", bits);\n-        return 0;\n+    case AUDIO_FORMAT_F32:\n+    case AUDIO_FORMAT__MAX:\n+        break;\n     }\n+\n+    g_assert_not_reached();\n }\n \n void AUD_vlog (const char *cap, const char *fmt, va_list ap)\n@@ -172,141 +177,68 @@ static int audio_validate_settings (const struct audsettings *as)\n \n static int audio_pcm_info_eq (struct audio_pcm_info *info, const struct audsettings *as)\n {\n-    int bits = 8;\n-    bool is_signed = false, is_float = false;\n-\n-    switch (as->fmt) {\n-    case AUDIO_FORMAT_S8:\n-        is_signed = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_U8:\n-        break;\n-\n-    case AUDIO_FORMAT_S16:\n-        is_signed = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_U16:\n-        bits = 16;\n-        break;\n-\n-    case AUDIO_FORMAT_F32:\n-        is_float = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_S32:\n-        is_signed = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_U32:\n-        bits = 32;\n-        break;\n-\n-    default:\n-        abort();\n-    }\n-    return info->freq == as->freq\n+    return info->af == as->fmt\n+        && info->freq == as->freq\n         && info->nchannels == as->nchannels\n-        && info->is_signed == is_signed\n-        && info->is_float == is_float\n-        && info->bits == bits\n         && info->swap_endianness == (as->endianness != HOST_BIG_ENDIAN);\n }\n \n void audio_pcm_init_info (struct audio_pcm_info *info, const struct audsettings *as)\n {\n-    int bits = 8, mul;\n-    bool is_signed = false, is_float = false;\n-\n-    switch (as->fmt) {\n-    case AUDIO_FORMAT_S8:\n-        is_signed = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_U8:\n-        mul = 1;\n-        break;\n-\n-    case AUDIO_FORMAT_S16:\n-        is_signed = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_U16:\n-        bits = 16;\n-        mul = 2;\n-        break;\n-\n-    case AUDIO_FORMAT_F32:\n-        is_float = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_S32:\n-        is_signed = true;\n-        /* fall through */\n-    case AUDIO_FORMAT_U32:\n-        bits = 32;\n-        mul = 4;\n-        break;\n-\n-    default:\n-        abort();\n-    }\n-\n+    info->af = as->fmt;\n     info->freq = as->freq;\n-    info->bits = bits;\n-    info->is_signed = is_signed;\n-    info->is_float = is_float;\n     info->nchannels = as->nchannels;\n-    info->bytes_per_frame = as->nchannels * mul;\n+    info->bytes_per_frame = as->nchannels * audio_format_bits(as->fmt) / 8;\n     info->bytes_per_second = info->freq * info->bytes_per_frame;\n     info->swap_endianness = (as->endianness != HOST_BIG_ENDIAN);\n }\n \n-void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)\n+void audio_pcm_info_clear_buf(struct audio_pcm_info *info, void *buf, int len)\n {\n     if (!len) {\n         return;\n     }\n \n-    if (info->is_signed || info->is_float) {\n-        memset(buf, 0x00, len * info->bytes_per_frame);\n-    } else {\n-        switch (info->bits) {\n-        case 8:\n-            memset(buf, 0x80, len * info->bytes_per_frame);\n-            break;\n-\n-        case 16:\n-            {\n-                int i;\n-                uint16_t *p = buf;\n-                short s = INT16_MAX;\n-\n-                if (info->swap_endianness) {\n-                    s = bswap16 (s);\n-                }\n-\n-                for (i = 0; i < len * info->nchannels; i++) {\n-                    p[i] = s;\n-                }\n-            }\n-            break;\n+    switch (info->af) {\n+    case AUDIO_FORMAT_U8:\n+        memset(buf, 0x80, len * info->bytes_per_frame);\n+        break;\n+    case AUDIO_FORMAT_U16: {\n+        int i;\n+        uint16_t *p = buf;\n+        short s = INT16_MAX;\n \n-        case 32:\n-            {\n-                int i;\n-                uint32_t *p = buf;\n-                int32_t s = INT32_MAX;\n+        if (info->swap_endianness) {\n+            s = bswap16(s);\n+        }\n \n-                if (info->swap_endianness) {\n-                    s = bswap32 (s);\n-                }\n+        for (i = 0; i < len * info->nchannels; i++) {\n+            p[i] = s;\n+        }\n+        break;\n+    }\n+    case AUDIO_FORMAT_U32: {\n+        int i;\n+        uint32_t *p = buf;\n+        int32_t s = INT32_MAX;\n \n-                for (i = 0; i < len * info->nchannels; i++) {\n-                    p[i] = s;\n-                }\n-            }\n-            break;\n+        if (info->swap_endianness) {\n+            s = bswap32(s);\n+        }\n \n-        default:\n-            AUD_log (NULL, \"audio_pcm_info_clear_buf: invalid bits %d\\n\",\n-                     info->bits);\n-            break;\n+        for (i = 0; i < len * info->nchannels; i++) {\n+            p[i] = s;\n         }\n+        break;\n+    }\n+    case AUDIO_FORMAT_S8:\n+    case AUDIO_FORMAT_S16:\n+    case AUDIO_FORMAT_S32:\n+    case AUDIO_FORMAT_F32:\n+        memset(buf, 0x00, len * info->bytes_per_frame);\n+        break;\n+    case AUDIO_FORMAT__MAX:\n+        g_assert_not_reached();\n     }\n }\n \n@@ -719,8 +651,8 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t buf_len)\n #ifdef DEBUG_AUDIO\n static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *info)\n {\n-    dolog(\"%s: bits %d, sign %d, float %d, freq %d, nchan %d\\n\",\n-          cap, info->bits, info->is_signed, info->is_float, info->freq,\n+    dolog(\"%s: %s, freq %d, nchan %d\\n\",\n+          cap, AudioFormat_str(info->af), info->freq,\n           info->nchannels);\n }\n #endif\n@@ -1759,15 +1691,15 @@ static CaptureVoiceOut *audio_mixeng_backend_add_capture(\n \n         cap->buf = g_malloc0_n(hw->mix_buf.size, hw->info.bytes_per_frame);\n \n-        if (hw->info.is_float) {\n+        if (audio_format_is_float(hw->info.af)) {\n             hw->clip = mixeng_clip_float[hw->info.nchannels == 2]\n                 [hw->info.swap_endianness];\n         } else {\n             hw->clip = mixeng_clip\n                 [hw->info.nchannels == 2]\n-                [hw->info.is_signed]\n+                [audio_format_is_signed(hw->info.af)]\n                 [hw->info.swap_endianness]\n-                [audio_bits_to_index(hw->info.bits)];\n+                [audio_format_to_index(hw->info.af)];\n         }\n \n         QLIST_INSERT_HEAD (&s->cap_head, cap, entries);\n@@ -1869,29 +1801,6 @@ audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo)\n     };\n }\n \n-int audioformat_bytes_per_sample(AudioFormat fmt)\n-{\n-    switch (fmt) {\n-    case AUDIO_FORMAT_U8:\n-    case AUDIO_FORMAT_S8:\n-        return 1;\n-\n-    case AUDIO_FORMAT_U16:\n-    case AUDIO_FORMAT_S16:\n-        return 2;\n-\n-    case AUDIO_FORMAT_U32:\n-    case AUDIO_FORMAT_S32:\n-    case AUDIO_FORMAT_F32:\n-        return 4;\n-\n-    case AUDIO_FORMAT__MAX:\n-        ;\n-    }\n-    abort();\n-}\n-\n-\n /* frames = freq * usec / 1e6 */\n int audio_buffer_frames(AudiodevPerDirectionOptions *pdo,\n                         audsettings *as, int def_usecs)\n@@ -1914,8 +1823,7 @@ int audio_buffer_samples(AudiodevPerDirectionOptions *pdo,\n int audio_buffer_bytes(AudiodevPerDirectionOptions *pdo,\n                        audsettings *as, int def_usecs)\n {\n-    return audio_buffer_samples(pdo, as, def_usecs) *\n-        audioformat_bytes_per_sample(as->fmt);\n+    return audio_buffer_samples(pdo, as, def_usecs) * audio_format_bits(as->fmt) / 8;\n }\n \n void audio_rate_start(RateCtl *rate)\ndiff --git a/audio/dbusaudio.c b/audio/dbusaudio.c\nindex 5f65c043c16..b212b3d6022 100644\n--- a/audio/dbusaudio.c\n+++ b/audio/dbusaudio.c\n@@ -147,9 +147,9 @@ dbus_init_out_listener(QemuDBusDisplay1AudioOutListener *listener,\n     qemu_dbus_display1_audio_out_listener_call_init(\n         listener,\n         (uintptr_t)hw,\n-        hw->info.bits,\n-        hw->info.is_signed,\n-        hw->info.is_float,\n+        audio_format_bits(hw->info.af),\n+        audio_format_is_signed(hw->info.af),\n+        audio_format_is_float(hw->info.af),\n         hw->info.freq,\n         hw->info.nchannels,\n         hw->info.bytes_per_frame,\n@@ -273,9 +273,9 @@ dbus_init_in_listener(QemuDBusDisplay1AudioInListener *listener, HWVoiceIn *hw)\n     qemu_dbus_display1_audio_in_listener_call_init(\n         listener,\n         (uintptr_t)hw,\n-        hw->info.bits,\n-        hw->info.is_signed,\n-        hw->info.is_float,\n+        audio_format_bits(hw->info.af),\n+        audio_format_is_signed(hw->info.af),\n+        audio_format_is_float(hw->info.af),\n         hw->info.freq,\n         hw->info.nchannels,\n         hw->info.bytes_per_frame,\ndiff --git a/audio/coreaudio.m b/audio/coreaudio.m\nindex 0c0e8583c89..1f4b3d9d467 100644\n--- a/audio/coreaudio.m\n+++ b/audio/coreaudio.m\n@@ -359,7 +359,7 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)\n     AudioValueRange frameRange;\n \n     AudioStreamBasicDescription streamBasicDescription = {\n-        .mBitsPerChannel = core->hw.info.bits,\n+        .mBitsPerChannel = audio_format_bits(core->hw.info.af),\n         .mBytesPerFrame = core->hw.info.bytes_per_frame,\n         .mBytesPerPacket = core->hw.info.bytes_per_frame,\n         .mChannelsPerFrame = core->hw.info.nchannels,\n",
    "prefixes": [
        "72/85"
    ]
}