qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Thomas Huth" <huth@tuxfamily.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v2 44/42] audio: Rename @endianness argument as @big_endian for clarity
Date: Wed, 22 Oct 2025 09:53:52 +0200	[thread overview]
Message-ID: <20251022075352.66756-2-philmd@linaro.org> (raw)
In-Reply-To: <20251022065640.1172785-1-marcandre.lureau@redhat.com>

@endianness is used as a boolean, rename for clarity.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 audio/alsaaudio.c | 32 ++++++--------------------------
 audio/ossaudio.c  | 14 +++-----------
 audio/paaudio.c   |  8 ++++----
 audio/pwaudio.c   | 12 ++++++------
 4 files changed, 19 insertions(+), 47 deletions(-)

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 89f6dad1a97..7d7da576dc9 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -264,7 +264,7 @@ static int alsa_poll_in (HWVoiceIn *hw)
     return alsa_poll_helper (alsa->handle, &alsa->pollhlp, POLLIN);
 }
 
-static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness)
+static snd_pcm_format_t aud_to_alsafmt(AudioFormat fmt, bool big_endian)
 {
     switch (fmt) {
     case AUDIO_FORMAT_S8:
@@ -274,39 +274,19 @@ static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness)
         return SND_PCM_FORMAT_U8;
 
     case AUDIO_FORMAT_S16:
-        if (endianness) {
-            return SND_PCM_FORMAT_S16_BE;
-        } else {
-            return SND_PCM_FORMAT_S16_LE;
-        }
+        return big_endian ? SND_PCM_FORMAT_S16_BE : SND_PCM_FORMAT_S16_LE;
 
     case AUDIO_FORMAT_U16:
-        if (endianness) {
-            return SND_PCM_FORMAT_U16_BE;
-        } else {
-            return SND_PCM_FORMAT_U16_LE;
-        }
+        return big_endian ? SND_PCM_FORMAT_U16_BE : SND_PCM_FORMAT_U16_LE;
 
     case AUDIO_FORMAT_S32:
-        if (endianness) {
-            return SND_PCM_FORMAT_S32_BE;
-        } else {
-            return SND_PCM_FORMAT_S32_LE;
-        }
+        return big_endian ? SND_PCM_FORMAT_S32_BE : SND_PCM_FORMAT_S32_LE;
 
     case AUDIO_FORMAT_U32:
-        if (endianness) {
-            return SND_PCM_FORMAT_U32_BE;
-        } else {
-            return SND_PCM_FORMAT_U32_LE;
-        }
+        return big_endian ? SND_PCM_FORMAT_U32_BE : SND_PCM_FORMAT_U32_LE;
 
     case AUDIO_FORMAT_F32:
-        if (endianness) {
-            return SND_PCM_FORMAT_FLOAT_BE;
-        } else {
-            return SND_PCM_FORMAT_FLOAT_LE;
-        }
+        return big_endian ? SND_PCM_FORMAT_FLOAT_BE : SND_PCM_FORMAT_FLOAT_LE;
 
     default:
         dolog ("Internal logic error: Bad audio format %d\n", fmt);
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 86c4805675e..c6cad47a015 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -131,7 +131,7 @@ static void oss_poll_in (HWVoiceIn *hw)
     qemu_set_fd_handler(oss->fd, oss_helper_poll_in, NULL, hw->s);
 }
 
-static int aud_to_ossfmt (AudioFormat fmt, int endianness)
+static int aud_to_ossfmt(AudioFormat fmt, bool big_endian)
 {
     switch (fmt) {
     case AUDIO_FORMAT_S8:
@@ -141,18 +141,10 @@ static int aud_to_ossfmt (AudioFormat fmt, int endianness)
         return AFMT_U8;
 
     case AUDIO_FORMAT_S16:
-        if (endianness) {
-            return AFMT_S16_BE;
-        } else {
-            return AFMT_S16_LE;
-        }
+        return big_endian ? AFMT_S16_BE : AFMT_S16_LE;
 
     case AUDIO_FORMAT_U16:
-        if (endianness) {
-            return AFMT_U16_BE;
-        } else {
-            return AFMT_U16_LE;
-        }
+        return big_endian ? AFMT_U16_BE : AFMT_U16_LE;
 
     default:
         dolog ("Internal logic error: Bad audio format %d\n", fmt);
diff --git a/audio/paaudio.c b/audio/paaudio.c
index 6b9b6d219ab..0c06a397195 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -316,7 +316,7 @@ unlock_and_fail:
     return 0;
 }
 
-static pa_sample_format_t audfmt_to_pa (AudioFormat afmt, int endianness)
+static pa_sample_format_t audfmt_to_pa(AudioFormat afmt, bool big_endian)
 {
     int format;
 
@@ -327,14 +327,14 @@ static pa_sample_format_t audfmt_to_pa (AudioFormat afmt, int endianness)
         break;
     case AUDIO_FORMAT_S16:
     case AUDIO_FORMAT_U16:
-        format = endianness ? PA_SAMPLE_S16BE : PA_SAMPLE_S16LE;
+        format = big_endian ? PA_SAMPLE_S16BE : PA_SAMPLE_S16LE;
         break;
     case AUDIO_FORMAT_S32:
     case AUDIO_FORMAT_U32:
-        format = endianness ? PA_SAMPLE_S32BE : PA_SAMPLE_S32LE;
+        format = big_endian ? PA_SAMPLE_S32BE : PA_SAMPLE_S32LE;
         break;
     case AUDIO_FORMAT_F32:
-        format = endianness ? PA_SAMPLE_FLOAT32BE : PA_SAMPLE_FLOAT32LE;
+        format = big_endian ? PA_SAMPLE_FLOAT32BE : PA_SAMPLE_FLOAT32LE;
         break;
     default:
         dolog ("Internal logic error: Bad audio format %d\n", afmt);
diff --git a/audio/pwaudio.c b/audio/pwaudio.c
index 0fd59d9fe60..30f717ccacf 100644
--- a/audio/pwaudio.c
+++ b/audio/pwaudio.c
@@ -324,7 +324,7 @@ done_unlock:
 }
 
 static int
-audfmt_to_pw(AudioFormat fmt, int endianness)
+audfmt_to_pw(AudioFormat fmt, bool big_endian)
 {
     int format;
 
@@ -336,19 +336,19 @@ audfmt_to_pw(AudioFormat fmt, int endianness)
         format = SPA_AUDIO_FORMAT_U8;
         break;
     case AUDIO_FORMAT_S16:
-        format = endianness ? SPA_AUDIO_FORMAT_S16_BE : SPA_AUDIO_FORMAT_S16_LE;
+        format = big_endian ? SPA_AUDIO_FORMAT_S16_BE : SPA_AUDIO_FORMAT_S16_LE;
         break;
     case AUDIO_FORMAT_U16:
-        format = endianness ? SPA_AUDIO_FORMAT_U16_BE : SPA_AUDIO_FORMAT_U16_LE;
+        format = big_endian ? SPA_AUDIO_FORMAT_U16_BE : SPA_AUDIO_FORMAT_U16_LE;
         break;
     case AUDIO_FORMAT_S32:
-        format = endianness ? SPA_AUDIO_FORMAT_S32_BE : SPA_AUDIO_FORMAT_S32_LE;
+        format = big_endian ? SPA_AUDIO_FORMAT_S32_BE : SPA_AUDIO_FORMAT_S32_LE;
         break;
     case AUDIO_FORMAT_U32:
-        format = endianness ? SPA_AUDIO_FORMAT_U32_BE : SPA_AUDIO_FORMAT_U32_LE;
+        format = big_endian ? SPA_AUDIO_FORMAT_U32_BE : SPA_AUDIO_FORMAT_U32_LE;
         break;
     case AUDIO_FORMAT_F32:
-        format = endianness ? SPA_AUDIO_FORMAT_F32_BE : SPA_AUDIO_FORMAT_F32_LE;
+        format = big_endian ? SPA_AUDIO_FORMAT_F32_BE : SPA_AUDIO_FORMAT_F32_LE;
         break;
     default:
         dolog("Internal logic error: Bad audio format %d\n", fmt);
-- 
2.51.0



  parent reply	other threads:[~2025-10-22  7:54 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  6:55 [PATCH v2 00/42] Audio clean-ups marcandre.lureau
2025-10-22  6:55 ` [PATCH v2 01/42] hw/audio: improve error reports marcandre.lureau
2025-10-22  6:55 ` [PATCH v2 02/42] hw/audio: rename model list function marcandre.lureau
2025-10-22  6:55 ` [PATCH v2 03/42] hw/audio: remove global pcspk marcandre.lureau
2025-10-22  6:55 ` [PATCH v2 04/42] hw/pcspk: use explicitly the required PIT types marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 05/42] hw/pcspk: make 'pit' a class property marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 06/42] hw/pcspk: check the "pit" is set marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 07/42] docs: update -soundhw -> -device list marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 08/42] qdev: add qdev_find_default_bus() marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 09/42] hw/audio: look up the default bus from the device class marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 10/42] audio: rename audio_define->audio_add_audiodev() marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 11/42] hw/audio: use better naming for -audio model handling code marcandre.lureau
2025-10-22  8:04   ` Philippe Mathieu-Daudé
2025-10-22  6:56 ` [PATCH v2 12/42] hw/audio/virtio-snd-pci: remove custom model callback marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 13/42] hw/audio: simplify 'hda' audio init code marcandre.lureau
2025-10-22 11:41   ` BALATON Zoltan
2025-10-22 11:49     ` Marc-André Lureau
2025-10-22  6:56 ` [PATCH v2 14/42] hw/audio: generalize audio_model.init() marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 15/42] hw/audio: drop audio_model.isa marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 16/42] audio: start making AudioState a QOM Object marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 17/42] audio: register backends in /audiodevs container marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 18/42] audio: use /audiodevs QOM container marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 19/42] audio/paaudio: remove needless return value marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 20/42] audio/dsound: simplify init() marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 21/42] audio/dsound: report init error via **errp marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 22/42] audio: simplify audio_driver_init() marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 23/42] audio: move period tick initialization marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 24/42] audio: drop needless error message marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 25/42] audio: clean-up vmstate change handler on finalize marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 26/42] audio: unregister vmstate description marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 27/42] audio: initialize card_head during object init marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 28/42] audio: remove some needless headers marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 29/42] audio: remove AUDIO_HOST_ENDIANNESS marcandre.lureau
2025-10-22  7:11   ` Philippe Mathieu-Daudé
2025-10-22  6:56 ` [PATCH v2 30/42] audio: introduce AUD_set_volume_{in,out}_lr() marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 31/42] hw/audio: replace AUD_log() usage marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 32/42] audio/replay: fix type punning marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 33/42] audio: move internal APIs to audio_int.h marcandre.lureau
2025-10-22  7:08   ` Philippe Mathieu-Daudé
2025-10-22  6:56 ` [PATCH v2 34/42] audio: rename AudioState -> AudioBackend marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 35/42] audio: remove QEMUSoundCard marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 36/42] audio/dbus: use a helper function to set the backend dbus server marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 37/42] audio: move audio.h under include/qemu/ marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 38/42] audio: remove dependency on spice header marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 39/42] audio: cleanup, use bool for booleans marcandre.lureau
2025-10-22  7:05   ` Philippe Mathieu-Daudé
2025-10-22 12:01   ` BALATON Zoltan
2025-10-22  6:56 ` [PATCH v2 40/42] audio: move capture API to own header marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 41/42] audio: drop needless audio_driver "descr" field marcandre.lureau
2025-10-22  6:56 ` [PATCH v2 42/42] docs: Update mentions of removed '-soundhw' command line option marcandre.lureau
2025-10-22  7:53 ` [PATCH v2 43/42] audio: Remove pointless local variables Philippe Mathieu-Daudé
2025-10-22  7:56   ` Marc-André Lureau
2025-10-22  7:53 ` Philippe Mathieu-Daudé [this message]
2025-10-22  7:59   ` [PATCH v2 44/42] audio: Rename @endianness argument as @big_endian for clarity Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251022075352.66756-2-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=huth@tuxfamily.org \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).