Commit d929eba5d47f097302779d55427712c3ceb931ad
1 parent
219fb125
audio endianness API changes (malc)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2042 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
17 changed files
with
85 additions
and
109 deletions
audio/alsaaudio.c
| ... | ... | @@ -662,12 +662,9 @@ static int alsa_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 662 | 662 | obt_as.freq = obt.freq; |
| 663 | 663 | obt_as.nchannels = obt.nchannels; |
| 664 | 664 | obt_as.fmt = effective_fmt; |
| 665 | + obt_as.endianness = endianness; | |
| 665 | 666 | |
| 666 | - audio_pcm_init_info ( | |
| 667 | - &hw->info, | |
| 668 | - &obt_as, | |
| 669 | - audio_need_to_swap_endian (endianness) | |
| 670 | - ); | |
| 667 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 671 | 668 | hw->samples = obt.samples; |
| 672 | 669 | |
| 673 | 670 | alsa->pcm_buf = audio_calloc (AUDIO_FUNC, obt.samples, 1 << hw->info.shift); |
| ... | ... | @@ -751,12 +748,9 @@ static int alsa_init_in (HWVoiceIn *hw, audsettings_t *as) |
| 751 | 748 | obt_as.freq = obt.freq; |
| 752 | 749 | obt_as.nchannels = obt.nchannels; |
| 753 | 750 | obt_as.fmt = effective_fmt; |
| 751 | + obt_as.endianness = endianness; | |
| 754 | 752 | |
| 755 | - audio_pcm_init_info ( | |
| 756 | - &hw->info, | |
| 757 | - &obt_as, | |
| 758 | - audio_need_to_swap_endian (endianness) | |
| 759 | - ); | |
| 753 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 760 | 754 | hw->samples = obt.samples; |
| 761 | 755 | |
| 762 | 756 | alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); | ... | ... |
audio/audio.c
| ... | ... | @@ -510,6 +510,18 @@ static void audio_print_settings (audsettings_t *as) |
| 510 | 510 | AUD_log (NULL, "invalid(%d)", as->fmt); |
| 511 | 511 | break; |
| 512 | 512 | } |
| 513 | + AUD_log (NULL, "endianness="); | |
| 514 | + switch (as->endianness) { | |
| 515 | + case 0: | |
| 516 | + AUD_log (NULL, "little"); | |
| 517 | + break; | |
| 518 | + case 1: | |
| 519 | + AUD_log (NULL, "big"); | |
| 520 | + break; | |
| 521 | + default: | |
| 522 | + AUD_log (NULL, "invalid"); | |
| 523 | + break; | |
| 524 | + } | |
| 513 | 525 | AUD_log (NULL, "\n"); |
| 514 | 526 | } |
| 515 | 527 | |
| ... | ... | @@ -518,6 +530,7 @@ static int audio_validate_settigs (audsettings_t *as) |
| 518 | 530 | int invalid; |
| 519 | 531 | |
| 520 | 532 | invalid = as->nchannels != 1 && as->nchannels != 2; |
| 533 | + invalid |= as->endianness != 0 && as->endianness != 1; | |
| 521 | 534 | |
| 522 | 535 | switch (as->fmt) { |
| 523 | 536 | case AUD_FMT_S8: |
| ... | ... | @@ -531,11 +544,7 @@ static int audio_validate_settigs (audsettings_t *as) |
| 531 | 544 | } |
| 532 | 545 | |
| 533 | 546 | invalid |= as->freq <= 0; |
| 534 | - | |
| 535 | - if (invalid) { | |
| 536 | - return -1; | |
| 537 | - } | |
| 538 | - return 0; | |
| 547 | + return invalid ? -1 : 0; | |
| 539 | 548 | } |
| 540 | 549 | |
| 541 | 550 | static int audio_pcm_info_eq (struct audio_pcm_info *info, audsettings_t *as) |
| ... | ... | @@ -557,14 +566,11 @@ static int audio_pcm_info_eq (struct audio_pcm_info *info, audsettings_t *as) |
| 557 | 566 | return info->freq == as->freq |
| 558 | 567 | && info->nchannels == as->nchannels |
| 559 | 568 | && info->sign == sign |
| 560 | - && info->bits == bits; | |
| 569 | + && info->bits == bits | |
| 570 | + && info->swap_endianness == (as->endianness != AUDIO_HOST_ENDIANNESS); | |
| 561 | 571 | } |
| 562 | 572 | |
| 563 | -void audio_pcm_init_info ( | |
| 564 | - struct audio_pcm_info *info, | |
| 565 | - audsettings_t *as, | |
| 566 | - int swap_endian | |
| 567 | - ) | |
| 573 | +void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as) | |
| 568 | 574 | { |
| 569 | 575 | int bits = 8, sign = 0; |
| 570 | 576 | |
| ... | ... | @@ -588,7 +594,7 @@ void audio_pcm_init_info ( |
| 588 | 594 | info->shift = (as->nchannels == 2) + (bits == 16); |
| 589 | 595 | info->align = (1 << info->shift) - 1; |
| 590 | 596 | info->bytes_per_second = info->freq << info->shift; |
| 591 | - info->swap_endian = swap_endian; | |
| 597 | + info->swap_endianness = (as->endianness != AUDIO_HOST_ENDIANNESS); | |
| 592 | 598 | } |
| 593 | 599 | |
| 594 | 600 | void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len) |
| ... | ... | @@ -610,7 +616,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len) |
| 610 | 616 | int shift = info->nchannels - 1; |
| 611 | 617 | short s = INT16_MAX; |
| 612 | 618 | |
| 613 | - if (info->swap_endian) { | |
| 619 | + if (info->swap_endianness) { | |
| 614 | 620 | s = bswap16 (s); |
| 615 | 621 | } |
| 616 | 622 | |
| ... | ... | @@ -635,16 +641,13 @@ static void noop_conv (st_sample_t *dst, const void *src, |
| 635 | 641 | |
| 636 | 642 | static CaptureVoiceOut *audio_pcm_capture_find_specific ( |
| 637 | 643 | AudioState *s, |
| 638 | - audsettings_t *as, | |
| 639 | - int endian | |
| 644 | + audsettings_t *as | |
| 640 | 645 | ) |
| 641 | 646 | { |
| 642 | 647 | CaptureVoiceOut *cap; |
| 643 | - int swap_endian = audio_need_to_swap_endian (endian); | |
| 644 | 648 | |
| 645 | 649 | for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) { |
| 646 | - if ((cap->hw.info.swap_endian == swap_endian) | |
| 647 | - && audio_pcm_info_eq (&cap->hw.info, as)) { | |
| 650 | + if (audio_pcm_info_eq (&cap->hw.info, as)) { | |
| 648 | 651 | return cap; |
| 649 | 652 | } |
| 650 | 653 | } |
| ... | ... | @@ -1697,7 +1700,6 @@ AudioState *AUD_init (void) |
| 1697 | 1700 | int AUD_add_capture ( |
| 1698 | 1701 | AudioState *s, |
| 1699 | 1702 | audsettings_t *as, |
| 1700 | - int endian, | |
| 1701 | 1703 | struct audio_capture_ops *ops, |
| 1702 | 1704 | void *cb_opaque |
| 1703 | 1705 | ) |
| ... | ... | @@ -1725,7 +1727,7 @@ int AUD_add_capture ( |
| 1725 | 1727 | cb->ops = *ops; |
| 1726 | 1728 | cb->opaque = cb_opaque; |
| 1727 | 1729 | |
| 1728 | - cap = audio_pcm_capture_find_specific (s, as, endian); | |
| 1730 | + cap = audio_pcm_capture_find_specific (s, as); | |
| 1729 | 1731 | if (cap) { |
| 1730 | 1732 | LIST_INSERT_HEAD (&cap->cb_head, cb, entries); |
| 1731 | 1733 | return 0; |
| ... | ... | @@ -1755,7 +1757,7 @@ int AUD_add_capture ( |
| 1755 | 1757 | goto err2; |
| 1756 | 1758 | } |
| 1757 | 1759 | |
| 1758 | - audio_pcm_init_info (&hw->info, as, endian); | |
| 1760 | + audio_pcm_init_info (&hw->info, as); | |
| 1759 | 1761 | |
| 1760 | 1762 | cap->buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); |
| 1761 | 1763 | if (!cap->buf) { |
| ... | ... | @@ -1768,7 +1770,7 @@ int AUD_add_capture ( |
| 1768 | 1770 | hw->clip = mixeng_clip |
| 1769 | 1771 | [hw->info.nchannels == 2] |
| 1770 | 1772 | [hw->info.sign] |
| 1771 | - [hw->info.swap_endian] | |
| 1773 | + [hw->info.swap_endianness] | |
| 1772 | 1774 | [hw->info.bits == 16]; |
| 1773 | 1775 | |
| 1774 | 1776 | LIST_INSERT_HEAD (&s->cap_head, cap, entries); | ... | ... |
audio/audio.h
| ... | ... | @@ -24,6 +24,7 @@ |
| 24 | 24 | #ifndef QEMU_AUDIO_H |
| 25 | 25 | #define QEMU_AUDIO_H |
| 26 | 26 | |
| 27 | +#include "config.h" | |
| 27 | 28 | #include "sys-queue.h" |
| 28 | 29 | |
| 29 | 30 | typedef void (*audio_callback_fn_t) (void *opaque, int avail); |
| ... | ... | @@ -35,10 +36,17 @@ typedef enum { |
| 35 | 36 | AUD_FMT_S16 |
| 36 | 37 | } audfmt_e; |
| 37 | 38 | |
| 39 | +#ifdef WORDS_BIGENDIAN | |
| 40 | +#define AUDIO_HOST_ENDIANNESS 1 | |
| 41 | +#else | |
| 42 | +#define AUDIO_HOST_ENDIANNESS 0 | |
| 43 | +#endif | |
| 44 | + | |
| 38 | 45 | typedef struct { |
| 39 | 46 | int freq; |
| 40 | 47 | int nchannels; |
| 41 | 48 | audfmt_e fmt; |
| 49 | + int endianness; | |
| 42 | 50 | } audsettings_t; |
| 43 | 51 | |
| 44 | 52 | struct audio_capture_ops { |
| ... | ... | @@ -74,7 +82,6 @@ void AUD_remove_card (QEMUSoundCard *card); |
| 74 | 82 | int AUD_add_capture ( |
| 75 | 83 | AudioState *s, |
| 76 | 84 | audsettings_t *as, |
| 77 | - int endian, | |
| 78 | 85 | struct audio_capture_ops *ops, |
| 79 | 86 | void *opaque |
| 80 | 87 | ); |
| ... | ... | @@ -85,8 +92,7 @@ SWVoiceOut *AUD_open_out ( |
| 85 | 92 | const char *name, |
| 86 | 93 | void *callback_opaque, |
| 87 | 94 | audio_callback_fn_t callback_fn, |
| 88 | - audsettings_t *settings, | |
| 89 | - int sw_endian | |
| 95 | + audsettings_t *settings | |
| 90 | 96 | ); |
| 91 | 97 | |
| 92 | 98 | void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw); |
| ... | ... | @@ -104,8 +110,7 @@ SWVoiceIn *AUD_open_in ( |
| 104 | 110 | const char *name, |
| 105 | 111 | void *callback_opaque, |
| 106 | 112 | audio_callback_fn_t callback_fn, |
| 107 | - audsettings_t *settings, | |
| 108 | - int sw_endian | |
| 113 | + audsettings_t *settings | |
| 109 | 114 | ); |
| 110 | 115 | |
| 111 | 116 | void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw); | ... | ... |
audio/audio_int.h
| ... | ... | @@ -61,7 +61,7 @@ struct audio_pcm_info { |
| 61 | 61 | int align; |
| 62 | 62 | int shift; |
| 63 | 63 | int bytes_per_second; |
| 64 | - int swap_endian; | |
| 64 | + int swap_endianness; | |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | 67 | typedef struct HWVoiceOut { |
| ... | ... | @@ -198,8 +198,7 @@ extern struct audio_driver coreaudio_audio_driver; |
| 198 | 198 | extern struct audio_driver dsound_audio_driver; |
| 199 | 199 | extern volume_t nominal_volume; |
| 200 | 200 | |
| 201 | -void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as, | |
| 202 | - int swap_endian); | |
| 201 | +void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as); | |
| 203 | 202 | void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len); |
| 204 | 203 | |
| 205 | 204 | int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len); |
| ... | ... | @@ -220,15 +219,6 @@ static inline int audio_ring_dist (int dst, int src, int len) |
| 220 | 219 | return (dst >= src) ? (dst - src) : (len - src + dst); |
| 221 | 220 | } |
| 222 | 221 | |
| 223 | -static inline int audio_need_to_swap_endian (int endianness) | |
| 224 | -{ | |
| 225 | -#ifdef WORDS_BIGENDIAN | |
| 226 | - return endianness != 1; | |
| 227 | -#else | |
| 228 | - return endianness != 0; | |
| 229 | -#endif | |
| 230 | -} | |
| 231 | - | |
| 232 | 222 | #if defined __GNUC__ |
| 233 | 223 | #define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2))) |
| 234 | 224 | #define INIT_FIELD(f) . f | ... | ... |
audio/audio_template.h
| ... | ... | @@ -140,13 +140,12 @@ static int glue (audio_pcm_sw_init_, TYPE) ( |
| 140 | 140 | SW *sw, |
| 141 | 141 | HW *hw, |
| 142 | 142 | const char *name, |
| 143 | - audsettings_t *as, | |
| 144 | - int endian | |
| 143 | + audsettings_t *as | |
| 145 | 144 | ) |
| 146 | 145 | { |
| 147 | 146 | int err; |
| 148 | 147 | |
| 149 | - audio_pcm_init_info (&sw->info, as, audio_need_to_swap_endian (endian)); | |
| 148 | + audio_pcm_init_info (&sw->info, as); | |
| 150 | 149 | sw->hw = hw; |
| 151 | 150 | sw->active = 0; |
| 152 | 151 | #ifdef DAC |
| ... | ... | @@ -164,7 +163,7 @@ static int glue (audio_pcm_sw_init_, TYPE) ( |
| 164 | 163 | #endif |
| 165 | 164 | [sw->info.nchannels == 2] |
| 166 | 165 | [sw->info.sign] |
| 167 | - [sw->info.swap_endian] | |
| 166 | + [sw->info.swap_endianness] | |
| 168 | 167 | [sw->info.bits == 16]; |
| 169 | 168 | |
| 170 | 169 | sw->name = qemu_strdup (name); |
| ... | ... | @@ -288,7 +287,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (AudioState *s, audsettings_t *as) |
| 288 | 287 | #endif |
| 289 | 288 | [hw->info.nchannels == 2] |
| 290 | 289 | [hw->info.sign] |
| 291 | - [hw->info.swap_endian] | |
| 290 | + [hw->info.swap_endianness] | |
| 292 | 291 | [hw->info.bits == 16]; |
| 293 | 292 | |
| 294 | 293 | if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) { |
| ... | ... | @@ -336,8 +335,7 @@ static HW *glue (audio_pcm_hw_add_, TYPE) (AudioState *s, audsettings_t *as) |
| 336 | 335 | static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( |
| 337 | 336 | AudioState *s, |
| 338 | 337 | const char *sw_name, |
| 339 | - audsettings_t *as, | |
| 340 | - int sw_endian | |
| 338 | + audsettings_t *as | |
| 341 | 339 | ) |
| 342 | 340 | { |
| 343 | 341 | SW *sw; |
| ... | ... | @@ -365,7 +363,7 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( |
| 365 | 363 | |
| 366 | 364 | glue (audio_pcm_hw_add_sw_, TYPE) (hw, sw); |
| 367 | 365 | |
| 368 | - if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as, sw_endian)) { | |
| 366 | + if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as)) { | |
| 369 | 367 | goto err3; |
| 370 | 368 | } |
| 371 | 369 | |
| ... | ... | @@ -407,8 +405,7 @@ SW *glue (AUD_open_, TYPE) ( |
| 407 | 405 | const char *name, |
| 408 | 406 | void *callback_opaque , |
| 409 | 407 | audio_callback_fn_t callback_fn, |
| 410 | - audsettings_t *as, | |
| 411 | - int sw_endian | |
| 408 | + audsettings_t *as | |
| 412 | 409 | ) |
| 413 | 410 | { |
| 414 | 411 | AudioState *s; |
| ... | ... | @@ -481,12 +478,12 @@ SW *glue (AUD_open_, TYPE) ( |
| 481 | 478 | } |
| 482 | 479 | |
| 483 | 480 | glue (audio_pcm_sw_fini_, TYPE) (sw); |
| 484 | - if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, name, as, sw_endian)) { | |
| 481 | + if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, name, as)) { | |
| 485 | 482 | goto fail; |
| 486 | 483 | } |
| 487 | 484 | } |
| 488 | 485 | else { |
| 489 | - sw = glue (audio_pcm_create_voice_pair_, TYPE) (s, name, as, sw_endian); | |
| 486 | + sw = glue (audio_pcm_create_voice_pair_, TYPE) (s, name, as); | |
| 490 | 487 | if (!sw) { |
| 491 | 488 | dolog ("Failed to create voice `%s'\n", name); |
| 492 | 489 | return NULL; | ... | ... |
audio/coreaudio.c
| ... | ... | @@ -295,7 +295,6 @@ static int coreaudio_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 295 | 295 | UInt32 propertySize; |
| 296 | 296 | int err; |
| 297 | 297 | int bits = 8; |
| 298 | - int endianess = 0; | |
| 299 | 298 | const char *typ = "playback"; |
| 300 | 299 | AudioValueRange frameRange; |
| 301 | 300 | |
| ... | ... | @@ -308,16 +307,9 @@ static int coreaudio_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 308 | 307 | |
| 309 | 308 | if (as->fmt == AUD_FMT_S16 || as->fmt == AUD_FMT_U16) { |
| 310 | 309 | bits = 16; |
| 311 | - endianess = 1; | |
| 312 | 310 | } |
| 313 | 311 | |
| 314 | - audio_pcm_init_info ( | |
| 315 | - &hw->info, | |
| 316 | - as, | |
| 317 | - /* Following is irrelevant actually since we do not use | |
| 318 | - mixengs clipping routines */ | |
| 319 | - audio_need_to_swap_endian (endianess) | |
| 320 | - ); | |
| 312 | + audio_pcm_init_info (&hw->info, as); | |
| 321 | 313 | |
| 322 | 314 | /* open default output device */ |
| 323 | 315 | propertySize = sizeof(core->outputDeviceID); | ... | ... |
audio/dsound_template.h
| ... | ... | @@ -250,8 +250,8 @@ static int dsound_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | ds->first_time = 1; |
| 253 | - | |
| 254 | - audio_pcm_init_info (&hw->info, &obt_as, audio_need_to_swap_endian (0)); | |
| 253 | + obt_as.endianness = 0; | |
| 254 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 255 | 255 | |
| 256 | 256 | if (bc.dwBufferBytes & hw->info.align) { |
| 257 | 257 | dolog ( | ... | ... |
audio/fmodaudio.c
| ... | ... | @@ -358,6 +358,7 @@ static int fmod_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 358 | 358 | { |
| 359 | 359 | int bits16, mode, channel; |
| 360 | 360 | FMODVoiceOut *fmd = (FMODVoiceOut *) hw; |
| 361 | + audsettings_t obt_as = *as; | |
| 361 | 362 | |
| 362 | 363 | mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0); |
| 363 | 364 | fmd->fmod_sample = FSOUND_Sample_Alloc ( |
| ... | ... | @@ -384,7 +385,8 @@ static int fmod_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 384 | 385 | fmd->channel = channel; |
| 385 | 386 | |
| 386 | 387 | /* FMOD always operates on little endian frames? */ |
| 387 | - audio_pcm_init_info (&hw->info, as, audio_need_to_swap_endian (0)); | |
| 388 | + obt_as.endianness = 0; | |
| 389 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 388 | 390 | bits16 = (mode & FSOUND_16BITS) != 0; |
| 389 | 391 | hw->samples = conf.nb_samples; |
| 390 | 392 | return 0; |
| ... | ... | @@ -418,6 +420,7 @@ static int fmod_init_in (HWVoiceIn *hw, audsettings_t *as) |
| 418 | 420 | { |
| 419 | 421 | int bits16, mode; |
| 420 | 422 | FMODVoiceIn *fmd = (FMODVoiceIn *) hw; |
| 423 | + audsettings_t obt_as = *as; | |
| 421 | 424 | |
| 422 | 425 | if (conf.broken_adc) { |
| 423 | 426 | return -1; |
| ... | ... | @@ -440,7 +443,8 @@ static int fmod_init_in (HWVoiceIn *hw, audsettings_t *as) |
| 440 | 443 | } |
| 441 | 444 | |
| 442 | 445 | /* FMOD always operates on little endian frames? */ |
| 443 | - audio_pcm_init_info (&hw->info, as, audio_need_to_swap_endian (0)); | |
| 446 | + obt_as.endianness = 0; | |
| 447 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 444 | 448 | bits16 = (mode & FSOUND_16BITS) != 0; |
| 445 | 449 | hw->samples = conf.nb_samples; |
| 446 | 450 | return 0; | ... | ... |
audio/noaudio.c
| ... | ... | @@ -68,7 +68,7 @@ static int no_write (SWVoiceOut *sw, void *buf, int len) |
| 68 | 68 | |
| 69 | 69 | static int no_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 70 | 70 | { |
| 71 | - audio_pcm_init_info (&hw->info, as, 0); | |
| 71 | + audio_pcm_init_info (&hw->info, as); | |
| 72 | 72 | hw->samples = 1024; |
| 73 | 73 | return 0; |
| 74 | 74 | } |
| ... | ... | @@ -87,7 +87,7 @@ static int no_ctl_out (HWVoiceOut *hw, int cmd, ...) |
| 87 | 87 | |
| 88 | 88 | static int no_init_in (HWVoiceIn *hw, audsettings_t *as) |
| 89 | 89 | { |
| 90 | - audio_pcm_init_info (&hw->info, as, 0); | |
| 90 | + audio_pcm_init_info (&hw->info, as); | |
| 91 | 91 | hw->samples = 1024; |
| 92 | 92 | return 0; |
| 93 | 93 | } | ... | ... |
audio/ossaudio.c
| ... | ... | @@ -453,12 +453,9 @@ static int oss_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 453 | 453 | obt_as.freq = obt.freq; |
| 454 | 454 | obt_as.nchannels = obt.nchannels; |
| 455 | 455 | obt_as.fmt = effective_fmt; |
| 456 | + obt_as.endianness = endianness; | |
| 456 | 457 | |
| 457 | - audio_pcm_init_info ( | |
| 458 | - &hw->info, | |
| 459 | - &obt_as, | |
| 460 | - audio_need_to_swap_endian (endianness) | |
| 461 | - ); | |
| 458 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 462 | 459 | oss->nfrags = obt.nfrags; |
| 463 | 460 | oss->fragsize = obt.fragsize; |
| 464 | 461 | |
| ... | ... | @@ -597,12 +594,9 @@ static int oss_init_in (HWVoiceIn *hw, audsettings_t *as) |
| 597 | 594 | obt_as.freq = obt.freq; |
| 598 | 595 | obt_as.nchannels = obt.nchannels; |
| 599 | 596 | obt_as.fmt = effective_fmt; |
| 597 | + obt_as.endianness = endianness; | |
| 600 | 598 | |
| 601 | - audio_pcm_init_info ( | |
| 602 | - &hw->info, | |
| 603 | - &obt_as, | |
| 604 | - audio_need_to_swap_endian (endianness) | |
| 605 | - ); | |
| 599 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 606 | 600 | oss->nfrags = obt.nfrags; |
| 607 | 601 | oss->fragsize = obt.fragsize; |
| 608 | 602 | ... | ... |
audio/sdlaudio.c
| ... | ... | @@ -335,12 +335,9 @@ static int sdl_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 335 | 335 | obt_as.freq = obt.freq; |
| 336 | 336 | obt_as.nchannels = obt.channels; |
| 337 | 337 | obt_as.fmt = effective_fmt; |
| 338 | + obt_as.endianness = endianess; | |
| 338 | 339 | |
| 339 | - audio_pcm_init_info ( | |
| 340 | - &hw->info, | |
| 341 | - &obt_as, | |
| 342 | - audio_need_to_swap_endian (endianess) | |
| 343 | - ); | |
| 340 | + audio_pcm_init_info (&hw->info, &obt_as); | |
| 344 | 341 | hw->samples = obt.samples; |
| 345 | 342 | |
| 346 | 343 | s->initialized = 1; | ... | ... |
audio/wavaudio.c
| ... | ... | @@ -135,7 +135,8 @@ static int wav_init_out (HWVoiceOut *hw, audsettings_t *as) |
| 135 | 135 | |
| 136 | 136 | hdr[34] = bits16 ? 0x10 : 0x08; |
| 137 | 137 | |
| 138 | - audio_pcm_init_info (&hw->info, &wav_as, audio_need_to_swap_endian (0)); | |
| 138 | + wav_as.endianness = 0; | |
| 139 | + audio_pcm_init_info (&hw->info, &wav_as); | |
| 139 | 140 | |
| 140 | 141 | hw->samples = 1024; |
| 141 | 142 | wav->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); | ... | ... |
audio/wavcapture.c
| ... | ... | @@ -70,6 +70,7 @@ void wav_capture (const char *path, int freq, int bits16, int stereo) |
| 70 | 70 | as.freq = freq; |
| 71 | 71 | as.nchannels = 1 << stereo; |
| 72 | 72 | as.fmt = bits16 ? AUD_FMT_S16 : AUD_FMT_U8; |
| 73 | + as.endianness = 0; | |
| 73 | 74 | |
| 74 | 75 | ops.state = wav_state_cb; |
| 75 | 76 | ops.capture = wav_capture_cb; |
| ... | ... | @@ -97,5 +98,5 @@ void wav_capture (const char *path, int freq, int bits16, int stereo) |
| 97 | 98 | } |
| 98 | 99 | |
| 99 | 100 | qemu_put_buffer (wav->f, hdr, sizeof (hdr)); |
| 100 | - AUD_add_capture (NULL, &as, 0, &ops, wav); | |
| 101 | + AUD_add_capture (NULL, &as, &ops, wav); | |
| 101 | 102 | } | ... | ... |
hw/adlib.c
| ... | ... | @@ -301,6 +301,7 @@ int Adlib_init (AudioState *audio) |
| 301 | 301 | as.freq = conf.freq; |
| 302 | 302 | as.nchannels = SHIFT; |
| 303 | 303 | as.fmt = AUD_FMT_S16; |
| 304 | + as.endianness = AUDIO_HOST_ENDIANNESS; | |
| 304 | 305 | |
| 305 | 306 | AUD_register_card (audio, "adlib", &s->card); |
| 306 | 307 | |
| ... | ... | @@ -310,8 +311,7 @@ int Adlib_init (AudioState *audio) |
| 310 | 311 | "adlib", |
| 311 | 312 | s, |
| 312 | 313 | adlib_callback, |
| 313 | - &as, | |
| 314 | - 0 /* XXX: little endian? */ | |
| 314 | + &as | |
| 315 | 315 | ); |
| 316 | 316 | if (!s->voice) { |
| 317 | 317 | Adlib_fini (s); | ... | ... |
hw/es1370.c
| ... | ... | @@ -423,6 +423,7 @@ static void es1370_update_voices (ES1370State *s, uint32_t ctl, uint32_t sctl) |
| 423 | 423 | as.freq = new_freq; |
| 424 | 424 | as.nchannels = 1 << (new_fmt & 1); |
| 425 | 425 | as.fmt = (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8; |
| 426 | + as.endianness = 0; | |
| 426 | 427 | |
| 427 | 428 | if (i == ADC_CHANNEL) { |
| 428 | 429 | s->adc_voice = |
| ... | ... | @@ -432,8 +433,7 @@ static void es1370_update_voices (ES1370State *s, uint32_t ctl, uint32_t sctl) |
| 432 | 433 | "es1370.adc", |
| 433 | 434 | s, |
| 434 | 435 | es1370_adc_callback, |
| 435 | - &as, | |
| 436 | - 0 /* little endian */ | |
| 436 | + &as | |
| 437 | 437 | ); |
| 438 | 438 | } |
| 439 | 439 | else { |
| ... | ... | @@ -444,8 +444,7 @@ static void es1370_update_voices (ES1370State *s, uint32_t ctl, uint32_t sctl) |
| 444 | 444 | i ? "es1370.dac2" : "es1370.dac1", |
| 445 | 445 | s, |
| 446 | 446 | i ? es1370_dac2_callback : es1370_dac1_callback, |
| 447 | - &as, | |
| 448 | - 0 /* litle endian */ | |
| 447 | + &as | |
| 449 | 448 | ); |
| 450 | 449 | } |
| 451 | 450 | } | ... | ... |
hw/pcspk.c
| ... | ... | @@ -95,7 +95,7 @@ static void pcspk_callback(void *opaque, int free) |
| 95 | 95 | int pcspk_audio_init(AudioState *audio) |
| 96 | 96 | { |
| 97 | 97 | PCSpkState *s = &pcspk_state; |
| 98 | - audsettings_t as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8}; | |
| 98 | + audsettings_t as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0}; | |
| 99 | 99 | |
| 100 | 100 | if (!audio) { |
| 101 | 101 | AUD_log(s_spk, "No audio state\n"); |
| ... | ... | @@ -103,7 +103,7 @@ int pcspk_audio_init(AudioState *audio) |
| 103 | 103 | } |
| 104 | 104 | AUD_register_card(audio, s_spk, &s->card); |
| 105 | 105 | |
| 106 | - s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as, 0); | |
| 106 | + s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as); | |
| 107 | 107 | if (!s->voice) { |
| 108 | 108 | AUD_log(s_spk, "Could not open voice\n"); |
| 109 | 109 | return -1; | ... | ... |
hw/sb16.c
| ... | ... | @@ -203,6 +203,7 @@ static void continue_dma8 (SB16State *s) |
| 203 | 203 | as.freq = s->freq; |
| 204 | 204 | as.nchannels = 1 << s->fmt_stereo; |
| 205 | 205 | as.fmt = s->fmt; |
| 206 | + as.endianness = 0; | |
| 206 | 207 | |
| 207 | 208 | s->voice = AUD_open_out ( |
| 208 | 209 | &s->card, |
| ... | ... | @@ -210,8 +211,7 @@ static void continue_dma8 (SB16State *s) |
| 210 | 211 | "sb16", |
| 211 | 212 | s, |
| 212 | 213 | SB_audio_callback, |
| 213 | - &as, | |
| 214 | - 0 /* little endian */ | |
| 214 | + &as | |
| 215 | 215 | ); |
| 216 | 216 | } |
| 217 | 217 | |
| ... | ... | @@ -348,6 +348,7 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, int dma_len) |
| 348 | 348 | as.freq = s->freq; |
| 349 | 349 | as.nchannels = 1 << s->fmt_stereo; |
| 350 | 350 | as.fmt = s->fmt; |
| 351 | + as.endianness = 0; | |
| 351 | 352 | |
| 352 | 353 | s->voice = AUD_open_out ( |
| 353 | 354 | &s->card, |
| ... | ... | @@ -355,8 +356,7 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, int dma_len) |
| 355 | 356 | "sb16", |
| 356 | 357 | s, |
| 357 | 358 | SB_audio_callback, |
| 358 | - &as, | |
| 359 | - 0 /* little endian */ | |
| 359 | + &as | |
| 360 | 360 | ); |
| 361 | 361 | } |
| 362 | 362 | |
| ... | ... | @@ -838,6 +838,7 @@ static void legacy_reset (SB16State *s) |
| 838 | 838 | as.freq = s->freq; |
| 839 | 839 | as.nchannels = 1; |
| 840 | 840 | as.fmt = AUD_FMT_U8; |
| 841 | + as.endianness = 0; | |
| 841 | 842 | |
| 842 | 843 | s->voice = AUD_open_out ( |
| 843 | 844 | &s->card, |
| ... | ... | @@ -845,8 +846,7 @@ static void legacy_reset (SB16State *s) |
| 845 | 846 | "sb16", |
| 846 | 847 | s, |
| 847 | 848 | SB_audio_callback, |
| 848 | - &as, | |
| 849 | - 0 /* little endian */ | |
| 849 | + &as | |
| 850 | 850 | ); |
| 851 | 851 | |
| 852 | 852 | /* Not sure about that... */ |
| ... | ... | @@ -1371,6 +1371,7 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id) |
| 1371 | 1371 | as.freq = s->freq; |
| 1372 | 1372 | as.nchannels = 1 << s->fmt_stereo; |
| 1373 | 1373 | as.fmt = s->fmt; |
| 1374 | + as.endianness = 0; | |
| 1374 | 1375 | |
| 1375 | 1376 | s->voice = AUD_open_out ( |
| 1376 | 1377 | &s->card, |
| ... | ... | @@ -1378,8 +1379,7 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id) |
| 1378 | 1379 | "sb16", |
| 1379 | 1380 | s, |
| 1380 | 1381 | SB_audio_callback, |
| 1381 | - &as, | |
| 1382 | - 0 /* little endian */ | |
| 1382 | + &as | |
| 1383 | 1383 | ); |
| 1384 | 1384 | } |
| 1385 | 1385 | ... | ... |