audio: replace int endianness with bool big_endian in audsettings
The endianness field used an int to represent a boolean concept, with 0 meaning little-endian and 1 meaning big-endian. This required runtime validation to reject invalid values and made the code less readable. Replace with a bool big_endian field that is self-documenting and type-safe. The compiler now enforces valid values, eliminating the need for the validation check in audio_validate_settings(). Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Jan 20, 2026 at 23:43 UTC
eebba32fe5240a1e21c26f2c7440923ee291bee6
28 files changed
+90
-103
audio/alsaaudio.c
+4
-4
@@ -666,7 +666,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as)
666
struct audsettings obt_as;
667
Audiodev *dev = hw->s->dev;
668
669
- req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
669
+ req.fmt = aud_to_alsafmt (as->fmt, as->big_endian);
670
req.freq = as->freq;
671
req.nchannels = as->nchannels;
672
@@ -677,7 +677,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as)
677
obt_as.freq = obt.freq;
678
obt_as.nchannels = obt.nchannels;
679
obt_as.fmt = obt.fmt;
680
- obt_as.endianness = obt.endianness;
680
+ obt_as.big_endian = obt.endianness;
681
682
audio_pcm_init_info (&hw->info, &obt_as);
683
hw->samples = obt.samples;
@@ -752,7 +752,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as)
752
struct audsettings obt_as;
753
Audiodev *dev = hw->s->dev;
754
755
- req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
755
+ req.fmt = aud_to_alsafmt (as->fmt, as->big_endian);
756
req.freq = as->freq;
757
req.nchannels = as->nchannels;
758
@@ -763,7 +763,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as)
763
obt_as.freq = obt.freq;
764
obt_as.nchannels = obt.nchannels;
765
obt_as.fmt = obt.fmt;
766
- obt_as.endianness = obt.endianness;
766
+ obt_as.big_endian = obt.endianness;
767
768
audio_pcm_init_info (&hw->info, &obt_as);
769
hw->samples = obt.samples;
audio/audio-mixeng-be.c
+4
-17
@@ -135,19 +135,7 @@ static void audio_print_settings (const struct audsettings *as)
135
break;
136
}
137
138
- AUD_log (NULL, " endianness=");
139
- switch (as->endianness) {
140
- case 0:
141
- AUD_log (NULL, "little");
142
- break;
143
- case 1:
144
- AUD_log (NULL, "big");
145
- break;
146
- default:
147
- AUD_log (NULL, "invalid");
148
- break;
149
- }
150
- AUD_log (NULL, "\n");
138
+ AUD_log (NULL, " endianness=%s\n", as->big_endian ? "big" : "little");
139
}
140
141
static int audio_validate_settings (const struct audsettings *as)
@@ -155,7 +143,6 @@ static int audio_validate_settings (const struct audsettings *as)
143
int invalid;
144
145
invalid = as->nchannels < 1;
158
- invalid |= as->endianness != 0 && as->endianness != 1;
146
147
switch (as->fmt) {
148
case AUDIO_FORMAT_S8:
@@ -180,7 +167,7 @@ static int audio_pcm_info_eq (struct audio_pcm_info *info, const struct audsetti
167
return info->af == as->fmt
168
&& info->freq == as->freq
169
&& info->nchannels == as->nchannels
183
- && info->swap_endianness == (as->endianness != HOST_BIG_ENDIAN);
170
+ && info->swap_endianness == (as->big_endian != HOST_BIG_ENDIAN);
171
}
172
173
void audio_pcm_init_info (struct audio_pcm_info *info, const struct audsettings *as)
@@ -190,7 +177,7 @@ void audio_pcm_init_info (struct audio_pcm_info *info, const struct audsettings
177
info->nchannels = as->nchannels;
178
info->bytes_per_frame = as->nchannels * audio_format_bits(as->fmt) / 8;
179
info->bytes_per_second = info->freq * info->bytes_per_frame;
193
- info->swap_endianness = (as->endianness != HOST_BIG_ENDIAN);
180
+ info->swap_endianness = (as->big_endian != HOST_BIG_ENDIAN);
181
}
182
183
void audio_pcm_info_clear_buf(struct audio_pcm_info *info, void *buf, int len)
@@ -1797,7 +1784,7 @@ audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo)
1784
.freq = pdo->frequency,
1785
.nchannels = pdo->channels,
1786
.fmt = pdo->format,
1800
- .endianness = HOST_BIG_ENDIAN,
1787
+ .big_endian = HOST_BIG_ENDIAN,
1788
};
1789
}
1790
audio/dsound_template.h
+1
-1
@@ -244,7 +244,7 @@ static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as)
244
}
245
246
ds->first_time = true;
247
- obt_as.endianness = 0;
247
+ obt_as.big_endian = false;
248
audio_pcm_init_info (&hw->info, &obt_as);
249
250
if (bc.dwBufferBytes % hw->info.bytes_per_frame) {
audio/jackaudio.c
+2
-2
@@ -531,7 +531,7 @@ static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as)
531
.freq = jo->c.freq,
532
.nchannels = jo->c.nchannels,
533
.fmt = AUDIO_FORMAT_F32,
534
- .endianness = 0
534
+ .big_endian = false
535
};
536
audio_pcm_init_info(&hw->info, &os);
537
@@ -566,7 +566,7 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as)
566
.freq = ji->c.freq,
567
.nchannels = ji->c.nchannels,
568
.fmt = AUDIO_FORMAT_F32,
569
- .endianness = 0
569
+ .big_endian = false
570
};
571
audio_pcm_init_info(&hw->info, &is);
572
audio/ossaudio.c
+11
-11
@@ -160,36 +160,36 @@ static int aud_to_ossfmt(AudioFormat fmt, bool big_endian)
160
}
161
}
162
163
-static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, int *endianness)
163
+static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, bool *big_endian)
164
{
165
switch (ossfmt) {
166
case AFMT_S8:
167
- *endianness = 0;
167
+ *big_endian = false;
168
*fmt = AUDIO_FORMAT_S8;
169
break;
170
171
case AFMT_U8:
172
- *endianness = 0;
172
+ *big_endian = false;
173
*fmt = AUDIO_FORMAT_U8;
174
break;
175
176
case AFMT_S16_LE:
177
- *endianness = 0;
177
+ *big_endian = false;
178
*fmt = AUDIO_FORMAT_S16;
179
break;
180
181
case AFMT_U16_LE:
182
- *endianness = 0;
182
+ *big_endian = false;
183
*fmt = AUDIO_FORMAT_U16;
184
break;
185
186
case AFMT_S16_BE:
187
- *endianness = 1;
187
+ *big_endian = true;
188
*fmt = AUDIO_FORMAT_S16;
189
break;
190
191
case AFMT_U16_BE:
192
- *endianness = 1;
192
+ *big_endian = true;
193
*fmt = AUDIO_FORMAT_U16;
194
break;
195
@@ -475,7 +475,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as)
475
476
oss->fd = -1;
477
478
- req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
478
+ req.fmt = aud_to_ossfmt (as->fmt, as->big_endian);
479
req.freq = as->freq;
480
req.nchannels = as->nchannels;
481
@@ -483,7 +483,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as)
483
return -1;
484
}
485
486
- err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.endianness);
486
+ err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.big_endian);
487
if (err) {
488
oss_anal_close (&fd);
489
return -1;
@@ -601,14 +601,14 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as)
601
602
oss->fd = -1;
603
604
- req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
604
+ req.fmt = aud_to_ossfmt (as->fmt, as->big_endian);
605
req.freq = as->freq;
606
req.nchannels = as->nchannels;
607
if (oss_open(1, &req, as, &obt, &fd, dev)) {
608
return -1;
609
}
610
611
- err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.endianness);
611
+ err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.big_endian);
612
if (err) {
613
oss_anal_close (&fd);
614
return -1;
audio/paaudio.c
+11
-11
@@ -352,28 +352,28 @@ static pa_sample_format_t audfmt_to_pa(AudioFormat afmt, bool big_endian)
352
return format;
353
}
354
355
-static AudioFormat pa_to_audfmt (pa_sample_format_t fmt, int *endianness)
355
+static AudioFormat pa_to_audfmt (pa_sample_format_t fmt, bool *big_endian)
356
{
357
switch (fmt) {
358
case PA_SAMPLE_U8:
359
return AUDIO_FORMAT_U8;
360
case PA_SAMPLE_S16BE:
361
- *endianness = 1;
361
+ *big_endian = true;
362
return AUDIO_FORMAT_S16;
363
case PA_SAMPLE_S16LE:
364
- *endianness = 0;
364
+ *big_endian = false;
365
return AUDIO_FORMAT_S16;
366
case PA_SAMPLE_S32BE:
367
- *endianness = 1;
367
+ *big_endian = true;
368
return AUDIO_FORMAT_S32;
369
case PA_SAMPLE_S32LE:
370
- *endianness = 0;
370
+ *big_endian = false;
371
return AUDIO_FORMAT_S32;
372
case PA_SAMPLE_FLOAT32BE:
373
- *endianness = 1;
373
+ *big_endian = true;
374
return AUDIO_FORMAT_F32;
375
case PA_SAMPLE_FLOAT32LE:
376
- *endianness = 0;
376
+ *big_endian = false;
377
return AUDIO_FORMAT_F32;
378
default:
379
error_report("pulseaudio: Internal logic error: Bad pa_sample_format %d", fmt);
@@ -531,7 +531,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as)
531
PAConnection *c = apa->conn;
532
533
pa->g = apa;
534
- ss.format = audfmt_to_pa (as->fmt, as->endianness);
534
+ ss.format = audfmt_to_pa (as->fmt, as->big_endian);
535
ss.channels = as->nchannels;
536
ss.rate = as->freq;
537
@@ -541,7 +541,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as)
541
ba.maxlength = -1;
542
ba.prebuf = -1;
543
544
- obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
544
+ obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.big_endian);
545
546
pa->stream = qpa_simple_new (
547
c,
@@ -582,7 +582,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as)
582
PAConnection *c = apa->conn;
583
584
pa->g = apa;
585
- ss.format = audfmt_to_pa (as->fmt, as->endianness);
585
+ ss.format = audfmt_to_pa (as->fmt, as->big_endian);
586
ss.channels = as->nchannels;
587
ss.rate = as->freq;
588
@@ -592,7 +592,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as)
592
ba.minreq = -1;
593
ba.prebuf = -1;
594
595
- obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
595
+ obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.big_endian);
596
597
pa->stream = qpa_simple_new (
598
c,
audio/pwaudio.c
+15
-15
@@ -365,7 +365,7 @@ audfmt_to_pw(AudioFormat fmt, bool big_endian)
365
}
366
367
static AudioFormat
368
-pw_to_audfmt(enum spa_audio_format fmt, int *endianness,
368
+pw_to_audfmt(enum spa_audio_format fmt, bool *big_endian,
369
uint32_t *sample_size)
370
{
371
switch (fmt) {
@@ -377,43 +377,43 @@ pw_to_audfmt(enum spa_audio_format fmt, int *endianness,
377
return AUDIO_FORMAT_U8;
378
case SPA_AUDIO_FORMAT_S16_BE:
379
*sample_size = 2;
380
- *endianness = 1;
380
+ *big_endian = true;
381
return AUDIO_FORMAT_S16;
382
case SPA_AUDIO_FORMAT_S16_LE:
383
*sample_size = 2;
384
- *endianness = 0;
384
+ *big_endian = false;
385
return AUDIO_FORMAT_S16;
386
case SPA_AUDIO_FORMAT_U16_BE:
387
*sample_size = 2;
388
- *endianness = 1;
388
+ *big_endian = true;
389
return AUDIO_FORMAT_U16;
390
case SPA_AUDIO_FORMAT_U16_LE:
391
*sample_size = 2;
392
- *endianness = 0;
392
+ *big_endian = false;
393
return AUDIO_FORMAT_U16;
394
case SPA_AUDIO_FORMAT_S32_BE:
395
*sample_size = 4;
396
- *endianness = 1;
396
+ *big_endian = true;
397
return AUDIO_FORMAT_S32;
398
case SPA_AUDIO_FORMAT_S32_LE:
399
*sample_size = 4;
400
- *endianness = 0;
400
+ *big_endian = false;
401
return AUDIO_FORMAT_S32;
402
case SPA_AUDIO_FORMAT_U32_BE:
403
*sample_size = 4;
404
- *endianness = 1;
404
+ *big_endian = true;
405
return AUDIO_FORMAT_U32;
406
case SPA_AUDIO_FORMAT_U32_LE:
407
*sample_size = 4;
408
- *endianness = 0;
408
+ *big_endian = false;
409
return AUDIO_FORMAT_U32;
410
case SPA_AUDIO_FORMAT_F32_BE:
411
*sample_size = 4;
412
- *endianness = 1;
412
+ *big_endian = true;
413
return AUDIO_FORMAT_F32;
414
case SPA_AUDIO_FORMAT_F32_LE:
415
*sample_size = 4;
416
- *endianness = 0;
416
+ *big_endian = false;
417
return AUDIO_FORMAT_F32;
418
default:
419
*sample_size = 1;
@@ -534,13 +534,13 @@ qpw_init_out(HWVoiceOut *hw, struct audsettings *as)
534
535
pw_thread_loop_lock(c->thread_loop);
536
537
- v->info.format = audfmt_to_pw(as->fmt, as->endianness);
537
+ v->info.format = audfmt_to_pw(as->fmt, as->big_endian);
538
v->info.channels = as->nchannels;
539
qpw_set_position(as->nchannels, v->info.position);
540
v->info.rate = as->freq;
541
542
obt_as.fmt =
543
- pw_to_audfmt(v->info.format, &obt_as.endianness, &v->frame_size);
543
+ pw_to_audfmt(v->info.format, &obt_as.big_endian, &v->frame_size);
544
v->frame_size *= as->nchannels;
545
546
v->req = (uint64_t)AUDIO_MIXENG_BACKEND(c)->dev->timer_period * v->info.rate
@@ -581,13 +581,13 @@ qpw_init_in(HWVoiceIn *hw, struct audsettings *as)
581
582
pw_thread_loop_lock(c->thread_loop);
583
584
- v->info.format = audfmt_to_pw(as->fmt, as->endianness);
584
+ v->info.format = audfmt_to_pw(as->fmt, as->big_endian);
585
v->info.channels = as->nchannels;
586
qpw_set_position(as->nchannels, v->info.position);
587
v->info.rate = as->freq;
588
589
obt_as.fmt =
590
- pw_to_audfmt(v->info.format, &obt_as.endianness, &v->frame_size);
590
+ pw_to_audfmt(v->info.format, &obt_as.big_endian, &v->frame_size);
591
v->frame_size *= as->nchannels;
592
593
/* call the function that creates a new stream for recording */
audio/sdlaudio.c
+13
-13
@@ -96,56 +96,56 @@ static int aud_to_sdlfmt (AudioFormat fmt)
96
}
97
}
98
99
-static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, int *endianness)
99
+static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, bool *big_endian)
100
{
101
switch (sdlfmt) {
102
case AUDIO_S8:
103
- *endianness = 0;
103
+ *big_endian = false;
104
*fmt = AUDIO_FORMAT_S8;
105
break;
106
107
case AUDIO_U8:
108
- *endianness = 0;
108
+ *big_endian = false;
109
*fmt = AUDIO_FORMAT_U8;
110
break;
111
112
case AUDIO_S16LSB:
113
- *endianness = 0;
113
+ *big_endian = false;
114
*fmt = AUDIO_FORMAT_S16;
115
break;
116
117
case AUDIO_U16LSB:
118
- *endianness = 0;
118
+ *big_endian = false;
119
*fmt = AUDIO_FORMAT_U16;
120
break;
121
122
case AUDIO_S16MSB:
123
- *endianness = 1;
123
+ *big_endian = true;
124
*fmt = AUDIO_FORMAT_S16;
125
break;
126
127
case AUDIO_U16MSB:
128
- *endianness = 1;
128
+ *big_endian = true;
129
*fmt = AUDIO_FORMAT_U16;
130
break;
131
132
case AUDIO_S32LSB:
133
- *endianness = 0;
133
+ *big_endian = false;
134
*fmt = AUDIO_FORMAT_S32;
135
break;
136
137
case AUDIO_S32MSB:
138
- *endianness = 1;
138
+ *big_endian = true;
139
*fmt = AUDIO_FORMAT_S32;
140
break;
141
142
case AUDIO_F32LSB:
143
- *endianness = 0;
143
+ *big_endian = false;
144
*fmt = AUDIO_FORMAT_F32;
145
break;
146
147
case AUDIO_F32MSB:
148
- *endianness = 1;
148
+ *big_endian = true;
149
*fmt = AUDIO_FORMAT_F32;
150
break;
151
@@ -350,7 +350,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as)
350
return -1;
351
}
352
353
- err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.endianness);
353
+ err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.big_endian);
354
if (err) {
355
sdl_close_out(sdl);
356
return -1;
@@ -406,7 +406,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as)
406
return -1;
407
}
408
409
- err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.endianness);
409
+ err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.big_endian);
410
if (err) {
411
sdl_close_in(sdl);
412
return -1;
audio/sndioaudio.c
+1
-1
@@ -387,7 +387,7 @@ static int sndio_init(SndioVoice *self,
387
}
388
389
if (req.bits > 8) {
390
- req.le = as->endianness ? 0 : 1;
390
+ req.le = !as->big_endian;
391
}
392
393
req.rate = as->freq;
audio/spiceaudio.c
+2
-2
@@ -106,7 +106,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as)
106
#endif
107
settings.nchannels = SPICE_INTERFACE_PLAYBACK_CHAN;
108
settings.fmt = AUDIO_FORMAT_S16;
109
- settings.endianness = HOST_BIG_ENDIAN;
109
+ settings.big_endian = HOST_BIG_ENDIAN;
110
111
audio_pcm_init_info (&hw->info, &settings);
112
hw->samples = LINE_OUT_SAMPLES;
@@ -222,7 +222,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as)
222
#endif
223
settings.nchannels = SPICE_INTERFACE_RECORD_CHAN;
224
settings.fmt = AUDIO_FORMAT_S16;
225
- settings.endianness = HOST_BIG_ENDIAN;
225
+ settings.big_endian = HOST_BIG_ENDIAN;
226
227
audio_pcm_init_info (&hw->info, &settings);
228
hw->samples = LINE_IN_SAMPLES;
audio/wavaudio.c
+1
-1
@@ -111,7 +111,7 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as)
111
112
hdr[34] = bits16 ? 0x10 : 0x08;
113
114
- wav_as.endianness = 0;
114
+ wav_as.big_endian = false;
115
audio_pcm_init_info (&hw->info, &wav_as);
116
117
hw->samples = 1024;
audio/wavcapture.c
+1
-1
@@ -137,7 +137,7 @@ int wav_start_capture(AudioBackend *state, CaptureState *s, const char *path,
137
as.freq = freq;
138
as.nchannels = 1 << stereo;
139
as.fmt = bits16 ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_U8;
140
- as.endianness = 0;
140
+ as.big_endian = false;
141
142
ops.notify = wav_notify;
143
ops.capture = wav_capture;
hw/audio/ac97.c
+1
-1
@@ -313,7 +313,7 @@ static void open_voice(AC97LinkState *s, int index, int freq)
313
as.freq = freq;
314
as.nchannels = 2;
315
as.fmt = AUDIO_FORMAT_S16;
316
- as.endianness = 0;
316
+ as.big_endian = false;
317
318
if (freq > 0) {
319
s->invalid_freq[index] = 0;
hw/audio/adlib.c
+1
-1
@@ -254,7 +254,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp)
254
as.freq = s->freq;
255
as.nchannels = SHIFT;
256
as.fmt = AUDIO_FORMAT_S16;
257
- as.endianness = HOST_BIG_ENDIAN;
257
+ as.big_endian = HOST_BIG_ENDIAN;
258
259
s->voice = audio_be_open_out(
260
s->audio_be,
hw/audio/asc.c
+1
-1
@@ -648,7 +648,7 @@ static void asc_realize(DeviceState *dev, Error **errp)
648
as.freq = ASC_FREQ;
649
as.nchannels = 2;
650
as.fmt = AUDIO_FORMAT_U8;
651
- as.endianness = HOST_BIG_ENDIAN;
651
+ as.big_endian = HOST_BIG_ENDIAN;
652
653
s->voice = audio_be_open_out(s->audio_be, s->voice, "asc.out", s, asc_out_cb,
654
&as);
hw/audio/cs4231a.c
+3
-3
@@ -289,7 +289,7 @@ static void cs_reset_voices (CSState *s, uint32_t val)
289
}
290
291
as.nchannels = (val & (1 << 4)) ? 2 : 1;
292
- as.endianness = 0;
292
+ as.big_endian = false;
293
s->tab = NULL;
294
295
switch ((val >> 5) & ((s->dregs[MODE_And_ID] & MODE2) ? 7 : 3)) {
@@ -305,12 +305,12 @@ static void cs_reset_voices (CSState *s, uint32_t val)
305
s->tab = ALawDecompressTable;
306
x_law:
307
as.fmt = AUDIO_FORMAT_S16;
308
- as.endianness = HOST_BIG_ENDIAN;
308
+ as.big_endian = HOST_BIG_ENDIAN;
309
s->shift = as.nchannels == 2;
310
break;
311
312
case 6:
313
- as.endianness = 1;
313
+ as.big_endian = true;
314
/* fall through */
315
case 2:
316
as.fmt = AUDIO_FORMAT_S16;
hw/audio/es1370.c
+1
-1
@@ -407,7 +407,7 @@ static void es1370_update_voices (ES1370State *s, uint32_t ctl, uint32_t sctl)
407
as.freq = new_freq;
408
as.nchannels = 1 << (new_fmt & 1);
409
as.fmt = (new_fmt & 2) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_U8;
410
- as.endianness = 0;
410
+ as.big_endian = false;
411
412
if (i == ADC_CHANNEL) {
413
s->adc_voice =
hw/audio/gus.c
+1
-1
@@ -256,7 +256,7 @@ static void gus_realizefn (DeviceState *dev, Error **errp)
256
as.freq = s->freq;
257
as.nchannels = 2;
258
as.fmt = AUDIO_FORMAT_S16;
259
- as.endianness = HOST_BIG_ENDIAN;
259
+ as.big_endian = HOST_BIG_ENDIAN;
260
261
s->voice = audio_be_open_out(
262
s->audio_be,
hw/audio/lm4549.c
+3
-3
@@ -202,7 +202,7 @@ void lm4549_write(lm4549_state *s,
202
as.freq = value;
203
as.nchannels = 2;
204
as.fmt = AUDIO_FORMAT_S16;
205
- as.endianness = 0;
205
+ as.big_endian = false;
206
207
s->voice = audio_be_open_out(
208
s->audio_be,
@@ -272,7 +272,7 @@ static int lm4549_post_load(void *opaque, int version_id)
272
as.freq = freq;
273
as.nchannels = 2;
274
as.fmt = AUDIO_FORMAT_S16;
275
- as.endianness = 0;
275
+ as.big_endian = false;
276
277
s->voice = audio_be_open_out(
278
s->audio_be,
@@ -312,7 +312,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_req_cb, void* opaque,
312
as.freq = 48000;
313
as.nchannels = 2;
314
as.fmt = AUDIO_FORMAT_S16;
315
- as.endianness = 0;
315
+ as.big_endian = false;
316
317
s->voice = audio_be_open_out(
318
s->audio_be,
hw/audio/sb16.c
+4
-4
@@ -213,7 +213,7 @@ static void continue_dma8 (SB16State *s)
213
as.freq = s->freq;
214
as.nchannels = 1 << s->fmt_stereo;
215
as.fmt = s->fmt;
216
- as.endianness = 0;
216
+ as.big_endian = false;
217
218
s->voice = audio_be_open_out(
219
s->audio_be,
@@ -376,7 +376,7 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, int dma_len)
376
as.freq = s->freq;
377
as.nchannels = 1 << s->fmt_stereo;
378
as.fmt = s->fmt;
379
- as.endianness = 0;
379
+ as.big_endian = false;
380
381
s->voice = audio_be_open_out(
382
s->audio_be,
@@ -877,7 +877,7 @@ static void legacy_reset (SB16State *s)
877
as.freq = s->freq;
878
as.nchannels = 1;
879
as.fmt = AUDIO_FORMAT_U8;
880
- as.endianness = 0;
880
+ as.big_endian = false;
881
882
s->voice = audio_be_open_out(
883
s->audio_be,
@@ -1300,7 +1300,7 @@ static int sb16_post_load (void *opaque, int version_id)
1300
as.freq = s->freq;
1301
as.nchannels = 1 << s->fmt_stereo;
1302
as.fmt = s->fmt;
1303
- as.endianness = 0;
1303
+ as.big_endian = false;
1304
1305
s->voice = audio_be_open_out(
1306
s->audio_be,
hw/audio/via-ac97.c
+1
-1
@@ -237,7 +237,7 @@ static void open_voice_out(ViaAC97State *s)
237
.freq = CODEC_REG(s, AC97_PCM_Front_DAC_Rate),
238
.nchannels = s->aur.type & BIT(4) ? 2 : 1,
239
.fmt = s->aur.type & BIT(5) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_S8,
240
- .endianness = 0,
240
+ .big_endian = false,
241
};
242
s->vo = audio_be_open_out(s->audio_be, s->vo, "via-ac97.out", s, out_cb, &as);
243
}
hw/audio/virtio-snd.c
+1
-1
@@ -389,7 +389,7 @@ static void virtio_snd_get_qemu_audsettings(audsettings *as,
389
as->nchannels = MIN(AUDIO_MAX_CHANNELS, params->channels);
390
as->fmt = virtio_snd_get_qemu_format(params->format);
391
as->freq = virtio_snd_get_qemu_freq(params->rate);
392
- as->endianness = 0; /* Conforming to VIRTIO 1.0: always little endian. */
392
+ as->big_endian = false; /* Conforming to VIRTIO 1.0: always little endian. */
393
}
394
395
/*
hw/audio/wm8750.c
+2
-2
@@ -202,7 +202,7 @@ static void wm8750_set_format(WM8750State *s)
202
return;
203
204
/* Setup input */
205
- in_fmt.endianness = 0;
205
+ in_fmt.big_endian = false;
206
in_fmt.nchannels = 2;
207
in_fmt.freq = s->adc_hz;
208
in_fmt.fmt = AUDIO_FORMAT_S16;
@@ -215,7 +215,7 @@ static void wm8750_set_format(WM8750State *s)
215
CODEC ".input3", s, wm8750_audio_in_cb, &in_fmt);
216
217
/* Setup output */
218
- out_fmt.endianness = 0;
218
+ out_fmt.big_endian = false;
219
out_fmt.nchannels = 2;
220
out_fmt.freq = s->dac_hz;
221
out_fmt.fmt = AUDIO_FORMAT_S16;
hw/display/xlnx_dp.c
+1
-1
@@ -1393,7 +1393,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error **errp)
1393
as.freq = 44100;
1394
as.nchannels = 2;
1395
as.fmt = AUDIO_FORMAT_S16;
1396
- as.endianness = 0;
1396
+ as.big_endian = false;
1397
1398
s->amixer_output_stream = audio_be_open_out(s->audio_be,
1399
s->amixer_output_stream,
hw/usb/dev-audio.c
+1
-1
@@ -975,7 +975,7 @@ static void usb_audio_reinit(USBDevice *dev, unsigned channels)
975
s->out.as.freq = USBAUDIO_SAMPLE_RATE;
976
s->out.as.nchannels = s->out.channels;
977
s->out.as.fmt = AUDIO_FORMAT_S16;
978
- s->out.as.endianness = 0;
978
+ s->out.as.big_endian = false;
979
streambuf_init(&s->out.buf, s->buffer, s->out.channels);
980
981
s->out.voice = audio_be_open_out(s->audio_be, s->out.voice, TYPE_USB_AUDIO,
include/qemu/audio.h
+1
-1
@@ -38,7 +38,7 @@ typedef struct audsettings {
38
int freq;
39
int nchannels;
40
AudioFormat fmt;
41
- int endianness;
41
+ bool big_endian;
42
} audsettings;
43
44
typedef struct SWVoiceOut SWVoiceOut;
tests/audio/test-audio.c
+1
-1
@@ -57,7 +57,7 @@ static const struct audsettings default_test_settings = {
57
.freq = SAMPLE_RATE,
58
.nchannels = CHANNELS,
59
.fmt = AUDIO_FORMAT_S16,
60
- .endianness = 0,
60
+ .big_endian = false,
61
};
62
63
static void dummy_audio_callback(void *opaque, int avail)
ui/vnc.c
+1
-1
@@ -3372,7 +3372,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc,
3372
vs->as.freq = 44100;
3373
vs->as.nchannels = 2;
3374
vs->as.fmt = AUDIO_FORMAT_S16;
3375
- vs->as.endianness = 0;
3375
+ vs->as.big_endian = false;
3376
3377
qemu_mutex_init(&vs->output_mutex);
3378
vs->bh = qemu_bh_new(vnc_jobs_bh, vs);