summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/SDL2/src/audio
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/SDL2/src/audio')
-rw-r--r--3rdparty/SDL2/src/audio/SDL_audio.c1668
-rw-r--r--3rdparty/SDL2/src/audio/SDL_audio_c.h52
-rw-r--r--3rdparty/SDL2/src/audio/SDL_audiocvt.c1121
-rw-r--r--3rdparty/SDL2/src/audio/SDL_audiodev.c123
-rw-r--r--3rdparty/SDL2/src/audio/SDL_audiodev_c.h38
-rw-r--r--3rdparty/SDL2/src/audio/SDL_audiotypecvt.c16015
-rw-r--r--3rdparty/SDL2/src/audio/SDL_mixer.c369
-rw-r--r--3rdparty/SDL2/src/audio/SDL_sysaudio.h205
-rw-r--r--3rdparty/SDL2/src/audio/SDL_wave.c624
-rw-r--r--3rdparty/SDL2/src/audio/SDL_wave.h67
-rw-r--r--3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.c983
-rw-r--r--3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.h45
-rw-r--r--3rdparty/SDL2/src/audio/android/SDL_androidaudio.c242
-rw-r--r--3rdparty/SDL2/src/audio/android/SDL_androidaudio.h39
-rw-r--r--3rdparty/SDL2/src/audio/android/opensl_io.c558
-rw-r--r--3rdparty/SDL2/src/audio/android/opensl_io.h129
-rw-r--r--3rdparty/SDL2/src/audio/arts/SDL_artsaudio.c365
-rw-r--r--3rdparty/SDL2/src/audio/arts/SDL_artsaudio.h52
-rw-r--r--3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.c418
-rw-r--r--3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.h51
-rw-r--r--3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.h67
-rw-r--r--3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.m849
-rw-r--r--3rdparty/SDL2/src/audio/directsound/SDL_directsound.c605
-rw-r--r--3rdparty/SDL2/src/audio/directsound/SDL_directsound.h47
-rw-r--r--3rdparty/SDL2/src/audio/disk/SDL_diskaudio.c207
-rw-r--r--3rdparty/SDL2/src/audio/disk/SDL_diskaudio.h41
-rw-r--r--3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.c320
-rw-r--r--3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.h43
-rw-r--r--3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.c65
-rw-r--r--3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.h41
-rw-r--r--3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.c443
-rw-r--r--3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.h42
-rw-r--r--3rdparty/SDL2/src/audio/esd/SDL_esdaudio.c335
-rw-r--r--3rdparty/SDL2/src/audio/esd/SDL_esdaudio.h50
-rw-r--r--3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.c328
-rw-r--r--3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.h49
-rw-r--r--3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.cc234
-rw-r--r--3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.h38
-rw-r--r--3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.c149
-rw-r--r--3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.h41
-rw-r--r--3rdparty/SDL2/src/audio/nas/SDL_nasaudio.c463
-rw-r--r--3rdparty/SDL2/src/audio/nas/SDL_nasaudio.h56
-rw-r--r--3rdparty/SDL2/src/audio/paudio/SDL_paudio.c529
-rw-r--r--3rdparty/SDL2/src/audio/paudio/SDL_paudio.h47
-rw-r--r--3rdparty/SDL2/src/audio/psp/SDL_pspaudio.c180
-rw-r--r--3rdparty/SDL2/src/audio/psp/SDL_pspaudio.h45
-rw-r--r--3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.c772
-rw-r--r--3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.h52
-rw-r--r--3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.c771
-rw-r--r--3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.h57
-rw-r--r--3rdparty/SDL2/src/audio/sdlgenaudiocvt.pl761
-rw-r--r--3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.c315
-rw-r--r--3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.h45
-rw-r--r--3rdparty/SDL2/src/audio/sun/SDL_sunaudio.c421
-rw-r--r--3rdparty/SDL2/src/audio/sun/SDL_sunaudio.h47
-rw-r--r--3rdparty/SDL2/src/audio/winmm/SDL_winmm.c423
-rw-r--r--3rdparty/SDL2/src/audio/winmm/SDL_winmm.h45
-rw-r--r--3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.c503
-rw-r--r--3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.h386
-rw-r--r--3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp90
-rw-r--r--3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h70
61 files changed, 0 insertions, 33236 deletions
diff --git a/3rdparty/SDL2/src/audio/SDL_audio.c b/3rdparty/SDL2/src/audio/SDL_audio.c
deleted file mode 100644
index 460852d7f5a..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_audio.c
+++ /dev/null
@@ -1,1668 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-/* Allow access to a raw mixing buffer */
-
-#include "SDL.h"
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-#include "SDL_sysaudio.h"
-#include "../thread/SDL_systhread.h"
-
-#define _THIS SDL_AudioDevice *_this
-
-static SDL_AudioDriver current_audio;
-static SDL_AudioDevice *open_devices[16];
-
-/*
- * Not all of these will be compiled and linked in, but it's convenient
- * to have a complete list here and saves yet-another block of #ifdefs...
- * Please see bootstrap[], below, for the actual #ifdef mess.
- */
-extern AudioBootStrap PULSEAUDIO_bootstrap;
-extern AudioBootStrap ALSA_bootstrap;
-extern AudioBootStrap SNDIO_bootstrap;
-extern AudioBootStrap BSD_AUDIO_bootstrap;
-extern AudioBootStrap DSP_bootstrap;
-extern AudioBootStrap QSAAUDIO_bootstrap;
-extern AudioBootStrap SUNAUDIO_bootstrap;
-extern AudioBootStrap ARTS_bootstrap;
-extern AudioBootStrap ESD_bootstrap;
-extern AudioBootStrap NACLAUDIO_bootstrap;
-extern AudioBootStrap NAS_bootstrap;
-extern AudioBootStrap XAUDIO2_bootstrap;
-extern AudioBootStrap DSOUND_bootstrap;
-extern AudioBootStrap WINMM_bootstrap;
-extern AudioBootStrap PAUDIO_bootstrap;
-extern AudioBootStrap HAIKUAUDIO_bootstrap;
-extern AudioBootStrap COREAUDIO_bootstrap;
-extern AudioBootStrap DISKAUDIO_bootstrap;
-extern AudioBootStrap DUMMYAUDIO_bootstrap;
-extern AudioBootStrap FUSIONSOUND_bootstrap;
-extern AudioBootStrap ANDROIDAUDIO_bootstrap;
-extern AudioBootStrap PSPAUDIO_bootstrap;
-extern AudioBootStrap SNDIO_bootstrap;
-extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap;
-
-/* Available audio drivers */
-static const AudioBootStrap *const bootstrap[] = {
-#if SDL_AUDIO_DRIVER_PULSEAUDIO
- &PULSEAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_ALSA
- &ALSA_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_SNDIO
- &SNDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_BSD
- &BSD_AUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_OSS
- &DSP_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_QSA
- &QSAAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_SUNAUDIO
- &SUNAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_ARTS
- &ARTS_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_ESD
- &ESD_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_NACL
- &NACLAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_NAS
- &NAS_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_XAUDIO2
- &XAUDIO2_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_DSOUND
- &DSOUND_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_WINMM
- &WINMM_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_PAUDIO
- &PAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_HAIKU
- &HAIKUAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_COREAUDIO
- &COREAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_DISK
- &DISKAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_DUMMY
- &DUMMYAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_FUSIONSOUND
- &FUSIONSOUND_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_ANDROID
- &ANDROIDAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_PSP
- &PSPAUDIO_bootstrap,
-#endif
-#if SDL_AUDIO_DRIVER_EMSCRIPTEN
- &EMSCRIPTENAUDIO_bootstrap,
-#endif
- NULL
-};
-
-static SDL_AudioDevice *
-get_audio_device(SDL_AudioDeviceID id)
-{
- id--;
- if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) {
- SDL_SetError("Invalid audio device ID");
- return NULL;
- }
-
- return open_devices[id];
-}
-
-
-/* stubs for audio drivers that don't need a specific entry point... */
-static void
-SDL_AudioDetectDevices_Default(void)
-{
- /* you have to write your own implementation if these assertions fail. */
- SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice);
- SDL_assert(current_audio.impl.OnlyHasDefaultCaptureDevice || !current_audio.impl.HasCaptureSupport);
-
- SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, (void *) ((size_t) 0x1));
- if (current_audio.impl.HasCaptureSupport) {
- SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, (void *) ((size_t) 0x2));
- }
-}
-
-static void
-SDL_AudioThreadInit_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioWaitDevice_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioPlayDevice_Default(_THIS)
-{ /* no-op. */
-}
-
-static int
-SDL_AudioGetPendingBytes_Default(_THIS)
-{
- return 0;
-}
-
-static Uint8 *
-SDL_AudioGetDeviceBuf_Default(_THIS)
-{
- return NULL;
-}
-
-static int
-SDL_AudioCaptureFromDevice_Default(_THIS, void *buffer, int buflen)
-{
- return -1; /* just fail immediately. */
-}
-
-static void
-SDL_AudioFlushCapture_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioPrepareToClose_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioCloseDevice_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioDeinitialize_Default(void)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioFreeDeviceHandle_Default(void *handle)
-{ /* no-op. */
-}
-
-
-static int
-SDL_AudioOpenDevice_Default(_THIS, void *handle, const char *devname, int iscapture)
-{
- return SDL_Unsupported();
-}
-
-static SDL_INLINE SDL_bool
-is_in_audio_device_thread(SDL_AudioDevice * device)
-{
- /* The device thread locks the same mutex, but not through the public API.
- This check is in case the application, in the audio callback,
- tries to lock the thread that we've already locked from the
- device thread...just in case we only have non-recursive mutexes. */
- if (device->thread && (SDL_ThreadID() == device->threadid)) {
- return SDL_TRUE;
- }
-
- return SDL_FALSE;
-}
-
-static void
-SDL_AudioLockDevice_Default(SDL_AudioDevice * device)
-{
- if (!is_in_audio_device_thread(device)) {
- SDL_LockMutex(device->mixer_lock);
- }
-}
-
-static void
-SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device)
-{
- if (!is_in_audio_device_thread(device)) {
- SDL_UnlockMutex(device->mixer_lock);
- }
-}
-
-static void
-SDL_AudioLockOrUnlockDeviceWithNoMixerLock(SDL_AudioDevice * device)
-{
-}
-
-static void
-finish_audio_entry_points_init(void)
-{
- /*
- * Fill in stub functions for unused driver entry points. This lets us
- * blindly call them without having to check for validity first.
- */
-
- if (current_audio.impl.SkipMixerLock) {
- if (current_audio.impl.LockDevice == NULL) {
- current_audio.impl.LockDevice = SDL_AudioLockOrUnlockDeviceWithNoMixerLock;
- }
- if (current_audio.impl.UnlockDevice == NULL) {
- current_audio.impl.UnlockDevice = SDL_AudioLockOrUnlockDeviceWithNoMixerLock;
- }
- }
-
-#define FILL_STUB(x) \
- if (current_audio.impl.x == NULL) { \
- current_audio.impl.x = SDL_Audio##x##_Default; \
- }
- FILL_STUB(DetectDevices);
- FILL_STUB(OpenDevice);
- FILL_STUB(ThreadInit);
- FILL_STUB(WaitDevice);
- FILL_STUB(PlayDevice);
- FILL_STUB(GetPendingBytes);
- FILL_STUB(GetDeviceBuf);
- FILL_STUB(CaptureFromDevice);
- FILL_STUB(FlushCapture);
- FILL_STUB(PrepareToClose);
- FILL_STUB(CloseDevice);
- FILL_STUB(LockDevice);
- FILL_STUB(UnlockDevice);
- FILL_STUB(FreeDeviceHandle);
- FILL_STUB(Deinitialize);
-#undef FILL_STUB
-}
-
-
-/* device hotplug support... */
-
-static int
-add_audio_device(const char *name, void *handle, SDL_AudioDeviceItem **devices, int *devCount)
-{
- int retval = -1;
- const size_t size = sizeof (SDL_AudioDeviceItem) + SDL_strlen(name) + 1;
- SDL_AudioDeviceItem *item = (SDL_AudioDeviceItem *) SDL_malloc(size);
- if (item == NULL) {
- return -1;
- }
-
- SDL_assert(handle != NULL); /* we reserve NULL, audio backends can't use it. */
-
- item->handle = handle;
- SDL_strlcpy(item->name, name, size - sizeof (SDL_AudioDeviceItem));
-
- SDL_LockMutex(current_audio.detectionLock);
- item->next = *devices;
- *devices = item;
- retval = (*devCount)++;
- SDL_UnlockMutex(current_audio.detectionLock);
-
- return retval;
-}
-
-static SDL_INLINE int
-add_capture_device(const char *name, void *handle)
-{
- SDL_assert(current_audio.impl.HasCaptureSupport);
- return add_audio_device(name, handle, &current_audio.inputDevices, &current_audio.inputDeviceCount);
-}
-
-static SDL_INLINE int
-add_output_device(const char *name, void *handle)
-{
- return add_audio_device(name, handle, &current_audio.outputDevices, &current_audio.outputDeviceCount);
-}
-
-static void
-free_device_list(SDL_AudioDeviceItem **devices, int *devCount)
-{
- SDL_AudioDeviceItem *item, *next;
- for (item = *devices; item != NULL; item = next) {
- next = item->next;
- if (item->handle != NULL) {
- current_audio.impl.FreeDeviceHandle(item->handle);
- }
- SDL_free(item);
- }
- *devices = NULL;
- *devCount = 0;
-}
-
-
-/* The audio backends call this when a new device is plugged in. */
-void
-SDL_AddAudioDevice(const int iscapture, const char *name, void *handle)
-{
- const int device_index = iscapture ? add_capture_device(name, handle) : add_output_device(name, handle);
- if (device_index != -1) {
- /* Post the event, if desired */
- if (SDL_GetEventState(SDL_AUDIODEVICEADDED) == SDL_ENABLE) {
- SDL_Event event;
- SDL_zero(event);
- event.adevice.type = SDL_AUDIODEVICEADDED;
- event.adevice.which = device_index;
- event.adevice.iscapture = iscapture;
- SDL_PushEvent(&event);
- }
- }
-}
-
-/* The audio backends call this when a currently-opened device is lost. */
-void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
-{
- SDL_assert(get_audio_device(device->id) == device);
-
- if (!SDL_AtomicGet(&device->enabled)) {
- return;
- }
-
- /* Ends the audio callback and mark the device as STOPPED, but the
- app still needs to close the device to free resources. */
- current_audio.impl.LockDevice(device);
- SDL_AtomicSet(&device->enabled, 0);
- current_audio.impl.UnlockDevice(device);
-
- /* Post the event, if desired */
- if (SDL_GetEventState(SDL_AUDIODEVICEREMOVED) == SDL_ENABLE) {
- SDL_Event event;
- SDL_zero(event);
- event.adevice.type = SDL_AUDIODEVICEREMOVED;
- event.adevice.which = device->id;
- event.adevice.iscapture = device->iscapture ? 1 : 0;
- SDL_PushEvent(&event);
- }
-}
-
-static void
-mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag)
-{
- SDL_AudioDeviceItem *item;
- SDL_assert(handle != NULL);
- for (item = devices; item != NULL; item = item->next) {
- if (item->handle == handle) {
- item->handle = NULL;
- *removedFlag = SDL_TRUE;
- return;
- }
- }
-}
-
-/* The audio backends call this when a device is removed from the system. */
-void
-SDL_RemoveAudioDevice(const int iscapture, void *handle)
-{
- int device_index;
- SDL_AudioDevice *device = NULL;
-
- SDL_LockMutex(current_audio.detectionLock);
- if (iscapture) {
- mark_device_removed(handle, current_audio.inputDevices, &current_audio.captureDevicesRemoved);
- } else {
- mark_device_removed(handle, current_audio.outputDevices, &current_audio.outputDevicesRemoved);
- }
- for (device_index = 0; device_index < SDL_arraysize(open_devices); device_index++)
- {
- device = open_devices[device_index];
- if (device != NULL && device->handle == handle)
- {
- SDL_OpenedAudioDeviceDisconnected(device);
- break;
- }
- }
- SDL_UnlockMutex(current_audio.detectionLock);
-
- current_audio.impl.FreeDeviceHandle(handle);
-}
-
-
-
-/* buffer queueing support... */
-
-/* this expects that you managed thread safety elsewhere. */
-static void
-free_audio_queue(SDL_AudioBufferQueue *packet)
-{
- while (packet) {
- SDL_AudioBufferQueue *next = packet->next;
- SDL_free(packet);
- packet = next;
- }
-}
-
-/* NOTE: This assumes you'll hold the mixer lock before calling! */
-static int
-queue_audio_to_device(SDL_AudioDevice *device, const Uint8 *data, Uint32 len)
-{
- SDL_AudioBufferQueue *orighead;
- SDL_AudioBufferQueue *origtail;
- Uint32 origlen;
- Uint32 datalen;
-
- orighead = device->buffer_queue_head;
- origtail = device->buffer_queue_tail;
- origlen = origtail ? origtail->datalen : 0;
-
- while (len > 0) {
- SDL_AudioBufferQueue *packet = device->buffer_queue_tail;
- SDL_assert(!packet || (packet->datalen <= SDL_AUDIOBUFFERQUEUE_PACKETLEN));
- if (!packet || (packet->datalen >= SDL_AUDIOBUFFERQUEUE_PACKETLEN)) {
- /* tail packet missing or completely full; we need a new packet. */
- packet = device->buffer_queue_pool;
- if (packet != NULL) {
- /* we have one available in the pool. */
- device->buffer_queue_pool = packet->next;
- } else {
- /* Have to allocate a new one! */
- packet = (SDL_AudioBufferQueue *) SDL_malloc(sizeof (SDL_AudioBufferQueue));
- if (packet == NULL) {
- /* uhoh, reset so we've queued nothing new, free what we can. */
- if (!origtail) {
- packet = device->buffer_queue_head; /* whole queue. */
- } else {
- packet = origtail->next; /* what we added to existing queue. */
- origtail->next = NULL;
- origtail->datalen = origlen;
- }
- device->buffer_queue_head = orighead;
- device->buffer_queue_tail = origtail;
- device->buffer_queue_pool = NULL;
-
- free_audio_queue(packet); /* give back what we can. */
-
- return SDL_OutOfMemory();
- }
- }
- packet->datalen = 0;
- packet->startpos = 0;
- packet->next = NULL;
-
- SDL_assert((device->buffer_queue_head != NULL) == (device->queued_bytes != 0));
- if (device->buffer_queue_tail == NULL) {
- device->buffer_queue_head = packet;
- } else {
- device->buffer_queue_tail->next = packet;
- }
- device->buffer_queue_tail = packet;
- }
-
- datalen = SDL_min(len, SDL_AUDIOBUFFERQUEUE_PACKETLEN - packet->datalen);
- SDL_memcpy(packet->data + packet->datalen, data, datalen);
- data += datalen;
- len -= datalen;
- packet->datalen += datalen;
- device->queued_bytes += datalen;
- }
-
- return 0;
-}
-
-/* NOTE: This assumes you'll hold the mixer lock before calling! */
-static Uint32
-dequeue_audio_from_device(SDL_AudioDevice *device, Uint8 *stream, Uint32 len)
-{
- SDL_AudioBufferQueue *packet;
- Uint8 *ptr = stream;
-
- while ((len > 0) && ((packet = device->buffer_queue_head) != NULL)) {
- const Uint32 avail = packet->datalen - packet->startpos;
- const Uint32 cpy = SDL_min(len, avail);
- SDL_assert(device->queued_bytes >= avail);
-
- SDL_memcpy(ptr, packet->data + packet->startpos, cpy);
- packet->startpos += cpy;
- ptr += cpy;
- device->queued_bytes -= cpy;
- len -= cpy;
-
- if (packet->startpos == packet->datalen) { /* packet is done, put it in the pool. */
- device->buffer_queue_head = packet->next;
- SDL_assert((packet->next != NULL) || (packet == device->buffer_queue_tail));
- packet->next = device->buffer_queue_pool;
- device->buffer_queue_pool = packet;
- }
- }
-
- SDL_assert((device->buffer_queue_head != NULL) == (device->queued_bytes != 0));
-
- if (device->buffer_queue_head == NULL) {
- device->buffer_queue_tail = NULL; /* in case we drained the queue entirely. */
- }
-
- return (Uint32) (ptr - stream);
-}
-
-static void SDLCALL
-SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len)
-{
- /* this function always holds the mixer lock before being called. */
- SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
- Uint32 written;
-
- SDL_assert(device != NULL); /* this shouldn't ever happen, right?! */
- SDL_assert(!device->iscapture); /* this shouldn't ever happen, right?! */
- SDL_assert(len >= 0); /* this shouldn't ever happen, right?! */
-
- written = dequeue_audio_from_device(device, stream, (Uint32) len);
- stream += written;
- len -= (int) written;
-
- if (len > 0) { /* fill any remaining space in the stream with silence. */
- SDL_assert(device->buffer_queue_head == NULL);
- SDL_memset(stream, device->spec.silence, len);
- }
-}
-
-static void SDLCALL
-SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len)
-{
- /* this function always holds the mixer lock before being called. */
- SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
-
- SDL_assert(device != NULL); /* this shouldn't ever happen, right?! */
- SDL_assert(device->iscapture); /* this shouldn't ever happen, right?! */
- SDL_assert(len >= 0); /* this shouldn't ever happen, right?! */
-
- /* note that if this needs to allocate more space and run out of memory,
- we have no choice but to quietly drop the data and hope it works out
- later, but you probably have bigger problems in this case anyhow. */
- queue_audio_to_device(device, stream, (Uint32) len);
-}
-
-int
-SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- int rc = 0;
-
- if (!device) {
- return -1; /* get_audio_device() will have set the error state */
- } else if (device->iscapture) {
- return SDL_SetError("This is a capture device, queueing not allowed");
- } else if (device->spec.callback != SDL_BufferQueueDrainCallback) {
- return SDL_SetError("Audio device has a callback, queueing not allowed");
- }
-
- if (len > 0) {
- current_audio.impl.LockDevice(device);
- rc = queue_audio_to_device(device, data, len);
- current_audio.impl.UnlockDevice(device);
- }
-
- return rc;
-}
-
-Uint32
-SDL_DequeueAudio(SDL_AudioDeviceID devid, void *data, Uint32 len)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- Uint32 rc;
-
- if ( (len == 0) || /* nothing to do? */
- (!device) || /* called with bogus device id */
- (!device->iscapture) || /* playback devices can't dequeue */
- (device->spec.callback != SDL_BufferQueueFillCallback) ) { /* not set for queueing */
- return 0; /* just report zero bytes dequeued. */
- }
-
- current_audio.impl.LockDevice(device);
- rc = dequeue_audio_from_device(device, data, len);
- current_audio.impl.UnlockDevice(device);
- return rc;
-}
-
-Uint32
-SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
-{
- Uint32 retval = 0;
- SDL_AudioDevice *device = get_audio_device(devid);
-
- if (!device) {
- return 0;
- }
-
- /* Nothing to do unless we're set up for queueing. */
- if (device->spec.callback == SDL_BufferQueueDrainCallback) {
- current_audio.impl.LockDevice(device);
- retval = device->queued_bytes + current_audio.impl.GetPendingBytes(device);
- current_audio.impl.UnlockDevice(device);
- } else if (device->spec.callback == SDL_BufferQueueFillCallback) {
- current_audio.impl.LockDevice(device);
- retval = device->queued_bytes;
- current_audio.impl.UnlockDevice(device);
- }
-
- return retval;
-}
-
-void
-SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- SDL_AudioBufferQueue *packet;
-
- if (!device) {
- return; /* nothing to do. */
- }
-
- /* Blank out the device and release the mutex. Free it afterwards. */
- current_audio.impl.LockDevice(device);
-
- /* merge the available pool and the current queue into one list. */
- packet = device->buffer_queue_head;
- if (packet) {
- device->buffer_queue_tail->next = device->buffer_queue_pool;
- } else {
- packet = device->buffer_queue_pool;
- }
-
- /* Remove the queued packets from the device. */
- device->buffer_queue_tail = NULL;
- device->buffer_queue_head = NULL;
- device->queued_bytes = 0;
- device->buffer_queue_pool = packet;
-
- /* Keep up to two packets in the pool to reduce future malloc pressure. */
- if (packet) {
- if (!packet->next) {
- packet = NULL; /* one packet (the only one) for the pool. */
- } else {
- SDL_AudioBufferQueue *next = packet->next->next;
- packet->next->next = NULL; /* two packets for the pool. */
- packet = next; /* rest will be freed. */
- }
- }
-
- current_audio.impl.UnlockDevice(device);
-
- /* free any extra packets we didn't keep in the pool. */
- free_audio_queue(packet);
-}
-
-
-/* The general mixing thread function */
-static int SDLCALL
-SDL_RunAudio(void *devicep)
-{
- SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
- const int silence = (int) device->spec.silence;
- const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq);
- const int stream_len = (device->convert.needed) ? device->convert.len : device->spec.size;
- Uint8 *stream;
- void *udata = device->spec.userdata;
- void (SDLCALL *callback) (void *, Uint8 *, int) = device->spec.callback;
-
- SDL_assert(!device->iscapture);
-
- /* The audio mixing is always a high priority thread */
- SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
-
- /* Perform any thread setup */
- device->threadid = SDL_ThreadID();
- current_audio.impl.ThreadInit(device);
-
- /* Loop, filling the audio buffers */
- while (!SDL_AtomicGet(&device->shutdown)) {
- /* Fill the current buffer with sound */
- if (device->convert.needed) {
- stream = device->convert.buf;
- } else if (SDL_AtomicGet(&device->enabled)) {
- stream = current_audio.impl.GetDeviceBuf(device);
- } else {
- /* if the device isn't enabled, we still write to the
- fake_stream, so the app's callback will fire with
- a regular frequency, in case they depend on that
- for timing or progress. They can use hotplug
- now to know if the device failed. */
- stream = NULL;
- }
-
- if (stream == NULL) {
- stream = device->fake_stream;
- }
-
- /* !!! FIXME: this should be LockDevice. */
- if ( SDL_AtomicGet(&device->enabled) ) {
- SDL_LockMutex(device->mixer_lock);
- if (SDL_AtomicGet(&device->paused)) {
- SDL_memset(stream, silence, stream_len);
- } else {
- (*callback) (udata, stream, stream_len);
- }
- SDL_UnlockMutex(device->mixer_lock);
- }
-
- /* Convert the audio if necessary */
- if (device->convert.needed && SDL_AtomicGet(&device->enabled)) {
- SDL_ConvertAudio(&device->convert);
- stream = current_audio.impl.GetDeviceBuf(device);
- if (stream == NULL) {
- stream = device->fake_stream;
- } else {
- SDL_memcpy(stream, device->convert.buf,
- device->convert.len_cvt);
- }
- }
-
- /* Ready current buffer for play and change current buffer */
- if (stream == device->fake_stream) {
- SDL_Delay(delay);
- } else {
- current_audio.impl.PlayDevice(device);
- current_audio.impl.WaitDevice(device);
- }
- }
-
- current_audio.impl.PrepareToClose(device);
-
- /* Wait for the audio to drain. */
- SDL_Delay(((device->spec.samples * 1000) / device->spec.freq) * 2);
-
- return 0;
-}
-
-/* The general capture thread function */
-static int SDLCALL
-SDL_CaptureAudio(void *devicep)
-{
- SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
- const int silence = (int) device->spec.silence;
- const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq);
- const int stream_len = (device->convert.needed) ? device->convert.len : device->spec.size;
- Uint8 *stream;
- void *udata = device->spec.userdata;
- void (SDLCALL *callback) (void *, Uint8 *, int) = device->spec.callback;
-
- SDL_assert(device->iscapture);
-
- /* The audio mixing is always a high priority thread */
- SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
-
- /* Perform any thread setup */
- device->threadid = SDL_ThreadID();
- current_audio.impl.ThreadInit(device);
-
- /* Loop, filling the audio buffers */
- while (!SDL_AtomicGet(&device->shutdown)) {
- int still_need;
- Uint8 *ptr;
-
- if (!SDL_AtomicGet(&device->enabled) || SDL_AtomicGet(&device->paused)) {
- SDL_Delay(delay); /* just so we don't cook the CPU. */
- current_audio.impl.FlushCapture(device); /* dump anything pending. */
- continue;
- }
-
- /* Fill the current buffer with sound */
- still_need = stream_len;
- if (device->convert.needed) {
- ptr = stream = device->convert.buf;
- } else {
- /* just use the "fake" stream to hold data read from the device. */
- ptr = stream = device->fake_stream;
- }
-
- /* We still read from the device when "paused" to keep the state sane,
- and block when there isn't data so this thread isn't eating CPU.
- But we don't process it further or call the app's callback. */
-
- while (still_need > 0) {
- const int rc = current_audio.impl.CaptureFromDevice(device, ptr, still_need);
- SDL_assert(rc <= still_need); /* device should not overflow buffer. :) */
- if (rc > 0) {
- still_need -= rc;
- ptr += rc;
- } else { /* uhoh, device failed for some reason! */
- SDL_OpenedAudioDeviceDisconnected(device);
- break;
- }
- }
-
- if (still_need > 0) {
- /* Keep any data we already read, silence the rest. */
- SDL_memset(ptr, silence, still_need);
- }
-
- if (device->convert.needed) {
- SDL_ConvertAudio(&device->convert);
- }
-
- /* !!! FIXME: this should be LockDevice. */
- SDL_LockMutex(device->mixer_lock);
- if (SDL_AtomicGet(&device->paused)) {
- current_audio.impl.FlushCapture(device); /* one snuck in! */
- } else {
- (*callback)(udata, stream, stream_len);
- }
- SDL_UnlockMutex(device->mixer_lock);
- }
-
- current_audio.impl.FlushCapture(device);
-
- return 0;
-}
-
-
-static SDL_AudioFormat
-SDL_ParseAudioFormat(const char *string)
-{
-#define CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x
- CHECK_FMT_STRING(U8);
- CHECK_FMT_STRING(S8);
- CHECK_FMT_STRING(U16LSB);
- CHECK_FMT_STRING(S16LSB);
- CHECK_FMT_STRING(U16MSB);
- CHECK_FMT_STRING(S16MSB);
- CHECK_FMT_STRING(U16SYS);
- CHECK_FMT_STRING(S16SYS);
- CHECK_FMT_STRING(U16);
- CHECK_FMT_STRING(S16);
- CHECK_FMT_STRING(S32LSB);
- CHECK_FMT_STRING(S32MSB);
- CHECK_FMT_STRING(S32SYS);
- CHECK_FMT_STRING(S32);
- CHECK_FMT_STRING(F32LSB);
- CHECK_FMT_STRING(F32MSB);
- CHECK_FMT_STRING(F32SYS);
- CHECK_FMT_STRING(F32);
-#undef CHECK_FMT_STRING
- return 0;
-}
-
-int
-SDL_GetNumAudioDrivers(void)
-{
- return SDL_arraysize(bootstrap) - 1;
-}
-
-const char *
-SDL_GetAudioDriver(int index)
-{
- if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
- return bootstrap[index]->name;
- }
- return NULL;
-}
-
-int
-SDL_AudioInit(const char *driver_name)
-{
- int i = 0;
- int initialized = 0;
- int tried_to_init = 0;
-
- if (SDL_WasInit(SDL_INIT_AUDIO)) {
- SDL_AudioQuit(); /* shutdown driver if already running. */
- }
-
- SDL_zero(current_audio);
- SDL_zero(open_devices);
-
- /* Select the proper audio driver */
- if (driver_name == NULL) {
- driver_name = SDL_getenv("SDL_AUDIODRIVER");
- }
-
- for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
- /* make sure we should even try this driver before doing so... */
- const AudioBootStrap *backend = bootstrap[i];
- if ((driver_name && (SDL_strncasecmp(backend->name, driver_name, SDL_strlen(driver_name)) != 0)) ||
- (!driver_name && backend->demand_only)) {
- continue;
- }
-
- tried_to_init = 1;
- SDL_zero(current_audio);
- current_audio.name = backend->name;
- current_audio.desc = backend->desc;
- initialized = backend->init(&current_audio.impl);
- }
-
- if (!initialized) {
- /* specific drivers will set the error message if they fail... */
- if (!tried_to_init) {
- if (driver_name) {
- SDL_SetError("Audio target '%s' not available", driver_name);
- } else {
- SDL_SetError("No available audio device");
- }
- }
-
- SDL_zero(current_audio);
- return -1; /* No driver was available, so fail. */
- }
-
- current_audio.detectionLock = SDL_CreateMutex();
-
- finish_audio_entry_points_init();
-
- /* Make sure we have a list of devices available at startup. */
- current_audio.impl.DetectDevices();
-
- return 0;
-}
-
-/*
- * Get the current audio driver name
- */
-const char *
-SDL_GetCurrentAudioDriver()
-{
- return current_audio.name;
-}
-
-/* Clean out devices that we've removed but had to keep around for stability. */
-static void
-clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag)
-{
- SDL_AudioDeviceItem *item = *devices;
- SDL_AudioDeviceItem *prev = NULL;
- int total = 0;
-
- while (item) {
- SDL_AudioDeviceItem *next = item->next;
- if (item->handle != NULL) {
- total++;
- prev = item;
- } else {
- if (prev) {
- prev->next = next;
- } else {
- *devices = next;
- }
- SDL_free(item);
- }
- item = next;
- }
-
- *devCount = total;
- *removedFlag = SDL_FALSE;
-}
-
-
-int
-SDL_GetNumAudioDevices(int iscapture)
-{
- int retval = 0;
-
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- return -1;
- }
-
- SDL_LockMutex(current_audio.detectionLock);
- if (iscapture && current_audio.captureDevicesRemoved) {
- clean_out_device_list(&current_audio.inputDevices, &current_audio.inputDeviceCount, &current_audio.captureDevicesRemoved);
- }
-
- if (!iscapture && current_audio.outputDevicesRemoved) {
- clean_out_device_list(&current_audio.outputDevices, &current_audio.outputDeviceCount, &current_audio.outputDevicesRemoved);
- current_audio.outputDevicesRemoved = SDL_FALSE;
- }
-
- retval = iscapture ? current_audio.inputDeviceCount : current_audio.outputDeviceCount;
- SDL_UnlockMutex(current_audio.detectionLock);
-
- return retval;
-}
-
-
-const char *
-SDL_GetAudioDeviceName(int index, int iscapture)
-{
- const char *retval = NULL;
-
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- SDL_SetError("Audio subsystem is not initialized");
- return NULL;
- }
-
- if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
- SDL_SetError("No capture support");
- return NULL;
- }
-
- if (index >= 0) {
- SDL_AudioDeviceItem *item;
- int i;
-
- SDL_LockMutex(current_audio.detectionLock);
- item = iscapture ? current_audio.inputDevices : current_audio.outputDevices;
- i = iscapture ? current_audio.inputDeviceCount : current_audio.outputDeviceCount;
- if (index < i) {
- for (i--; i > index; i--, item = item->next) {
- SDL_assert(item != NULL);
- }
- SDL_assert(item != NULL);
- retval = item->name;
- }
- SDL_UnlockMutex(current_audio.detectionLock);
- }
-
- if (retval == NULL) {
- SDL_SetError("No such device");
- }
-
- return retval;
-}
-
-
-static void
-close_audio_device(SDL_AudioDevice * device)
-{
- if (!device) {
- return;
- }
-
- if (device->id > 0) {
- SDL_AudioDevice *opendev = open_devices[device->id - 1];
- SDL_assert((opendev == device) || (opendev == NULL));
- if (opendev == device) {
- open_devices[device->id - 1] = NULL;
- }
- }
-
- SDL_AtomicSet(&device->shutdown, 1);
- SDL_AtomicSet(&device->enabled, 0);
- if (device->thread != NULL) {
- SDL_WaitThread(device->thread, NULL);
- }
- if (device->mixer_lock != NULL) {
- SDL_DestroyMutex(device->mixer_lock);
- }
- SDL_free(device->fake_stream);
- if (device->convert.needed) {
- SDL_free(device->convert.buf);
- }
- if (device->hidden != NULL) {
- current_audio.impl.CloseDevice(device);
- }
-
- free_audio_queue(device->buffer_queue_head);
- free_audio_queue(device->buffer_queue_pool);
-
- SDL_free(device);
-}
-
-
-/*
- * Sanity check desired AudioSpec for SDL_OpenAudio() in (orig).
- * Fills in a sanitized copy in (prepared).
- * Returns non-zero if okay, zero on fatal parameters in (orig).
- */
-static int
-prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
-{
- SDL_memcpy(prepared, orig, sizeof(SDL_AudioSpec));
-
- if (orig->freq == 0) {
- const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
- if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
- prepared->freq = 22050; /* a reasonable default */
- }
- }
-
- if (orig->format == 0) {
- const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
- if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) {
- prepared->format = AUDIO_S16; /* a reasonable default */
- }
- }
-
- switch (orig->channels) {
- case 0:{
- const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
- if ((!env) || ((prepared->channels = (Uint8) SDL_atoi(env)) == 0)) {
- prepared->channels = 2; /* a reasonable default */
- }
- break;
- }
- case 1: /* Mono */
- case 2: /* Stereo */
- case 4: /* surround */
- case 6: /* surround with center and lfe */
- break;
- default:
- SDL_SetError("Unsupported number of audio channels.");
- return 0;
- }
-
- if (orig->samples == 0) {
- const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
- if ((!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0)) {
- /* Pick a default of ~46 ms at desired frequency */
- /* !!! FIXME: remove this when the non-Po2 resampling is in. */
- const int samples = (prepared->freq / 1000) * 46;
- int power2 = 1;
- while (power2 < samples) {
- power2 *= 2;
- }
- prepared->samples = power2;
- }
- }
-
- /* Calculate the silence and size of the audio specification */
- SDL_CalculateAudioSpec(prepared);
-
- return 1;
-}
-
-static SDL_AudioDeviceID
-open_audio_device(const char *devname, int iscapture,
- const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
- int allowed_changes, int min_id)
-{
- const SDL_bool is_internal_thread = (desired->callback != NULL);
- SDL_AudioDeviceID id = 0;
- SDL_AudioSpec _obtained;
- SDL_AudioDevice *device;
- SDL_bool build_cvt;
- void *handle = NULL;
- int i = 0;
-
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- SDL_SetError("Audio subsystem is not initialized");
- return 0;
- }
-
- if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
- SDL_SetError("No capture support");
- return 0;
- }
-
- /* !!! FIXME: there is a race condition here if two devices open from two threads at once. */
- /* Find an available device ID... */
- for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) {
- if (open_devices[id] == NULL) {
- break;
- }
- }
-
- if (id == SDL_arraysize(open_devices)) {
- SDL_SetError("Too many open audio devices");
- return 0;
- }
-
- if (!obtained) {
- obtained = &_obtained;
- }
- if (!prepare_audiospec(desired, obtained)) {
- return 0;
- }
-
- /* If app doesn't care about a specific device, let the user override. */
- if (devname == NULL) {
- devname = SDL_getenv("SDL_AUDIO_DEVICE_NAME");
- }
-
- /*
- * Catch device names at the high level for the simple case...
- * This lets us have a basic "device enumeration" for systems that
- * don't have multiple devices, but makes sure the device name is
- * always NULL when it hits the low level.
- *
- * Also make sure that the simple case prevents multiple simultaneous
- * opens of the default system device.
- */
-
- if ((iscapture) && (current_audio.impl.OnlyHasDefaultCaptureDevice)) {
- if ((devname) && (SDL_strcmp(devname, DEFAULT_INPUT_DEVNAME) != 0)) {
- SDL_SetError("No such device");
- return 0;
- }
- devname = NULL;
-
- for (i = 0; i < SDL_arraysize(open_devices); i++) {
- if ((open_devices[i]) && (open_devices[i]->iscapture)) {
- SDL_SetError("Audio device already open");
- return 0;
- }
- }
- } else if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
- if ((devname) && (SDL_strcmp(devname, DEFAULT_OUTPUT_DEVNAME) != 0)) {
- SDL_SetError("No such device");
- return 0;
- }
- devname = NULL;
-
- for (i = 0; i < SDL_arraysize(open_devices); i++) {
- if ((open_devices[i]) && (!open_devices[i]->iscapture)) {
- SDL_SetError("Audio device already open");
- return 0;
- }
- }
- } else if (devname != NULL) {
- /* if the app specifies an exact string, we can pass the backend
- an actual device handle thingey, which saves them the effort of
- figuring out what device this was (such as, reenumerating
- everything again to find the matching human-readable name).
- It might still need to open a device based on the string for,
- say, a network audio server, but this optimizes some cases. */
- SDL_AudioDeviceItem *item;
- SDL_LockMutex(current_audio.detectionLock);
- for (item = iscapture ? current_audio.inputDevices : current_audio.outputDevices; item; item = item->next) {
- if ((item->handle != NULL) && (SDL_strcmp(item->name, devname) == 0)) {
- handle = item->handle;
- break;
- }
- }
- SDL_UnlockMutex(current_audio.detectionLock);
- }
-
- if (!current_audio.impl.AllowsArbitraryDeviceNames) {
- /* has to be in our device list, or the default device. */
- if ((handle == NULL) && (devname != NULL)) {
- SDL_SetError("No such device.");
- return 0;
- }
- }
-
- device = (SDL_AudioDevice *) SDL_calloc(1, sizeof (SDL_AudioDevice));
- if (device == NULL) {
- SDL_OutOfMemory();
- return 0;
- }
- device->id = id + 1;
- device->spec = *obtained;
- device->iscapture = iscapture ? SDL_TRUE : SDL_FALSE;
- device->handle = handle;
-
- SDL_AtomicSet(&device->shutdown, 0); /* just in case. */
- SDL_AtomicSet(&device->paused, 1);
- SDL_AtomicSet(&device->enabled, 1);
-
- /* Create a mutex for locking the sound buffers */
- if (!current_audio.impl.SkipMixerLock) {
- device->mixer_lock = SDL_CreateMutex();
- if (device->mixer_lock == NULL) {
- close_audio_device(device);
- SDL_SetError("Couldn't create mixer lock");
- return 0;
- }
- }
-
- if (current_audio.impl.OpenDevice(device, handle, devname, iscapture) < 0) {
- close_audio_device(device);
- return 0;
- }
-
- /* if your target really doesn't need it, set it to 0x1 or something. */
- /* otherwise, close_audio_device() won't call impl.CloseDevice(). */
- SDL_assert(device->hidden != NULL);
-
- /* See if we need to do any conversion */
- build_cvt = SDL_FALSE;
- if (obtained->freq != device->spec.freq) {
- if (allowed_changes & SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) {
- obtained->freq = device->spec.freq;
- } else {
- build_cvt = SDL_TRUE;
- }
- }
- if (obtained->format != device->spec.format) {
- if (allowed_changes & SDL_AUDIO_ALLOW_FORMAT_CHANGE) {
- obtained->format = device->spec.format;
- } else {
- build_cvt = SDL_TRUE;
- }
- }
- if (obtained->channels != device->spec.channels) {
- if (allowed_changes & SDL_AUDIO_ALLOW_CHANNELS_CHANGE) {
- obtained->channels = device->spec.channels;
- } else {
- build_cvt = SDL_TRUE;
- }
- }
-
- /* If the audio driver changes the buffer size, accept it.
- This needs to be done after the format is modified above,
- otherwise it might not have the correct buffer size.
- */
- if (device->spec.samples != obtained->samples) {
- obtained->samples = device->spec.samples;
- SDL_CalculateAudioSpec(obtained);
- }
-
- if (build_cvt) {
- /* Build an audio conversion block */
- if (SDL_BuildAudioCVT(&device->convert,
- obtained->format, obtained->channels,
- obtained->freq,
- device->spec.format, device->spec.channels,
- device->spec.freq) < 0) {
- close_audio_device(device);
- return 0;
- }
- if (device->convert.needed) {
- device->convert.len = (int) (((double) device->spec.size) /
- device->convert.len_ratio);
-
- device->convert.buf =
- (Uint8 *) SDL_malloc(device->convert.len *
- device->convert.len_mult);
- if (device->convert.buf == NULL) {
- close_audio_device(device);
- SDL_OutOfMemory();
- return 0;
- }
- }
- }
-
- if (device->spec.callback == NULL) { /* use buffer queueing? */
- /* pool a few packets to start. Enough for two callbacks. */
- const int packetlen = SDL_AUDIOBUFFERQUEUE_PACKETLEN;
- const int wantbytes = ((device->convert.needed) ? device->convert.len : device->spec.size) * 2;
- const int wantpackets = (wantbytes / packetlen) + ((wantbytes % packetlen) ? packetlen : 0);
- for (i = 0; i < wantpackets; i++) {
- SDL_AudioBufferQueue *packet = (SDL_AudioBufferQueue *) SDL_malloc(sizeof (SDL_AudioBufferQueue));
- if (packet) { /* don't care if this fails, we'll deal later. */
- packet->datalen = 0;
- packet->startpos = 0;
- packet->next = device->buffer_queue_pool;
- device->buffer_queue_pool = packet;
- }
- }
-
- device->spec.callback = iscapture ? SDL_BufferQueueFillCallback : SDL_BufferQueueDrainCallback;
- device->spec.userdata = device;
- }
-
- /* add it to our list of open devices. */
- open_devices[id] = device;
-
- /* Start the audio thread if necessary */
- if (!current_audio.impl.ProvidesOwnCallbackThread) {
- /* Start the audio thread */
- /* !!! FIXME: we don't force the audio thread stack size here if it calls into user code, but maybe we should? */
- /* buffer queueing callback only needs a few bytes, so make the stack tiny. */
- const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
- char threadname[64];
-
- /* Allocate a fake audio buffer; only used by our internal threads. */
- Uint32 stream_len = (device->convert.needed) ? device->convert.len_cvt : 0;
- if (device->spec.size > stream_len) {
- stream_len = device->spec.size;
- }
- SDL_assert(stream_len > 0);
-
- device->fake_stream = (Uint8 *) SDL_malloc(stream_len);
- if (device->fake_stream == NULL) {
- close_audio_device(device);
- SDL_OutOfMemory();
- return 0;
- }
-
- SDL_snprintf(threadname, sizeof (threadname), "SDLAudioDev%d", (int) device->id);
- device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device);
-
- if (device->thread == NULL) {
- close_audio_device(device);
- SDL_SetError("Couldn't create audio thread");
- return 0;
- }
- }
-
- return device->id;
-}
-
-
-int
-SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
-{
- SDL_AudioDeviceID id = 0;
-
- /* Start up the audio driver, if necessary. This is legacy behaviour! */
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
- return -1;
- }
- }
-
- /* SDL_OpenAudio() is legacy and can only act on Device ID #1. */
- if (open_devices[0] != NULL) {
- SDL_SetError("Audio device is already opened");
- return -1;
- }
-
- if (obtained) {
- id = open_audio_device(NULL, 0, desired, obtained,
- SDL_AUDIO_ALLOW_ANY_CHANGE, 1);
- } else {
- id = open_audio_device(NULL, 0, desired, NULL, 0, 1);
- }
-
- SDL_assert((id == 0) || (id == 1));
- return (id == 0) ? -1 : 0;
-}
-
-SDL_AudioDeviceID
-SDL_OpenAudioDevice(const char *device, int iscapture,
- const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
- int allowed_changes)
-{
- return open_audio_device(device, iscapture, desired, obtained,
- allowed_changes, 2);
-}
-
-SDL_AudioStatus
-SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- SDL_AudioStatus status = SDL_AUDIO_STOPPED;
- if (device && SDL_AtomicGet(&device->enabled)) {
- if (SDL_AtomicGet(&device->paused)) {
- status = SDL_AUDIO_PAUSED;
- } else {
- status = SDL_AUDIO_PLAYING;
- }
- }
- return status;
-}
-
-
-SDL_AudioStatus
-SDL_GetAudioStatus(void)
-{
- return SDL_GetAudioDeviceStatus(1);
-}
-
-void
-SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- if (device) {
- current_audio.impl.LockDevice(device);
- SDL_AtomicSet(&device->paused, pause_on ? 1 : 0);
- current_audio.impl.UnlockDevice(device);
- }
-}
-
-void
-SDL_PauseAudio(int pause_on)
-{
- SDL_PauseAudioDevice(1, pause_on);
-}
-
-
-void
-SDL_LockAudioDevice(SDL_AudioDeviceID devid)
-{
- /* Obtain a lock on the mixing buffers */
- SDL_AudioDevice *device = get_audio_device(devid);
- if (device) {
- current_audio.impl.LockDevice(device);
- }
-}
-
-void
-SDL_LockAudio(void)
-{
- SDL_LockAudioDevice(1);
-}
-
-void
-SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
-{
- /* Obtain a lock on the mixing buffers */
- SDL_AudioDevice *device = get_audio_device(devid);
- if (device) {
- current_audio.impl.UnlockDevice(device);
- }
-}
-
-void
-SDL_UnlockAudio(void)
-{
- SDL_UnlockAudioDevice(1);
-}
-
-void
-SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
-{
- close_audio_device(get_audio_device(devid));
-}
-
-void
-SDL_CloseAudio(void)
-{
- SDL_CloseAudioDevice(1);
-}
-
-void
-SDL_AudioQuit(void)
-{
- SDL_AudioDeviceID i;
-
- if (!current_audio.name) { /* not initialized?! */
- return;
- }
-
- for (i = 0; i < SDL_arraysize(open_devices); i++) {
- close_audio_device(open_devices[i]);
- }
-
- free_device_list(&current_audio.outputDevices, &current_audio.outputDeviceCount);
- free_device_list(&current_audio.inputDevices, &current_audio.inputDeviceCount);
-
- /* Free the driver data */
- current_audio.impl.Deinitialize();
-
- SDL_DestroyMutex(current_audio.detectionLock);
-
- SDL_zero(current_audio);
- SDL_zero(open_devices);
-}
-
-#define NUM_FORMATS 10
-static int format_idx;
-static int format_idx_sub;
-static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = {
- {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
- AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
- {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
- AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
- {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB,
- AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB,
- AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB,
- AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB,
- AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S16LSB,
- AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S16MSB,
- AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S16LSB,
- AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_S16MSB,
- AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
-};
-
-SDL_AudioFormat
-SDL_FirstAudioFormat(SDL_AudioFormat format)
-{
- for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
- if (format_list[format_idx][0] == format) {
- break;
- }
- }
- format_idx_sub = 0;
- return SDL_NextAudioFormat();
-}
-
-SDL_AudioFormat
-SDL_NextAudioFormat(void)
-{
- if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
- return 0;
- }
- return format_list[format_idx][format_idx_sub++];
-}
-
-void
-SDL_CalculateAudioSpec(SDL_AudioSpec * spec)
-{
- switch (spec->format) {
- case AUDIO_U8:
- spec->silence = 0x80;
- break;
- default:
- spec->silence = 0x00;
- break;
- }
- spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
- spec->size *= spec->channels;
- spec->size *= spec->samples;
-}
-
-
-/*
- * Moved here from SDL_mixer.c, since it relies on internals of an opened
- * audio device (and is deprecated, by the way!).
- */
-void
-SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume)
-{
- /* Mix the user-level audio format */
- SDL_AudioDevice *device = get_audio_device(1);
- if (device != NULL) {
- SDL_AudioFormat format;
- if (device->convert.needed) {
- format = device->convert.src_format;
- } else {
- format = device->spec.format;
- }
- SDL_MixAudioFormat(dst, src, format, len, volume);
- }
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_audio_c.h b/3rdparty/SDL2/src/audio/SDL_audio_c.h
deleted file mode 100644
index 7cde3a66253..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_audio_c.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-/* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */
-
-/* Functions to get a list of "close" audio formats */
-extern SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format);
-extern SDL_AudioFormat SDL_NextAudioFormat(void);
-
-/* Function to calculate the size and silence for a SDL_AudioSpec */
-extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec);
-
-/* this is used internally to access some autogenerated code. */
-typedef struct
-{
- SDL_AudioFormat src_fmt;
- SDL_AudioFormat dst_fmt;
- SDL_AudioFilter filter;
-} SDL_AudioTypeFilters;
-extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
-
-/* this is used internally to access some autogenerated code. */
-typedef struct
-{
- SDL_AudioFormat fmt;
- int channels;
- int upsample;
- int multiple;
- SDL_AudioFilter filter;
-} SDL_AudioRateFilters;
-extern const SDL_AudioRateFilters sdl_audio_rate_filters[];
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_audiocvt.c b/3rdparty/SDL2/src/audio/SDL_audiocvt.c
deleted file mode 100644
index 3b47c4cbcc0..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_audiocvt.c
+++ /dev/null
@@ -1,1121 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-/* Functions for audio drivers to perform runtime conversion of audio format */
-
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-
-#include "SDL_assert.h"
-
-/* #define DEBUG_CONVERT */
-
-/* Effectively mix right and left channels into a single channel */
-static void SDLCALL
-SDL_ConvertMono(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- Sint32 sample;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting to mono\n");
-#endif
- switch (format & (SDL_AUDIO_MASK_SIGNED |
- SDL_AUDIO_MASK_BITSIZE |
- SDL_AUDIO_MASK_DATATYPE)) {
- case AUDIO_U8:
- {
- Uint8 *src, *dst;
-
- src = cvt->buf;
- dst = cvt->buf;
- for (i = cvt->len_cvt / 2; i; --i) {
- sample = src[0] + src[1];
- *dst = (Uint8) (sample / 2);
- src += 2;
- dst += 1;
- }
- }
- break;
-
- case AUDIO_S8:
- {
- Sint8 *src, *dst;
-
- src = (Sint8 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / 2; i; --i) {
- sample = src[0] + src[1];
- *dst = (Sint8) (sample / 2);
- src += 2;
- dst += 1;
- }
- }
- break;
-
- case AUDIO_U16:
- {
- Uint8 *src, *dst;
-
- src = cvt->buf;
- dst = cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Uint16) ((src[0] << 8) | src[1]) +
- (Uint16) ((src[2] << 8) | src[3]);
- sample /= 2;
- dst[1] = (sample & 0xFF);
- sample >>= 8;
- dst[0] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Uint16) ((src[1] << 8) | src[0]) +
- (Uint16) ((src[3] << 8) | src[2]);
- sample /= 2;
- dst[0] = (sample & 0xFF);
- sample >>= 8;
- dst[1] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- }
- }
- break;
-
- case AUDIO_S16:
- {
- Uint8 *src, *dst;
-
- src = cvt->buf;
- dst = cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Sint16) ((src[0] << 8) | src[1]) +
- (Sint16) ((src[2] << 8) | src[3]);
- sample /= 2;
- dst[1] = (sample & 0xFF);
- sample >>= 8;
- dst[0] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Sint16) ((src[1] << 8) | src[0]) +
- (Sint16) ((src[3] << 8) | src[2]);
- sample /= 2;
- dst[0] = (sample & 0xFF);
- sample >>= 8;
- dst[1] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- }
- }
- break;
-
- case AUDIO_S32:
- {
- const Uint32 *src = (const Uint32 *) cvt->buf;
- Uint32 *dst = (Uint32 *) cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const Sint64 added =
- (((Sint64) (Sint32) SDL_SwapBE32(src[0])) +
- ((Sint64) (Sint32) SDL_SwapBE32(src[1])));
- *(dst++) = SDL_SwapBE32((Uint32) ((Sint32) (added / 2)));
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const Sint64 added =
- (((Sint64) (Sint32) SDL_SwapLE32(src[0])) +
- ((Sint64) (Sint32) SDL_SwapLE32(src[1])));
- *(dst++) = SDL_SwapLE32((Uint32) ((Sint32) (added / 2)));
- }
- }
- }
- break;
-
- case AUDIO_F32:
- {
- const float *src = (const float *) cvt->buf;
- float *dst = (float *) cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const float src1 = SDL_SwapFloatBE(src[0]);
- const float src2 = SDL_SwapFloatBE(src[1]);
- const double added = ((double) src1) + ((double) src2);
- const float halved = (float) (added * 0.5);
- *(dst++) = SDL_SwapFloatBE(halved);
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const float src1 = SDL_SwapFloatLE(src[0]);
- const float src2 = SDL_SwapFloatLE(src[1]);
- const double added = ((double) src1) + ((double) src2);
- const float halved = (float) (added * 0.5);
- *(dst++) = SDL_SwapFloatLE(halved);
- }
- }
- }
- break;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Discard top 4 channels */
-static void SDLCALL
-SDL_ConvertStrip(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting down from 6 channels to stereo\n");
-#endif
-
-#define strip_chans_6_to_2(type) \
- { \
- const type *src = (const type *) cvt->buf; \
- type *dst = (type *) cvt->buf; \
- for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
- dst[0] = src[0]; \
- dst[1] = src[1]; \
- src += 6; \
- dst += 2; \
- } \
- }
-
- /* this function only cares about typesize, and data as a block of bits. */
- switch (SDL_AUDIO_BITSIZE(format)) {
- case 8:
- strip_chans_6_to_2(Uint8);
- break;
- case 16:
- strip_chans_6_to_2(Uint16);
- break;
- case 32:
- strip_chans_6_to_2(Uint32);
- break;
- }
-
-#undef strip_chans_6_to_2
-
- cvt->len_cvt /= 3;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Discard top 2 channels of 6 */
-static void SDLCALL
-SDL_ConvertStrip_2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting 6 down to quad\n");
-#endif
-
-#define strip_chans_6_to_4(type) \
- { \
- const type *src = (const type *) cvt->buf; \
- type *dst = (type *) cvt->buf; \
- for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
- dst[0] = src[0]; \
- dst[1] = src[1]; \
- dst[2] = src[2]; \
- dst[3] = src[3]; \
- src += 6; \
- dst += 4; \
- } \
- }
-
- /* this function only cares about typesize, and data as a block of bits. */
- switch (SDL_AUDIO_BITSIZE(format)) {
- case 8:
- strip_chans_6_to_4(Uint8);
- break;
- case 16:
- strip_chans_6_to_4(Uint16);
- break;
- case 32:
- strip_chans_6_to_4(Uint32);
- break;
- }
-
-#undef strip_chans_6_to_4
-
- cvt->len_cvt /= 6;
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-/* Duplicate a mono channel to both stereo channels */
-static void SDLCALL
-SDL_ConvertStereo(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting to stereo\n");
-#endif
-
-#define dup_chans_1_to_2(type) \
- { \
- const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
- type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
- for (i = cvt->len_cvt / sizeof(type); i; --i) { \
- src -= 1; \
- dst -= 2; \
- dst[0] = dst[1] = *src; \
- } \
- }
-
- /* this function only cares about typesize, and data as a block of bits. */
- switch (SDL_AUDIO_BITSIZE(format)) {
- case 8:
- dup_chans_1_to_2(Uint8);
- break;
- case 16:
- dup_chans_1_to_2(Uint16);
- break;
- case 32:
- dup_chans_1_to_2(Uint32);
- break;
- }
-
-#undef dup_chans_1_to_2
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Duplicate a stereo channel to a pseudo-5.1 stream */
-static void SDLCALL
-SDL_ConvertSurround(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting stereo to surround\n");
-#endif
-
- switch (format & (SDL_AUDIO_MASK_SIGNED |
- SDL_AUDIO_MASK_BITSIZE |
- SDL_AUDIO_MASK_DATATYPE)) {
- case AUDIO_U8:
- {
- Uint8 *src, *dst, lf, rf, ce;
-
- src = (Uint8 *) (cvt->buf + cvt->len_cvt);
- dst = (Uint8 *) (cvt->buf + cvt->len_cvt * 3);
- for (i = cvt->len_cvt; i; --i) {
- dst -= 6;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- dst[4] = ce;
- dst[5] = ce;
- }
- }
- break;
-
- case AUDIO_S8:
- {
- Sint8 *src, *dst, lf, rf, ce;
-
- src = (Sint8 *) cvt->buf + cvt->len_cvt;
- dst = (Sint8 *) cvt->buf + cvt->len_cvt * 3;
- for (i = cvt->len_cvt; i; --i) {
- dst -= 6;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- dst[4] = ce;
- dst[5] = ce;
- }
- }
- break;
-
- case AUDIO_U16:
- {
- Uint8 *src, *dst;
- Uint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 3;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Uint16) ((src[0] << 8) | src[1]);
- rf = (Uint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
-
- dst[1 + 8] = (ce & 0xFF);
- dst[0 + 8] = ((ce >> 8) & 0xFF);
- dst[3 + 8] = (ce & 0xFF);
- dst[2 + 8] = ((ce >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Uint16) ((src[1] << 8) | src[0]);
- rf = (Uint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
-
- dst[0 + 8] = (ce & 0xFF);
- dst[1 + 8] = ((ce >> 8) & 0xFF);
- dst[2 + 8] = (ce & 0xFF);
- dst[3 + 8] = ((ce >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S16:
- {
- Uint8 *src, *dst;
- Sint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 3;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Sint16) ((src[0] << 8) | src[1]);
- rf = (Sint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
-
- dst[1 + 8] = (ce & 0xFF);
- dst[0 + 8] = ((ce >> 8) & 0xFF);
- dst[3 + 8] = (ce & 0xFF);
- dst[2 + 8] = ((ce >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Sint16) ((src[1] << 8) | src[0]);
- rf = (Sint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
-
- dst[0 + 8] = (ce & 0xFF);
- dst[1 + 8] = ((ce >> 8) & 0xFF);
- dst[2 + 8] = (ce & 0xFF);
- dst[3 + 8] = ((ce >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S32:
- {
- Sint32 lf, rf, ce;
- const Uint32 *src = (const Uint32 *) (cvt->buf + cvt->len_cvt);
- Uint32 *dst = (Uint32 *) (cvt->buf + cvt->len_cvt * 3);
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = (Sint32) SDL_SwapBE32(src[0]);
- rf = (Sint32) SDL_SwapBE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = SDL_SwapBE32((Uint32) lf);
- dst[1] = SDL_SwapBE32((Uint32) rf);
- dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
- dst[4] = SDL_SwapBE32((Uint32) ce);
- dst[5] = SDL_SwapBE32((Uint32) ce);
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = (Sint32) SDL_SwapLE32(src[0]);
- rf = (Sint32) SDL_SwapLE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
- dst[4] = SDL_SwapLE32((Uint32) ce);
- dst[5] = SDL_SwapLE32((Uint32) ce);
- }
- }
- }
- break;
-
- case AUDIO_F32:
- {
- float lf, rf, ce;
- const float *src = (const float *) (cvt->buf + cvt->len_cvt);
- float *dst = (float *) (cvt->buf + cvt->len_cvt * 3);
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = SDL_SwapFloatBE(src[0]);
- rf = SDL_SwapFloatBE(src[1]);
- ce = (lf * 0.5f) + (rf * 0.5f);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapFloatBE(lf - ce);
- dst[3] = SDL_SwapFloatBE(rf - ce);
- dst[4] = dst[5] = SDL_SwapFloatBE(ce);
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = SDL_SwapFloatLE(src[0]);
- rf = SDL_SwapFloatLE(src[1]);
- ce = (lf * 0.5f) + (rf * 0.5f);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapFloatLE(lf - ce);
- dst[3] = SDL_SwapFloatLE(rf - ce);
- dst[4] = dst[5] = SDL_SwapFloatLE(ce);
- }
- }
- }
- break;
-
- }
- cvt->len_cvt *= 3;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Duplicate a stereo channel to a pseudo-4.0 stream */
-static void SDLCALL
-SDL_ConvertSurround_4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting stereo to quad\n");
-#endif
-
- switch (format & (SDL_AUDIO_MASK_SIGNED |
- SDL_AUDIO_MASK_BITSIZE |
- SDL_AUDIO_MASK_DATATYPE)) {
- case AUDIO_U8:
- {
- Uint8 *src, *dst, lf, rf, ce;
-
- src = (Uint8 *) (cvt->buf + cvt->len_cvt);
- dst = (Uint8 *) (cvt->buf + cvt->len_cvt * 2);
- for (i = cvt->len_cvt; i; --i) {
- dst -= 4;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- }
- }
- break;
-
- case AUDIO_S8:
- {
- Sint8 *src, *dst, lf, rf, ce;
-
- src = (Sint8 *) cvt->buf + cvt->len_cvt;
- dst = (Sint8 *) cvt->buf + cvt->len_cvt * 2;
- for (i = cvt->len_cvt; i; --i) {
- dst -= 4;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- }
- }
- break;
-
- case AUDIO_U16:
- {
- Uint8 *src, *dst;
- Uint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 2;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Uint16) ((src[0] << 8) | src[1]);
- rf = (Uint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Uint16) ((src[1] << 8) | src[0]);
- rf = (Uint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S16:
- {
- Uint8 *src, *dst;
- Sint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 2;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Sint16) ((src[0] << 8) | src[1]);
- rf = (Sint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Sint16) ((src[1] << 8) | src[0]);
- rf = (Sint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S32:
- {
- const Uint32 *src = (const Uint32 *) (cvt->buf + cvt->len_cvt);
- Uint32 *dst = (Uint32 *) (cvt->buf + cvt->len_cvt * 2);
- Sint32 lf, rf, ce;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 4;
- src -= 2;
- lf = (Sint32) SDL_SwapBE32(src[0]);
- rf = (Sint32) SDL_SwapBE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 4;
- src -= 2;
- lf = (Sint32) SDL_SwapLE32(src[0]);
- rf = (Sint32) SDL_SwapLE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
- }
- }
- }
- break;
-
- case AUDIO_F32:
- {
- const float *src = (const float *) (cvt->buf + cvt->len_cvt);
- float *dst = (float *) (cvt->buf + cvt->len_cvt * 2);
- float lf, rf, ce;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 4;
- src -= 2;
- lf = SDL_SwapFloatBE(src[0]);
- rf = SDL_SwapFloatBE(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapFloatBE(lf - ce);
- dst[3] = SDL_SwapFloatBE(rf - ce);
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 4;
- src -= 2;
- lf = SDL_SwapFloatLE(src[0]);
- rf = SDL_SwapFloatLE(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapFloatLE(lf - ce);
- dst[3] = SDL_SwapFloatLE(rf - ce);
- }
- }
- }
- break;
- }
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-int
-SDL_ConvertAudio(SDL_AudioCVT * cvt)
-{
- /* !!! FIXME: (cvt) should be const; stack-copy it here. */
- /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */
-
- /* Make sure there's data to convert */
- if (cvt->buf == NULL) {
- SDL_SetError("No buffer allocated for conversion");
- return (-1);
- }
- /* Return okay if no conversion is necessary */
- cvt->len_cvt = cvt->len;
- if (cvt->filters[0] == NULL) {
- return (0);
- }
-
- /* Set up the conversion and go! */
- cvt->filter_index = 0;
- cvt->filters[0] (cvt, cvt->src_format);
- return (0);
-}
-
-
-static SDL_AudioFilter
-SDL_HandTunedTypeCVT(SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
-{
- /*
- * Fill in any future conversions that are specialized to a
- * processor, platform, compiler, or library here.
- */
-
- return NULL; /* no specialized converter code available. */
-}
-
-
-/*
- * Find a converter between two data types. We try to select a hand-tuned
- * asm/vectorized/optimized function first, and then fallback to an
- * autogenerated function that is customized to convert between two
- * specific data types.
- */
-static int
-SDL_BuildAudioTypeCVT(SDL_AudioCVT * cvt,
- SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
-{
- if (src_fmt != dst_fmt) {
- const Uint16 src_bitsize = SDL_AUDIO_BITSIZE(src_fmt);
- const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE(dst_fmt);
- SDL_AudioFilter filter = SDL_HandTunedTypeCVT(src_fmt, dst_fmt);
-
- /* No hand-tuned converter? Try the autogenerated ones. */
- if (filter == NULL) {
- int i;
- for (i = 0; sdl_audio_type_filters[i].filter != NULL; i++) {
- const SDL_AudioTypeFilters *filt = &sdl_audio_type_filters[i];
- if ((filt->src_fmt == src_fmt) && (filt->dst_fmt == dst_fmt)) {
- filter = filt->filter;
- break;
- }
- }
-
- if (filter == NULL) {
- SDL_SetError("No conversion available for these formats");
- return -1;
- }
- }
-
- /* Update (cvt) with filter details... */
- cvt->filters[cvt->filter_index++] = filter;
- if (src_bitsize < dst_bitsize) {
- const int mult = (dst_bitsize / src_bitsize);
- cvt->len_mult *= mult;
- cvt->len_ratio *= mult;
- } else if (src_bitsize > dst_bitsize) {
- cvt->len_ratio /= (src_bitsize / dst_bitsize);
- }
-
- return 1; /* added a converter. */
- }
-
- return 0; /* no conversion necessary. */
-}
-
-
-static SDL_AudioFilter
-SDL_HandTunedResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
- int src_rate, int dst_rate)
-{
- /*
- * Fill in any future conversions that are specialized to a
- * processor, platform, compiler, or library here.
- */
-
- return NULL; /* no specialized converter code available. */
-}
-
-static int
-SDL_FindFrequencyMultiple(const int src_rate, const int dst_rate)
-{
- int retval = 0;
-
- /* If we only built with the arbitrary resamplers, ignore multiples. */
-#if !LESS_RESAMPLERS
- int lo, hi;
- int div;
-
- SDL_assert(src_rate != 0);
- SDL_assert(dst_rate != 0);
- SDL_assert(src_rate != dst_rate);
-
- if (src_rate < dst_rate) {
- lo = src_rate;
- hi = dst_rate;
- } else {
- lo = dst_rate;
- hi = src_rate;
- }
-
- /* zero means "not a supported multiple" ... we only do 2x and 4x. */
- if ((hi % lo) != 0)
- return 0; /* not a multiple. */
-
- div = hi / lo;
- retval = ((div == 2) || (div == 4)) ? div : 0;
-#endif
-
- return retval;
-}
-
-static int
-SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
- int src_rate, int dst_rate)
-{
- if (src_rate != dst_rate) {
- SDL_AudioFilter filter = SDL_HandTunedResampleCVT(cvt, dst_channels,
- src_rate, dst_rate);
-
- /* No hand-tuned converter? Try the autogenerated ones. */
- if (filter == NULL) {
- int i;
- const int upsample = (src_rate < dst_rate) ? 1 : 0;
- const int multiple =
- SDL_FindFrequencyMultiple(src_rate, dst_rate);
-
- for (i = 0; sdl_audio_rate_filters[i].filter != NULL; i++) {
- const SDL_AudioRateFilters *filt = &sdl_audio_rate_filters[i];
- if ((filt->fmt == cvt->dst_format) &&
- (filt->channels == dst_channels) &&
- (filt->upsample == upsample) &&
- (filt->multiple == multiple)) {
- filter = filt->filter;
- break;
- }
- }
-
- if (filter == NULL) {
- SDL_SetError("No conversion available for these rates");
- return -1;
- }
- }
-
- /* Update (cvt) with filter details... */
- cvt->filters[cvt->filter_index++] = filter;
- if (src_rate < dst_rate) {
- const double mult = ((double) dst_rate) / ((double) src_rate);
- cvt->len_mult *= (int) SDL_ceil(mult);
- cvt->len_ratio *= mult;
- } else {
- cvt->len_ratio /= ((double) src_rate) / ((double) dst_rate);
- }
-
- return 1; /* added a converter. */
- }
-
- return 0; /* no conversion necessary. */
-}
-
-
-/* Creates a set of audio filters to convert from one format to another.
- Returns -1 if the format conversion is not supported, 0 if there's
- no conversion needed, or 1 if the audio filter is set up.
-*/
-
-int
-SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
- SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
- SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
-{
- /*
- * !!! FIXME: reorder filters based on which grow/shrink the buffer.
- * !!! FIXME: ideally, we should do everything that shrinks the buffer
- * !!! FIXME: first, so we don't have to process as many bytes in a given
- * !!! FIXME: filter and abuse the CPU cache less. This might not be as
- * !!! FIXME: good in practice as it sounds in theory, though.
- */
-
- /* Sanity check target pointer */
- if (cvt == NULL) {
- return SDL_InvalidParamError("cvt");
- }
-
- /* there are no unsigned types over 16 bits, so catch this up front. */
- if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
- return SDL_SetError("Invalid source format");
- }
- if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
- return SDL_SetError("Invalid destination format");
- }
-
- /* prevent possible divisions by zero, etc. */
- if ((src_channels == 0) || (dst_channels == 0)) {
- return SDL_SetError("Source or destination channels is zero");
- }
- if ((src_rate == 0) || (dst_rate == 0)) {
- return SDL_SetError("Source or destination rate is zero");
- }
-#ifdef DEBUG_CONVERT
- printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
- src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
-#endif
-
- /* Start off with no conversion necessary */
- SDL_zerop(cvt);
- cvt->src_format = src_fmt;
- cvt->dst_format = dst_fmt;
- cvt->needed = 0;
- cvt->filter_index = 0;
- cvt->filters[0] = NULL;
- cvt->len_mult = 1;
- cvt->len_ratio = 1.0;
- cvt->rate_incr = ((double) dst_rate) / ((double) src_rate);
-
- /* Convert data types, if necessary. Updates (cvt). */
- if (SDL_BuildAudioTypeCVT(cvt, src_fmt, dst_fmt) == -1) {
- return -1; /* shouldn't happen, but just in case... */
- }
-
- /* Channel conversion */
- if (src_channels != dst_channels) {
- if ((src_channels == 1) && (dst_channels > 1)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStereo;
- cvt->len_mult *= 2;
- src_channels = 2;
- cvt->len_ratio *= 2;
- }
- if ((src_channels == 2) && (dst_channels == 6)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertSurround;
- src_channels = 6;
- cvt->len_mult *= 3;
- cvt->len_ratio *= 3;
- }
- if ((src_channels == 2) && (dst_channels == 4)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertSurround_4;
- src_channels = 4;
- cvt->len_mult *= 2;
- cvt->len_ratio *= 2;
- }
- while ((src_channels * 2) <= dst_channels) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStereo;
- cvt->len_mult *= 2;
- src_channels *= 2;
- cvt->len_ratio *= 2;
- }
- if ((src_channels == 6) && (dst_channels <= 2)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStrip;
- src_channels = 2;
- cvt->len_ratio /= 3;
- }
- if ((src_channels == 6) && (dst_channels == 4)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStrip_2;
- src_channels = 4;
- cvt->len_ratio /= 2;
- }
- /* This assumes that 4 channel audio is in the format:
- Left {front/back} + Right {front/back}
- so converting to L/R stereo works properly.
- */
- while (((src_channels % 2) == 0) &&
- ((src_channels / 2) >= dst_channels)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertMono;
- src_channels /= 2;
- cvt->len_ratio /= 2;
- }
- if (src_channels != dst_channels) {
- /* Uh oh.. */ ;
- }
- }
-
- /* Do rate conversion, if necessary. Updates (cvt). */
- if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) ==
- -1) {
- return -1; /* shouldn't happen, but just in case... */
- }
-
- /* Set up the filter information */
- if (cvt->filter_index != 0) {
- cvt->needed = 1;
- cvt->src_format = src_fmt;
- cvt->dst_format = dst_fmt;
- cvt->len = 0;
- cvt->buf = NULL;
- cvt->filters[cvt->filter_index] = NULL;
- }
- return (cvt->needed);
-}
-
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_audiodev.c b/3rdparty/SDL2/src/audio/SDL_audiodev.c
deleted file mode 100644
index 5c392cfb725..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_audiodev.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-/* Get the name of the audio device we use for output */
-
-#if SDL_AUDIO_DRIVER_BSD || SDL_AUDIO_DRIVER_OSS || SDL_AUDIO_DRIVER_SUNAUDIO
-
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h> /* For close() */
-
-#include "SDL_stdinc.h"
-#include "SDL_audiodev_c.h"
-
-#ifndef _PATH_DEV_DSP
-#if defined(__NETBSD__) || defined(__OPENBSD__)
-#define _PATH_DEV_DSP "/dev/audio"
-#else
-#define _PATH_DEV_DSP "/dev/dsp"
-#endif
-#endif
-#ifndef _PATH_DEV_DSP24
-#define _PATH_DEV_DSP24 "/dev/sound/dsp"
-#endif
-#ifndef _PATH_DEV_AUDIO
-#define _PATH_DEV_AUDIO "/dev/audio"
-#endif
-
-static void
-test_device(const int iscapture, const char *fname, int flags, int (*test) (int fd))
-{
- struct stat sb;
- if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
- const int audio_fd = open(fname, flags, 0);
- if (audio_fd >= 0) {
- const int okay = test(audio_fd);
- close(audio_fd);
- if (okay) {
- static size_t dummyhandle = 0;
- dummyhandle++;
- SDL_assert(dummyhandle != 0);
- SDL_AddAudioDevice(iscapture, fname, (void *) dummyhandle);
- }
- }
- }
-}
-
-static int
-test_stub(int fd)
-{
- return 1;
-}
-
-static void
-SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
-{
- const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
- const char *audiodev;
- char audiopath[1024];
-
- if (test == NULL)
- test = test_stub;
-
- /* Figure out what our audio device is */
- if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) &&
- ((audiodev = SDL_getenv("AUDIODEV")) == NULL)) {
- if (classic) {
- audiodev = _PATH_DEV_AUDIO;
- } else {
- struct stat sb;
-
- /* Added support for /dev/sound/\* in Linux 2.4 */
- if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode))
- && ((stat(_PATH_DEV_DSP24, &sb) == 0)
- && S_ISCHR(sb.st_mode))) {
- audiodev = _PATH_DEV_DSP24;
- } else {
- audiodev = _PATH_DEV_DSP;
- }
- }
- }
- test_device(iscapture, audiodev, flags, test);
-
- if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
- int instance = 0;
- while (instance++ <= 64) {
- SDL_snprintf(audiopath, SDL_arraysize(audiopath),
- "%s%d", audiodev, instance);
- test_device(iscapture, audiopath, flags, test);
- }
- }
-}
-
-void
-SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
-{
- SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test);
- SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);
-}
-
-#endif /* Audio driver selection */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_audiodev_c.h b/3rdparty/SDL2/src/audio/SDL_audiodev_c.h
deleted file mode 100644
index fa60bcdb174..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_audiodev_c.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "SDL.h"
-#include "../SDL_internal.h"
-#include "SDL_sysaudio.h"
-
-/* Open the audio device for playback, and don't block if busy */
-/* #define USE_BLOCKING_WRITES */
-
-#ifdef USE_BLOCKING_WRITES
-#define OPEN_FLAGS_OUTPUT O_WRONLY
-#define OPEN_FLAGS_INPUT O_RDONLY
-#else
-#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK)
-#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
-#endif
-
-extern void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int));
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_audiotypecvt.c b/3rdparty/SDL2/src/audio/SDL_audiotypecvt.c
deleted file mode 100644
index be3b7430aa6..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_audiotypecvt.c
+++ /dev/null
@@ -1,16015 +0,0 @@
-/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../SDL_internal.h"
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-
-#ifndef DEBUG_CONVERT
-#define DEBUG_CONVERT 0
-#endif
-
-
-/* If you can guarantee your data and need space, you can eliminate code... */
-
-/* Just build the arbitrary resamplers if you're saving code space. */
-#ifndef LESS_RESAMPLERS
-#define LESS_RESAMPLERS 0
-#endif
-
-/* Don't build any resamplers if you're REALLY saving code space. */
-#ifndef NO_RESAMPLERS
-#define NO_RESAMPLERS 0
-#endif
-
-/* Don't build any type converters if you're saving code space. */
-#ifndef NO_CONVERTERS
-#define NO_CONVERTERS 0
-#endif
-
-
-/* *INDENT-OFF* */
-
-#define DIVBY127 0.0078740157480315f
-#define DIVBY32767 3.05185094759972e-05f
-#define DIVBY2147483647 4.6566128752458e-10f
-
-#if !NO_CONVERTERS
-
-static void SDLCALL
-SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S8.\n");
-#endif
-
- src = (const Uint8 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
- const Sint8 val = ((*src) ^ 0x80);
- *dst = ((Sint8) val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) *src) << 8);
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) *src) << 8);
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = ((((float) *src) * DIVBY127) - 1.0f);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = ((((float) *src) * DIVBY127) - 1.0f);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U8.\n");
-#endif
-
- src = (const Uint8 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
- const Uint8 val = ((((Sint8) *src)) ^ 0x80);
- *dst = val;
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = (((float) ((Sint8) *src)) * DIVBY127);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = (((float) ((Sint8) *src)) * DIVBY127);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (SDL_SwapLE16(*src) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((SDL_SwapLE16(*src)) ^ 0x8000) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = SDL_SwapLE16(*src);
- *dst = SDL_SwapBE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint16) SDL_SwapLE16(*src)) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
- *dst = SDL_SwapLE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
- *dst = SDL_SwapBE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) SDL_SwapLE16(*src));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (SDL_SwapBE16(*src) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((SDL_SwapBE16(*src)) ^ 0x8000) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = SDL_SwapBE16(*src);
- *dst = SDL_SwapLE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint16) SDL_SwapBE16(*src)) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
- *dst = SDL_SwapLE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) SDL_SwapBE16(*src));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
- *dst = SDL_SwapBE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 24));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint32) SDL_SwapLE32(*src)) >> 24));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) SDL_SwapLE32(*src));
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatLE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatBE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 24));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint32) SDL_SwapBE32(*src)) >> 24));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) SDL_SwapBE32(*src));
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatLE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatBE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) ((SDL_SwapFloatLE(*src) + 1.0f) * 127.0f));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (SDL_SwapFloatLE(*src) * 127.0f));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const float val = SDL_SwapFloatLE(*src);
- *dst = SDL_SwapFloatBE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) ((SDL_SwapFloatBE(*src) + 1.0f) * 127.0f));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (SDL_SwapFloatBE(*src) * 127.0f));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const float val = SDL_SwapFloatBE(*src);
- *dst = SDL_SwapFloatLE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-#endif /* !NO_CONVERTERS */
-
-
-const SDL_AudioTypeFilters sdl_audio_type_filters[] =
-{
-#if !NO_CONVERTERS
- { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
- { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
- { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
- { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB },
- { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB },
- { AUDIO_U8, AUDIO_S32LSB, SDL_Convert_U8_to_S32LSB },
- { AUDIO_U8, AUDIO_S32MSB, SDL_Convert_U8_to_S32MSB },
- { AUDIO_U8, AUDIO_F32LSB, SDL_Convert_U8_to_F32LSB },
- { AUDIO_U8, AUDIO_F32MSB, SDL_Convert_U8_to_F32MSB },
- { AUDIO_S8, AUDIO_U8, SDL_Convert_S8_to_U8 },
- { AUDIO_S8, AUDIO_U16LSB, SDL_Convert_S8_to_U16LSB },
- { AUDIO_S8, AUDIO_S16LSB, SDL_Convert_S8_to_S16LSB },
- { AUDIO_S8, AUDIO_U16MSB, SDL_Convert_S8_to_U16MSB },
- { AUDIO_S8, AUDIO_S16MSB, SDL_Convert_S8_to_S16MSB },
- { AUDIO_S8, AUDIO_S32LSB, SDL_Convert_S8_to_S32LSB },
- { AUDIO_S8, AUDIO_S32MSB, SDL_Convert_S8_to_S32MSB },
- { AUDIO_S8, AUDIO_F32LSB, SDL_Convert_S8_to_F32LSB },
- { AUDIO_S8, AUDIO_F32MSB, SDL_Convert_S8_to_F32MSB },
- { AUDIO_U16LSB, AUDIO_U8, SDL_Convert_U16LSB_to_U8 },
- { AUDIO_U16LSB, AUDIO_S8, SDL_Convert_U16LSB_to_S8 },
- { AUDIO_U16LSB, AUDIO_S16LSB, SDL_Convert_U16LSB_to_S16LSB },
- { AUDIO_U16LSB, AUDIO_U16MSB, SDL_Convert_U16LSB_to_U16MSB },
- { AUDIO_U16LSB, AUDIO_S16MSB, SDL_Convert_U16LSB_to_S16MSB },
- { AUDIO_U16LSB, AUDIO_S32LSB, SDL_Convert_U16LSB_to_S32LSB },
- { AUDIO_U16LSB, AUDIO_S32MSB, SDL_Convert_U16LSB_to_S32MSB },
- { AUDIO_U16LSB, AUDIO_F32LSB, SDL_Convert_U16LSB_to_F32LSB },
- { AUDIO_U16LSB, AUDIO_F32MSB, SDL_Convert_U16LSB_to_F32MSB },
- { AUDIO_S16LSB, AUDIO_U8, SDL_Convert_S16LSB_to_U8 },
- { AUDIO_S16LSB, AUDIO_S8, SDL_Convert_S16LSB_to_S8 },
- { AUDIO_S16LSB, AUDIO_U16LSB, SDL_Convert_S16LSB_to_U16LSB },
- { AUDIO_S16LSB, AUDIO_U16MSB, SDL_Convert_S16LSB_to_U16MSB },
- { AUDIO_S16LSB, AUDIO_S16MSB, SDL_Convert_S16LSB_to_S16MSB },
- { AUDIO_S16LSB, AUDIO_S32LSB, SDL_Convert_S16LSB_to_S32LSB },
- { AUDIO_S16LSB, AUDIO_S32MSB, SDL_Convert_S16LSB_to_S32MSB },
- { AUDIO_S16LSB, AUDIO_F32LSB, SDL_Convert_S16LSB_to_F32LSB },
- { AUDIO_S16LSB, AUDIO_F32MSB, SDL_Convert_S16LSB_to_F32MSB },
- { AUDIO_U16MSB, AUDIO_U8, SDL_Convert_U16MSB_to_U8 },
- { AUDIO_U16MSB, AUDIO_S8, SDL_Convert_U16MSB_to_S8 },
- { AUDIO_U16MSB, AUDIO_U16LSB, SDL_Convert_U16MSB_to_U16LSB },
- { AUDIO_U16MSB, AUDIO_S16LSB, SDL_Convert_U16MSB_to_S16LSB },
- { AUDIO_U16MSB, AUDIO_S16MSB, SDL_Convert_U16MSB_to_S16MSB },
- { AUDIO_U16MSB, AUDIO_S32LSB, SDL_Convert_U16MSB_to_S32LSB },
- { AUDIO_U16MSB, AUDIO_S32MSB, SDL_Convert_U16MSB_to_S32MSB },
- { AUDIO_U16MSB, AUDIO_F32LSB, SDL_Convert_U16MSB_to_F32LSB },
- { AUDIO_U16MSB, AUDIO_F32MSB, SDL_Convert_U16MSB_to_F32MSB },
- { AUDIO_S16MSB, AUDIO_U8, SDL_Convert_S16MSB_to_U8 },
- { AUDIO_S16MSB, AUDIO_S8, SDL_Convert_S16MSB_to_S8 },
- { AUDIO_S16MSB, AUDIO_U16LSB, SDL_Convert_S16MSB_to_U16LSB },
- { AUDIO_S16MSB, AUDIO_S16LSB, SDL_Convert_S16MSB_to_S16LSB },
- { AUDIO_S16MSB, AUDIO_U16MSB, SDL_Convert_S16MSB_to_U16MSB },
- { AUDIO_S16MSB, AUDIO_S32LSB, SDL_Convert_S16MSB_to_S32LSB },
- { AUDIO_S16MSB, AUDIO_S32MSB, SDL_Convert_S16MSB_to_S32MSB },
- { AUDIO_S16MSB, AUDIO_F32LSB, SDL_Convert_S16MSB_to_F32LSB },
- { AUDIO_S16MSB, AUDIO_F32MSB, SDL_Convert_S16MSB_to_F32MSB },
- { AUDIO_S32LSB, AUDIO_U8, SDL_Convert_S32LSB_to_U8 },
- { AUDIO_S32LSB, AUDIO_S8, SDL_Convert_S32LSB_to_S8 },
- { AUDIO_S32LSB, AUDIO_U16LSB, SDL_Convert_S32LSB_to_U16LSB },
- { AUDIO_S32LSB, AUDIO_S16LSB, SDL_Convert_S32LSB_to_S16LSB },
- { AUDIO_S32LSB, AUDIO_U16MSB, SDL_Convert_S32LSB_to_U16MSB },
- { AUDIO_S32LSB, AUDIO_S16MSB, SDL_Convert_S32LSB_to_S16MSB },
- { AUDIO_S32LSB, AUDIO_S32MSB, SDL_Convert_S32LSB_to_S32MSB },
- { AUDIO_S32LSB, AUDIO_F32LSB, SDL_Convert_S32LSB_to_F32LSB },
- { AUDIO_S32LSB, AUDIO_F32MSB, SDL_Convert_S32LSB_to_F32MSB },
- { AUDIO_S32MSB, AUDIO_U8, SDL_Convert_S32MSB_to_U8 },
- { AUDIO_S32MSB, AUDIO_S8, SDL_Convert_S32MSB_to_S8 },
- { AUDIO_S32MSB, AUDIO_U16LSB, SDL_Convert_S32MSB_to_U16LSB },
- { AUDIO_S32MSB, AUDIO_S16LSB, SDL_Convert_S32MSB_to_S16LSB },
- { AUDIO_S32MSB, AUDIO_U16MSB, SDL_Convert_S32MSB_to_U16MSB },
- { AUDIO_S32MSB, AUDIO_S16MSB, SDL_Convert_S32MSB_to_S16MSB },
- { AUDIO_S32MSB, AUDIO_S32LSB, SDL_Convert_S32MSB_to_S32LSB },
- { AUDIO_S32MSB, AUDIO_F32LSB, SDL_Convert_S32MSB_to_F32LSB },
- { AUDIO_S32MSB, AUDIO_F32MSB, SDL_Convert_S32MSB_to_F32MSB },
- { AUDIO_F32LSB, AUDIO_U8, SDL_Convert_F32LSB_to_U8 },
- { AUDIO_F32LSB, AUDIO_S8, SDL_Convert_F32LSB_to_S8 },
- { AUDIO_F32LSB, AUDIO_U16LSB, SDL_Convert_F32LSB_to_U16LSB },
- { AUDIO_F32LSB, AUDIO_S16LSB, SDL_Convert_F32LSB_to_S16LSB },
- { AUDIO_F32LSB, AUDIO_U16MSB, SDL_Convert_F32LSB_to_U16MSB },
- { AUDIO_F32LSB, AUDIO_S16MSB, SDL_Convert_F32LSB_to_S16MSB },
- { AUDIO_F32LSB, AUDIO_S32LSB, SDL_Convert_F32LSB_to_S32LSB },
- { AUDIO_F32LSB, AUDIO_S32MSB, SDL_Convert_F32LSB_to_S32MSB },
- { AUDIO_F32LSB, AUDIO_F32MSB, SDL_Convert_F32LSB_to_F32MSB },
- { AUDIO_F32MSB, AUDIO_U8, SDL_Convert_F32MSB_to_U8 },
- { AUDIO_F32MSB, AUDIO_S8, SDL_Convert_F32MSB_to_S8 },
- { AUDIO_F32MSB, AUDIO_U16LSB, SDL_Convert_F32MSB_to_U16LSB },
- { AUDIO_F32MSB, AUDIO_S16LSB, SDL_Convert_F32MSB_to_S16LSB },
- { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB },
- { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB },
- { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
- { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
- { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
-#endif /* !NO_CONVERTERS */
- { 0, 0, NULL }
-};
-
-
-#if !NO_RESAMPLERS
-
-static void SDLCALL
-SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Uint8 sample0 = src[0];
- Uint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = sample0;
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst++;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst += 2;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Uint8 sample3 = src[3];
- Uint8 sample2 = src[2];
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample3 = sample3;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = sample3;
- dst[2] = sample2;
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 sample2 = src[2];
- Uint8 sample3 = src[3];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst[2] = sample2;
- dst[3] = sample3;
- dst += 4;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Uint8 sample5 = src[5];
- Uint8 sample4 = src[4];
- Uint8 sample3 = src[3];
- Uint8 sample2 = src[2];
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample5 = sample5;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = sample5;
- dst[4] = sample4;
- dst[3] = sample3;
- dst[2] = sample2;
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 sample2 = src[2];
- Uint8 sample3 = src[3];
- Uint8 sample4 = src[4];
- Uint8 sample5 = src[5];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst[2] = sample2;
- dst[3] = sample3;
- dst[4] = sample4;
- dst[5] = sample5;
- dst += 6;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Uint8 sample7 = src[7];
- Uint8 sample6 = src[6];
- Uint8 sample5 = src[5];
- Uint8 sample4 = src[4];
- Uint8 sample3 = src[3];
- Uint8 sample2 = src[2];
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample7 = sample7;
- Uint8 last_sample6 = sample6;
- Uint8 last_sample5 = sample5;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = sample7;
- dst[6] = sample6;
- dst[5] = sample5;
- dst[4] = sample4;
- dst[3] = sample3;
- dst[2] = sample2;
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
- sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 sample2 = src[2];
- Uint8 sample3 = src[3];
- Uint8 sample4 = src[4];
- Uint8 sample5 = src[5];
- Uint8 sample6 = src[6];
- Uint8 sample7 = src[7];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample5 = sample5;
- Uint8 last_sample6 = sample6;
- Uint8 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst[2] = sample2;
- dst[3] = sample3;
- dst[4] = sample4;
- dst[5] = sample5;
- dst[6] = sample6;
- dst[7] = sample7;
- dst += 8;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
- sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = ((Sint8) sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst++;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst += 2;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample3 = sample3;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = ((Sint8) sample3);
- dst[2] = ((Sint8) sample2);
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst[2] = ((Sint8) sample2);
- dst[3] = ((Sint8) sample3);
- dst += 4;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample5 = sample5;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = ((Sint8) sample5);
- dst[4] = ((Sint8) sample4);
- dst[3] = ((Sint8) sample3);
- dst[2] = ((Sint8) sample2);
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst[2] = ((Sint8) sample2);
- dst[3] = ((Sint8) sample3);
- dst[4] = ((Sint8) sample4);
- dst[5] = ((Sint8) sample5);
- dst += 6;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint8 sample7 = ((Sint8) src[7]);
- Sint8 sample6 = ((Sint8) src[6]);
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample7 = sample7;
- Sint8 last_sample6 = sample6;
- Sint8 last_sample5 = sample5;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = ((Sint8) sample7);
- dst[6] = ((Sint8) sample6);
- dst[5] = ((Sint8) sample5);
- dst[4] = ((Sint8) sample4);
- dst[3] = ((Sint8) sample3);
- dst[2] = ((Sint8) sample2);
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
- sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 sample6 = ((Sint8) src[6]);
- Sint8 sample7 = ((Sint8) src[7]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample5 = sample5;
- Sint8 last_sample6 = sample6;
- Sint8 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst[2] = ((Sint8) sample2);
- dst[3] = ((Sint8) sample3);
- dst[4] = ((Sint8) sample4);
- dst[5] = ((Sint8) sample5);
- dst[6] = ((Sint8) sample6);
- dst[7] = ((Sint8) sample7);
- dst += 8;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
- sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = SDL_SwapLE16(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst++;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst += 2;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = SDL_SwapLE16(sample3);
- dst[2] = SDL_SwapLE16(sample2);
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst[2] = SDL_SwapLE16(sample2);
- dst[3] = SDL_SwapLE16(sample3);
- dst += 4;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = SDL_SwapLE16(sample5);
- dst[4] = SDL_SwapLE16(sample4);
- dst[3] = SDL_SwapLE16(sample3);
- dst[2] = SDL_SwapLE16(sample2);
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst[2] = SDL_SwapLE16(sample2);
- dst[3] = SDL_SwapLE16(sample3);
- dst[4] = SDL_SwapLE16(sample4);
- dst[5] = SDL_SwapLE16(sample5);
- dst += 6;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample7 = SDL_SwapLE16(src[7]);
- Uint16 sample6 = SDL_SwapLE16(src[6]);
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample7 = sample7;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = SDL_SwapLE16(sample7);
- dst[6] = SDL_SwapLE16(sample6);
- dst[5] = SDL_SwapLE16(sample5);
- dst[4] = SDL_SwapLE16(sample4);
- dst[3] = SDL_SwapLE16(sample3);
- dst[2] = SDL_SwapLE16(sample2);
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 sample6 = SDL_SwapLE16(src[6]);
- Uint16 sample7 = SDL_SwapLE16(src[7]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst[2] = SDL_SwapLE16(sample2);
- dst[3] = SDL_SwapLE16(sample3);
- dst[4] = SDL_SwapLE16(sample4);
- dst[5] = SDL_SwapLE16(sample5);
- dst[6] = SDL_SwapLE16(sample6);
- dst[7] = SDL_SwapLE16(sample7);
- dst += 8;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst++;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst += 2;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst += 4;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst += 6;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
- Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample7 = sample7;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = ((Sint16) SDL_SwapLE16(sample7));
- dst[6] = ((Sint16) SDL_SwapLE16(sample6));
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
- Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst[6] = ((Sint16) SDL_SwapLE16(sample6));
- dst[7] = ((Sint16) SDL_SwapLE16(sample7));
- dst += 8;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = SDL_SwapBE16(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst++;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst += 2;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = SDL_SwapBE16(sample3);
- dst[2] = SDL_SwapBE16(sample2);
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst[2] = SDL_SwapBE16(sample2);
- dst[3] = SDL_SwapBE16(sample3);
- dst += 4;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = SDL_SwapBE16(sample5);
- dst[4] = SDL_SwapBE16(sample4);
- dst[3] = SDL_SwapBE16(sample3);
- dst[2] = SDL_SwapBE16(sample2);
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst[2] = SDL_SwapBE16(sample2);
- dst[3] = SDL_SwapBE16(sample3);
- dst[4] = SDL_SwapBE16(sample4);
- dst[5] = SDL_SwapBE16(sample5);
- dst += 6;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Uint16 sample7 = SDL_SwapBE16(src[7]);
- Uint16 sample6 = SDL_SwapBE16(src[6]);
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample7 = sample7;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = SDL_SwapBE16(sample7);
- dst[6] = SDL_SwapBE16(sample6);
- dst[5] = SDL_SwapBE16(sample5);
- dst[4] = SDL_SwapBE16(sample4);
- dst[3] = SDL_SwapBE16(sample3);
- dst[2] = SDL_SwapBE16(sample2);
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 sample6 = SDL_SwapBE16(src[6]);
- Uint16 sample7 = SDL_SwapBE16(src[7]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst[2] = SDL_SwapBE16(sample2);
- dst[3] = SDL_SwapBE16(sample3);
- dst[4] = SDL_SwapBE16(sample4);
- dst[5] = SDL_SwapBE16(sample5);
- dst[6] = SDL_SwapBE16(sample6);
- dst[7] = SDL_SwapBE16(sample7);
- dst += 8;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst++;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst += 2;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst += 4;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst += 6;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
- Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample7 = sample7;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = ((Sint16) SDL_SwapBE16(sample7));
- dst[6] = ((Sint16) SDL_SwapBE16(sample6));
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
- Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst[6] = ((Sint16) SDL_SwapBE16(sample6));
- dst[7] = ((Sint16) SDL_SwapBE16(sample7));
- dst += 8;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst++;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst += 2;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst += 4;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst += 6;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
- Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample7 = sample7;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = ((Sint32) SDL_SwapLE32(sample7));
- dst[6] = ((Sint32) SDL_SwapLE32(sample6));
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
- Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst[6] = ((Sint32) SDL_SwapLE32(sample6));
- dst[7] = ((Sint32) SDL_SwapLE32(sample7));
- dst += 8;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst++;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst += 2;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst += 4;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst += 6;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
- Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample7 = sample7;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = ((Sint32) SDL_SwapBE32(sample7));
- dst[6] = ((Sint32) SDL_SwapBE32(sample6));
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
- Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst[6] = ((Sint32) SDL_SwapBE32(sample6));
- dst[7] = ((Sint32) SDL_SwapBE32(sample7));
- dst += 8;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst++;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst += 2;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst += 4;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf);
- float sample5 = SDL_SwapFloatLE(src[5]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = SDL_SwapFloatLE(sample5);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample5 = SDL_SwapFloatLE(src[5]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[5] = SDL_SwapFloatLE(sample5);
- dst += 6;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf);
- float sample7 = SDL_SwapFloatLE(src[7]);
- float sample6 = SDL_SwapFloatLE(src[6]);
- float sample5 = SDL_SwapFloatLE(src[5]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample7 = sample7;
- float last_sample6 = sample6;
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = SDL_SwapFloatLE(sample7);
- dst[6] = SDL_SwapFloatLE(sample6);
- dst[5] = SDL_SwapFloatLE(sample5);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample5 = SDL_SwapFloatLE(src[5]);
- float sample6 = SDL_SwapFloatLE(src[6]);
- float sample7 = SDL_SwapFloatLE(src[7]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- float last_sample6 = sample6;
- float last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[5] = SDL_SwapFloatLE(sample5);
- dst[6] = SDL_SwapFloatLE(sample6);
- dst[7] = SDL_SwapFloatLE(sample7);
- dst += 8;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
- sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst++;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst += 2;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst += 4;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf);
- float sample5 = SDL_SwapFloatBE(src[5]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[5] = SDL_SwapFloatBE(sample5);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample5 = SDL_SwapFloatBE(src[5]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[5] = SDL_SwapFloatBE(sample5);
- dst += 6;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf);
- float sample7 = SDL_SwapFloatBE(src[7]);
- float sample6 = SDL_SwapFloatBE(src[6]);
- float sample5 = SDL_SwapFloatBE(src[5]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample7 = sample7;
- float last_sample6 = sample6;
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst >= target) {
- dst[7] = SDL_SwapFloatBE(sample7);
- dst[6] = SDL_SwapFloatBE(sample6);
- dst[5] = SDL_SwapFloatBE(sample5);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample5 = SDL_SwapFloatBE(src[5]);
- float sample6 = SDL_SwapFloatBE(src[6]);
- float sample7 = SDL_SwapFloatBE(src[7]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- float last_sample6 = sample6;
- float last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[5] = SDL_SwapFloatBE(sample5);
- dst[6] = SDL_SwapFloatBE(sample6);
- dst[7] = SDL_SwapFloatBE(sample7);
- dst += 8;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
- sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-#if !LESS_RESAMPLERS
-
-static void SDLCALL
-SDL_Upsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1 * 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample0 = (Sint16) src[0];
- src--;
- dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint8) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- src += 2;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1 * 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample0 = (Sint16) src[0];
- src--;
- dst[3] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Uint8) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- src += 4;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2 * 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 2;
- dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- src += 4;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2 * 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 2;
- dst[7] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- src += 8;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4 * 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 4;
- dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- src += 8;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4 * 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 4;
- dst[15] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- src += 16;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6 * 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 6;
- dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint8) sample5;
- dst[4] = (Uint8) sample4;
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- src += 12;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6 * 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 6;
- dst[23] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[16] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[15] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[14] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[13] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[12] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[11] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Uint8) sample5;
- dst[4] = (Uint8) sample4;
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- src += 24;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8 * 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample7 = (Sint16) src[7];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample7 = (Sint16) src[7];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 8;
- dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint8) sample7;
- dst[6] = (Uint8) sample6;
- dst[5] = (Uint8) sample5;
- dst[4] = (Uint8) sample4;
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample7 = (Sint16) src[7];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample7 = (Sint16) src[7];
- src += 16;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8 * 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint8 *target = ((const Uint8 *) cvt->buf);
- Sint16 last_sample7 = (Sint16) src[7];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst >= target) {
- const Sint16 sample7 = (Sint16) src[7];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 8;
- dst[31] = (Uint8) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Uint8) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Uint8) ((sample7 + last_sample7) >> 1);
- dst[22] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[21] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[20] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[19] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[18] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[17] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[16] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[15] = (Uint8) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Uint8) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Uint8) sample7;
- dst[6] = (Uint8) sample6;
- dst[5] = (Uint8) sample5;
- dst[4] = (Uint8) sample4;
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample7 = (Sint16) src[7];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample7 = (Sint16) src[7];
- src += 32;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1 * 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src--;
- dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint8) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src += 2;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1 * 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src--;
- dst[3] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Sint8) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src += 4;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2 * 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 2;
- dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- src += 4;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2 * 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 2;
- dst[7] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- src += 8;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4 * 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 4;
- dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- src += 8;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4 * 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 4;
- dst[15] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- src += 16;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6 * 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 6;
- dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint8) sample5;
- dst[4] = (Sint8) sample4;
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- src += 12;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6 * 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 6;
- dst[23] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[16] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[15] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[14] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[13] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[12] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[11] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Sint8) sample5;
- dst[4] = (Sint8) sample4;
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- src += 24;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8 * 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 8;
- dst[15] = (Sint8) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint8) sample7;
- dst[6] = (Sint8) sample6;
- dst[5] = (Sint8) sample5;
- dst[4] = (Sint8) sample4;
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- src += 16;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8 * 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint8 *target = ((const Sint8 *) cvt->buf);
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst >= target) {
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 8;
- dst[31] = (Sint8) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Sint8) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Sint8) ((sample7 + last_sample7) >> 1);
- dst[22] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[21] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[20] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[19] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[18] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[17] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[16] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[15] = (Sint8) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Sint8) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint8) sample7;
- dst[6] = (Sint8) sample6;
- dst[5] = (Sint8) sample5;
- dst[4] = (Sint8) sample4;
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- src += 32;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src--;
- dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src += 2;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src--;
- dst[3] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Uint16) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 2;
- dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 2;
- dst[7] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 4;
- dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 4;
- dst[15] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 6;
- dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- src += 12;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 6;
- dst[23] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[16] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[15] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[14] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[13] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[12] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[11] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- src += 24;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 8;
- dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) sample7;
- dst[6] = (Uint16) sample6;
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 8;
- dst[31] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[22] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[21] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[20] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[19] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[18] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[17] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[16] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[15] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Uint16) sample7;
- dst[6] = (Uint16) sample6;
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- src += 32;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src--;
- dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src += 2;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src--;
- dst[3] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Sint16) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 2;
- dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 2;
- dst[7] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 4;
- dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 4;
- dst[15] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 6;
- dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- src += 12;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 6;
- dst[23] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[16] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[15] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[14] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[13] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[12] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[11] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- src += 24;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 8;
- dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) sample7;
- dst[6] = (Sint16) sample6;
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 8;
- dst[31] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[22] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[21] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[20] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[19] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[18] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[17] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[16] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[15] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint16) sample7;
- dst[6] = (Sint16) sample6;
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- src += 32;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src--;
- dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src += 2;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src--;
- dst[3] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Uint16) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 2;
- dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 2;
- dst[7] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 4;
- dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 4;
- dst[15] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 6;
- dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- src += 12;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 6;
- dst[23] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[16] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[15] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[14] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[13] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[12] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[11] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- src += 24;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 8;
- dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) sample7;
- dst[6] = (Uint16) sample6;
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 8;
- dst[31] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[22] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[21] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[20] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[19] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[18] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[17] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[16] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[15] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Uint16) sample7;
- dst[6] = (Uint16) sample6;
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- src += 32;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src--;
- dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src += 2;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src--;
- dst[3] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Sint16) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 2;
- dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 2;
- dst[7] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 4;
- dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 4;
- dst[15] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 6;
- dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- src += 12;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 6;
- dst[23] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[16] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[15] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[14] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[13] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[12] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[11] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- src += 24;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 8;
- dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) sample7;
- dst[6] = (Sint16) sample6;
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf);
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst >= target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 8;
- dst[31] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[22] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[21] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[20] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[19] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[18] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[17] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[16] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[15] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint16) sample7;
- dst[6] = (Sint16) sample6;
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- src += 32;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src--;
- dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint32) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src += 2;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src--;
- dst[3] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Sint32) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 2;
- dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 2;
- dst[7] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 4;
- dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 4;
- dst[15] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 6;
- dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- src += 12;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 6;
- dst[23] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[16] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[15] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[14] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[13] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[12] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[11] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- src += 24;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 8;
- dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) sample7;
- dst[6] = (Sint32) sample6;
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst >= target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 8;
- dst[31] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[22] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[21] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[20] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[19] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[18] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[17] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[16] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[15] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint32) sample7;
- dst[6] = (Sint32) sample6;
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- src += 32;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src--;
- dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint32) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src += 2;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src--;
- dst[3] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[0] = (Sint32) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 2;
- dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 2;
- dst[7] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[6] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 4;
- dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 4;
- dst[15] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[14] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[13] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[12] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[6] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 6;
- dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- src += 12;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 6;
- dst[23] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[22] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[21] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[20] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[19] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[18] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[17] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[16] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[15] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[14] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[13] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[12] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[11] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[10] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[9] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[8] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[7] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[6] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- src += 24;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 8;
- dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) sample7;
- dst[6] = (Sint32) sample6;
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf);
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst >= target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 8;
- dst[31] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
- dst[30] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
- dst[29] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[28] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[27] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[26] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[25] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[24] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- dst[23] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[22] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[21] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[20] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[19] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[18] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[17] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[16] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[15] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
- dst[14] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
- dst[13] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[12] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint32) sample7;
- dst[6] = (Sint32) sample6;
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- src += 32;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src--;
- dst[1] = (float) ((sample0 + last_sample0) * 0.5);
- dst[0] = (float) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src += 2;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src--;
- dst[3] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[0] = (float) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 2;
- dst[3] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 2;
- dst[7] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[6] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 4;
- dst[7] = (float) ((sample3 + last_sample3) * 0.5);
- dst[6] = (float) ((sample2 + last_sample2) * 0.5);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 4;
- dst[15] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[14] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[13] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[12] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[6] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 6;
- dst[11] = (float) ((sample5 + last_sample5) * 0.5);
- dst[10] = (float) ((sample4 + last_sample4) * 0.5);
- dst[9] = (float) ((sample3 + last_sample3) * 0.5);
- dst[8] = (float) ((sample2 + last_sample2) * 0.5);
- dst[7] = (float) ((sample1 + last_sample1) * 0.5);
- dst[6] = (float) ((sample0 + last_sample0) * 0.5);
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- src += 12;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 6;
- dst[23] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[22] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[21] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[20] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[19] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[18] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[17] = (float) ((sample5 + last_sample5) * 0.5);
- dst[16] = (float) ((sample4 + last_sample4) * 0.5);
- dst[15] = (float) ((sample3 + last_sample3) * 0.5);
- dst[14] = (float) ((sample2 + last_sample2) * 0.5);
- dst[13] = (float) ((sample1 + last_sample1) * 0.5);
- dst[12] = (float) ((sample0 + last_sample0) * 0.5);
- dst[11] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[10] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[9] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[8] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[7] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[6] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- src += 24;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf);
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 8;
- dst[15] = (float) ((sample7 + last_sample7) * 0.5);
- dst[14] = (float) ((sample6 + last_sample6) * 0.5);
- dst[13] = (float) ((sample5 + last_sample5) * 0.5);
- dst[12] = (float) ((sample4 + last_sample4) * 0.5);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) sample7;
- dst[6] = (float) sample6;
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf);
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst >= target) {
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 8;
- dst[31] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
- dst[30] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
- dst[29] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[28] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[27] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[26] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[25] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[24] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[23] = (float) ((sample7 + last_sample7) * 0.5);
- dst[22] = (float) ((sample6 + last_sample6) * 0.5);
- dst[21] = (float) ((sample5 + last_sample5) * 0.5);
- dst[20] = (float) ((sample4 + last_sample4) * 0.5);
- dst[19] = (float) ((sample3 + last_sample3) * 0.5);
- dst[18] = (float) ((sample2 + last_sample2) * 0.5);
- dst[17] = (float) ((sample1 + last_sample1) * 0.5);
- dst[16] = (float) ((sample0 + last_sample0) * 0.5);
- dst[15] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
- dst[14] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
- dst[13] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[12] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[7] = (float) sample7;
- dst[6] = (float) sample6;
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- src += 32;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src--;
- dst[1] = (float) ((sample0 + last_sample0) * 0.5);
- dst[0] = (float) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src += 2;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src--;
- dst[3] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[0] = (float) sample0;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 2;
- dst[3] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 2;
- dst[7] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[6] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 4;
- dst[7] = (float) ((sample3 + last_sample3) * 0.5);
- dst[6] = (float) ((sample2 + last_sample2) * 0.5);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 4;
- dst[15] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[14] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[13] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[12] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[6] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 6;
- dst[11] = (float) ((sample5 + last_sample5) * 0.5);
- dst[10] = (float) ((sample4 + last_sample4) * 0.5);
- dst[9] = (float) ((sample3 + last_sample3) * 0.5);
- dst[8] = (float) ((sample2 + last_sample2) * 0.5);
- dst[7] = (float) ((sample1 + last_sample1) * 0.5);
- dst[6] = (float) ((sample0 + last_sample0) * 0.5);
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- src += 12;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 6;
- dst[23] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[22] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[21] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[20] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[19] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[18] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[17] = (float) ((sample5 + last_sample5) * 0.5);
- dst[16] = (float) ((sample4 + last_sample4) * 0.5);
- dst[15] = (float) ((sample3 + last_sample3) * 0.5);
- dst[14] = (float) ((sample2 + last_sample2) * 0.5);
- dst[13] = (float) ((sample1 + last_sample1) * 0.5);
- dst[12] = (float) ((sample0 + last_sample0) * 0.5);
- dst[11] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[10] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[9] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[8] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[7] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[6] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- src += 24;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf);
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 8;
- dst[15] = (float) ((sample7 + last_sample7) * 0.5);
- dst[14] = (float) ((sample6 + last_sample6) * 0.5);
- dst[13] = (float) ((sample5 + last_sample5) * 0.5);
- dst[12] = (float) ((sample4 + last_sample4) * 0.5);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) sample7;
- dst[6] = (float) sample6;
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf);
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst >= target) {
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 8;
- dst[31] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
- dst[30] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
- dst[29] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[28] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[27] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[26] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[25] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[24] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- dst[23] = (float) ((sample7 + last_sample7) * 0.5);
- dst[22] = (float) ((sample6 + last_sample6) * 0.5);
- dst[21] = (float) ((sample5 + last_sample5) * 0.5);
- dst[20] = (float) ((sample4 + last_sample4) * 0.5);
- dst[19] = (float) ((sample3 + last_sample3) * 0.5);
- dst[18] = (float) ((sample2 + last_sample2) * 0.5);
- dst[17] = (float) ((sample1 + last_sample1) * 0.5);
- dst[16] = (float) ((sample0 + last_sample0) * 0.5);
- dst[15] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
- dst[14] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
- dst[13] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[12] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[7] = (float) sample7;
- dst[6] = (float) sample6;
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- src += 32;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-#endif /* !LESS_RESAMPLERS */
-#endif /* !NO_RESAMPLERS */
-
-
-const SDL_AudioRateFilters sdl_audio_rate_filters[] =
-{
-#if !NO_RESAMPLERS
- { AUDIO_U8, 1, 0, 0, SDL_Downsample_U8_1c },
- { AUDIO_U8, 1, 1, 0, SDL_Upsample_U8_1c },
- { AUDIO_U8, 2, 0, 0, SDL_Downsample_U8_2c },
- { AUDIO_U8, 2, 1, 0, SDL_Upsample_U8_2c },
- { AUDIO_U8, 4, 0, 0, SDL_Downsample_U8_4c },
- { AUDIO_U8, 4, 1, 0, SDL_Upsample_U8_4c },
- { AUDIO_U8, 6, 0, 0, SDL_Downsample_U8_6c },
- { AUDIO_U8, 6, 1, 0, SDL_Upsample_U8_6c },
- { AUDIO_U8, 8, 0, 0, SDL_Downsample_U8_8c },
- { AUDIO_U8, 8, 1, 0, SDL_Upsample_U8_8c },
- { AUDIO_S8, 1, 0, 0, SDL_Downsample_S8_1c },
- { AUDIO_S8, 1, 1, 0, SDL_Upsample_S8_1c },
- { AUDIO_S8, 2, 0, 0, SDL_Downsample_S8_2c },
- { AUDIO_S8, 2, 1, 0, SDL_Upsample_S8_2c },
- { AUDIO_S8, 4, 0, 0, SDL_Downsample_S8_4c },
- { AUDIO_S8, 4, 1, 0, SDL_Upsample_S8_4c },
- { AUDIO_S8, 6, 0, 0, SDL_Downsample_S8_6c },
- { AUDIO_S8, 6, 1, 0, SDL_Upsample_S8_6c },
- { AUDIO_S8, 8, 0, 0, SDL_Downsample_S8_8c },
- { AUDIO_S8, 8, 1, 0, SDL_Upsample_S8_8c },
- { AUDIO_U16LSB, 1, 0, 0, SDL_Downsample_U16LSB_1c },
- { AUDIO_U16LSB, 1, 1, 0, SDL_Upsample_U16LSB_1c },
- { AUDIO_U16LSB, 2, 0, 0, SDL_Downsample_U16LSB_2c },
- { AUDIO_U16LSB, 2, 1, 0, SDL_Upsample_U16LSB_2c },
- { AUDIO_U16LSB, 4, 0, 0, SDL_Downsample_U16LSB_4c },
- { AUDIO_U16LSB, 4, 1, 0, SDL_Upsample_U16LSB_4c },
- { AUDIO_U16LSB, 6, 0, 0, SDL_Downsample_U16LSB_6c },
- { AUDIO_U16LSB, 6, 1, 0, SDL_Upsample_U16LSB_6c },
- { AUDIO_U16LSB, 8, 0, 0, SDL_Downsample_U16LSB_8c },
- { AUDIO_U16LSB, 8, 1, 0, SDL_Upsample_U16LSB_8c },
- { AUDIO_S16LSB, 1, 0, 0, SDL_Downsample_S16LSB_1c },
- { AUDIO_S16LSB, 1, 1, 0, SDL_Upsample_S16LSB_1c },
- { AUDIO_S16LSB, 2, 0, 0, SDL_Downsample_S16LSB_2c },
- { AUDIO_S16LSB, 2, 1, 0, SDL_Upsample_S16LSB_2c },
- { AUDIO_S16LSB, 4, 0, 0, SDL_Downsample_S16LSB_4c },
- { AUDIO_S16LSB, 4, 1, 0, SDL_Upsample_S16LSB_4c },
- { AUDIO_S16LSB, 6, 0, 0, SDL_Downsample_S16LSB_6c },
- { AUDIO_S16LSB, 6, 1, 0, SDL_Upsample_S16LSB_6c },
- { AUDIO_S16LSB, 8, 0, 0, SDL_Downsample_S16LSB_8c },
- { AUDIO_S16LSB, 8, 1, 0, SDL_Upsample_S16LSB_8c },
- { AUDIO_U16MSB, 1, 0, 0, SDL_Downsample_U16MSB_1c },
- { AUDIO_U16MSB, 1, 1, 0, SDL_Upsample_U16MSB_1c },
- { AUDIO_U16MSB, 2, 0, 0, SDL_Downsample_U16MSB_2c },
- { AUDIO_U16MSB, 2, 1, 0, SDL_Upsample_U16MSB_2c },
- { AUDIO_U16MSB, 4, 0, 0, SDL_Downsample_U16MSB_4c },
- { AUDIO_U16MSB, 4, 1, 0, SDL_Upsample_U16MSB_4c },
- { AUDIO_U16MSB, 6, 0, 0, SDL_Downsample_U16MSB_6c },
- { AUDIO_U16MSB, 6, 1, 0, SDL_Upsample_U16MSB_6c },
- { AUDIO_U16MSB, 8, 0, 0, SDL_Downsample_U16MSB_8c },
- { AUDIO_U16MSB, 8, 1, 0, SDL_Upsample_U16MSB_8c },
- { AUDIO_S16MSB, 1, 0, 0, SDL_Downsample_S16MSB_1c },
- { AUDIO_S16MSB, 1, 1, 0, SDL_Upsample_S16MSB_1c },
- { AUDIO_S16MSB, 2, 0, 0, SDL_Downsample_S16MSB_2c },
- { AUDIO_S16MSB, 2, 1, 0, SDL_Upsample_S16MSB_2c },
- { AUDIO_S16MSB, 4, 0, 0, SDL_Downsample_S16MSB_4c },
- { AUDIO_S16MSB, 4, 1, 0, SDL_Upsample_S16MSB_4c },
- { AUDIO_S16MSB, 6, 0, 0, SDL_Downsample_S16MSB_6c },
- { AUDIO_S16MSB, 6, 1, 0, SDL_Upsample_S16MSB_6c },
- { AUDIO_S16MSB, 8, 0, 0, SDL_Downsample_S16MSB_8c },
- { AUDIO_S16MSB, 8, 1, 0, SDL_Upsample_S16MSB_8c },
- { AUDIO_S32LSB, 1, 0, 0, SDL_Downsample_S32LSB_1c },
- { AUDIO_S32LSB, 1, 1, 0, SDL_Upsample_S32LSB_1c },
- { AUDIO_S32LSB, 2, 0, 0, SDL_Downsample_S32LSB_2c },
- { AUDIO_S32LSB, 2, 1, 0, SDL_Upsample_S32LSB_2c },
- { AUDIO_S32LSB, 4, 0, 0, SDL_Downsample_S32LSB_4c },
- { AUDIO_S32LSB, 4, 1, 0, SDL_Upsample_S32LSB_4c },
- { AUDIO_S32LSB, 6, 0, 0, SDL_Downsample_S32LSB_6c },
- { AUDIO_S32LSB, 6, 1, 0, SDL_Upsample_S32LSB_6c },
- { AUDIO_S32LSB, 8, 0, 0, SDL_Downsample_S32LSB_8c },
- { AUDIO_S32LSB, 8, 1, 0, SDL_Upsample_S32LSB_8c },
- { AUDIO_S32MSB, 1, 0, 0, SDL_Downsample_S32MSB_1c },
- { AUDIO_S32MSB, 1, 1, 0, SDL_Upsample_S32MSB_1c },
- { AUDIO_S32MSB, 2, 0, 0, SDL_Downsample_S32MSB_2c },
- { AUDIO_S32MSB, 2, 1, 0, SDL_Upsample_S32MSB_2c },
- { AUDIO_S32MSB, 4, 0, 0, SDL_Downsample_S32MSB_4c },
- { AUDIO_S32MSB, 4, 1, 0, SDL_Upsample_S32MSB_4c },
- { AUDIO_S32MSB, 6, 0, 0, SDL_Downsample_S32MSB_6c },
- { AUDIO_S32MSB, 6, 1, 0, SDL_Upsample_S32MSB_6c },
- { AUDIO_S32MSB, 8, 0, 0, SDL_Downsample_S32MSB_8c },
- { AUDIO_S32MSB, 8, 1, 0, SDL_Upsample_S32MSB_8c },
- { AUDIO_F32LSB, 1, 0, 0, SDL_Downsample_F32LSB_1c },
- { AUDIO_F32LSB, 1, 1, 0, SDL_Upsample_F32LSB_1c },
- { AUDIO_F32LSB, 2, 0, 0, SDL_Downsample_F32LSB_2c },
- { AUDIO_F32LSB, 2, 1, 0, SDL_Upsample_F32LSB_2c },
- { AUDIO_F32LSB, 4, 0, 0, SDL_Downsample_F32LSB_4c },
- { AUDIO_F32LSB, 4, 1, 0, SDL_Upsample_F32LSB_4c },
- { AUDIO_F32LSB, 6, 0, 0, SDL_Downsample_F32LSB_6c },
- { AUDIO_F32LSB, 6, 1, 0, SDL_Upsample_F32LSB_6c },
- { AUDIO_F32LSB, 8, 0, 0, SDL_Downsample_F32LSB_8c },
- { AUDIO_F32LSB, 8, 1, 0, SDL_Upsample_F32LSB_8c },
- { AUDIO_F32MSB, 1, 0, 0, SDL_Downsample_F32MSB_1c },
- { AUDIO_F32MSB, 1, 1, 0, SDL_Upsample_F32MSB_1c },
- { AUDIO_F32MSB, 2, 0, 0, SDL_Downsample_F32MSB_2c },
- { AUDIO_F32MSB, 2, 1, 0, SDL_Upsample_F32MSB_2c },
- { AUDIO_F32MSB, 4, 0, 0, SDL_Downsample_F32MSB_4c },
- { AUDIO_F32MSB, 4, 1, 0, SDL_Upsample_F32MSB_4c },
- { AUDIO_F32MSB, 6, 0, 0, SDL_Downsample_F32MSB_6c },
- { AUDIO_F32MSB, 6, 1, 0, SDL_Upsample_F32MSB_6c },
- { AUDIO_F32MSB, 8, 0, 0, SDL_Downsample_F32MSB_8c },
- { AUDIO_F32MSB, 8, 1, 0, SDL_Upsample_F32MSB_8c },
-#if !LESS_RESAMPLERS
- { AUDIO_U8, 1, 0, 2, SDL_Downsample_U8_1c_x2 },
- { AUDIO_U8, 1, 1, 2, SDL_Upsample_U8_1c_x2 },
- { AUDIO_U8, 1, 0, 4, SDL_Downsample_U8_1c_x4 },
- { AUDIO_U8, 1, 1, 4, SDL_Upsample_U8_1c_x4 },
- { AUDIO_U8, 2, 0, 2, SDL_Downsample_U8_2c_x2 },
- { AUDIO_U8, 2, 1, 2, SDL_Upsample_U8_2c_x2 },
- { AUDIO_U8, 2, 0, 4, SDL_Downsample_U8_2c_x4 },
- { AUDIO_U8, 2, 1, 4, SDL_Upsample_U8_2c_x4 },
- { AUDIO_U8, 4, 0, 2, SDL_Downsample_U8_4c_x2 },
- { AUDIO_U8, 4, 1, 2, SDL_Upsample_U8_4c_x2 },
- { AUDIO_U8, 4, 0, 4, SDL_Downsample_U8_4c_x4 },
- { AUDIO_U8, 4, 1, 4, SDL_Upsample_U8_4c_x4 },
- { AUDIO_U8, 6, 0, 2, SDL_Downsample_U8_6c_x2 },
- { AUDIO_U8, 6, 1, 2, SDL_Upsample_U8_6c_x2 },
- { AUDIO_U8, 6, 0, 4, SDL_Downsample_U8_6c_x4 },
- { AUDIO_U8, 6, 1, 4, SDL_Upsample_U8_6c_x4 },
- { AUDIO_U8, 8, 0, 2, SDL_Downsample_U8_8c_x2 },
- { AUDIO_U8, 8, 1, 2, SDL_Upsample_U8_8c_x2 },
- { AUDIO_U8, 8, 0, 4, SDL_Downsample_U8_8c_x4 },
- { AUDIO_U8, 8, 1, 4, SDL_Upsample_U8_8c_x4 },
- { AUDIO_S8, 1, 0, 2, SDL_Downsample_S8_1c_x2 },
- { AUDIO_S8, 1, 1, 2, SDL_Upsample_S8_1c_x2 },
- { AUDIO_S8, 1, 0, 4, SDL_Downsample_S8_1c_x4 },
- { AUDIO_S8, 1, 1, 4, SDL_Upsample_S8_1c_x4 },
- { AUDIO_S8, 2, 0, 2, SDL_Downsample_S8_2c_x2 },
- { AUDIO_S8, 2, 1, 2, SDL_Upsample_S8_2c_x2 },
- { AUDIO_S8, 2, 0, 4, SDL_Downsample_S8_2c_x4 },
- { AUDIO_S8, 2, 1, 4, SDL_Upsample_S8_2c_x4 },
- { AUDIO_S8, 4, 0, 2, SDL_Downsample_S8_4c_x2 },
- { AUDIO_S8, 4, 1, 2, SDL_Upsample_S8_4c_x2 },
- { AUDIO_S8, 4, 0, 4, SDL_Downsample_S8_4c_x4 },
- { AUDIO_S8, 4, 1, 4, SDL_Upsample_S8_4c_x4 },
- { AUDIO_S8, 6, 0, 2, SDL_Downsample_S8_6c_x2 },
- { AUDIO_S8, 6, 1, 2, SDL_Upsample_S8_6c_x2 },
- { AUDIO_S8, 6, 0, 4, SDL_Downsample_S8_6c_x4 },
- { AUDIO_S8, 6, 1, 4, SDL_Upsample_S8_6c_x4 },
- { AUDIO_S8, 8, 0, 2, SDL_Downsample_S8_8c_x2 },
- { AUDIO_S8, 8, 1, 2, SDL_Upsample_S8_8c_x2 },
- { AUDIO_S8, 8, 0, 4, SDL_Downsample_S8_8c_x4 },
- { AUDIO_S8, 8, 1, 4, SDL_Upsample_S8_8c_x4 },
- { AUDIO_U16LSB, 1, 0, 2, SDL_Downsample_U16LSB_1c_x2 },
- { AUDIO_U16LSB, 1, 1, 2, SDL_Upsample_U16LSB_1c_x2 },
- { AUDIO_U16LSB, 1, 0, 4, SDL_Downsample_U16LSB_1c_x4 },
- { AUDIO_U16LSB, 1, 1, 4, SDL_Upsample_U16LSB_1c_x4 },
- { AUDIO_U16LSB, 2, 0, 2, SDL_Downsample_U16LSB_2c_x2 },
- { AUDIO_U16LSB, 2, 1, 2, SDL_Upsample_U16LSB_2c_x2 },
- { AUDIO_U16LSB, 2, 0, 4, SDL_Downsample_U16LSB_2c_x4 },
- { AUDIO_U16LSB, 2, 1, 4, SDL_Upsample_U16LSB_2c_x4 },
- { AUDIO_U16LSB, 4, 0, 2, SDL_Downsample_U16LSB_4c_x2 },
- { AUDIO_U16LSB, 4, 1, 2, SDL_Upsample_U16LSB_4c_x2 },
- { AUDIO_U16LSB, 4, 0, 4, SDL_Downsample_U16LSB_4c_x4 },
- { AUDIO_U16LSB, 4, 1, 4, SDL_Upsample_U16LSB_4c_x4 },
- { AUDIO_U16LSB, 6, 0, 2, SDL_Downsample_U16LSB_6c_x2 },
- { AUDIO_U16LSB, 6, 1, 2, SDL_Upsample_U16LSB_6c_x2 },
- { AUDIO_U16LSB, 6, 0, 4, SDL_Downsample_U16LSB_6c_x4 },
- { AUDIO_U16LSB, 6, 1, 4, SDL_Upsample_U16LSB_6c_x4 },
- { AUDIO_U16LSB, 8, 0, 2, SDL_Downsample_U16LSB_8c_x2 },
- { AUDIO_U16LSB, 8, 1, 2, SDL_Upsample_U16LSB_8c_x2 },
- { AUDIO_U16LSB, 8, 0, 4, SDL_Downsample_U16LSB_8c_x4 },
- { AUDIO_U16LSB, 8, 1, 4, SDL_Upsample_U16LSB_8c_x4 },
- { AUDIO_S16LSB, 1, 0, 2, SDL_Downsample_S16LSB_1c_x2 },
- { AUDIO_S16LSB, 1, 1, 2, SDL_Upsample_S16LSB_1c_x2 },
- { AUDIO_S16LSB, 1, 0, 4, SDL_Downsample_S16LSB_1c_x4 },
- { AUDIO_S16LSB, 1, 1, 4, SDL_Upsample_S16LSB_1c_x4 },
- { AUDIO_S16LSB, 2, 0, 2, SDL_Downsample_S16LSB_2c_x2 },
- { AUDIO_S16LSB, 2, 1, 2, SDL_Upsample_S16LSB_2c_x2 },
- { AUDIO_S16LSB, 2, 0, 4, SDL_Downsample_S16LSB_2c_x4 },
- { AUDIO_S16LSB, 2, 1, 4, SDL_Upsample_S16LSB_2c_x4 },
- { AUDIO_S16LSB, 4, 0, 2, SDL_Downsample_S16LSB_4c_x2 },
- { AUDIO_S16LSB, 4, 1, 2, SDL_Upsample_S16LSB_4c_x2 },
- { AUDIO_S16LSB, 4, 0, 4, SDL_Downsample_S16LSB_4c_x4 },
- { AUDIO_S16LSB, 4, 1, 4, SDL_Upsample_S16LSB_4c_x4 },
- { AUDIO_S16LSB, 6, 0, 2, SDL_Downsample_S16LSB_6c_x2 },
- { AUDIO_S16LSB, 6, 1, 2, SDL_Upsample_S16LSB_6c_x2 },
- { AUDIO_S16LSB, 6, 0, 4, SDL_Downsample_S16LSB_6c_x4 },
- { AUDIO_S16LSB, 6, 1, 4, SDL_Upsample_S16LSB_6c_x4 },
- { AUDIO_S16LSB, 8, 0, 2, SDL_Downsample_S16LSB_8c_x2 },
- { AUDIO_S16LSB, 8, 1, 2, SDL_Upsample_S16LSB_8c_x2 },
- { AUDIO_S16LSB, 8, 0, 4, SDL_Downsample_S16LSB_8c_x4 },
- { AUDIO_S16LSB, 8, 1, 4, SDL_Upsample_S16LSB_8c_x4 },
- { AUDIO_U16MSB, 1, 0, 2, SDL_Downsample_U16MSB_1c_x2 },
- { AUDIO_U16MSB, 1, 1, 2, SDL_Upsample_U16MSB_1c_x2 },
- { AUDIO_U16MSB, 1, 0, 4, SDL_Downsample_U16MSB_1c_x4 },
- { AUDIO_U16MSB, 1, 1, 4, SDL_Upsample_U16MSB_1c_x4 },
- { AUDIO_U16MSB, 2, 0, 2, SDL_Downsample_U16MSB_2c_x2 },
- { AUDIO_U16MSB, 2, 1, 2, SDL_Upsample_U16MSB_2c_x2 },
- { AUDIO_U16MSB, 2, 0, 4, SDL_Downsample_U16MSB_2c_x4 },
- { AUDIO_U16MSB, 2, 1, 4, SDL_Upsample_U16MSB_2c_x4 },
- { AUDIO_U16MSB, 4, 0, 2, SDL_Downsample_U16MSB_4c_x2 },
- { AUDIO_U16MSB, 4, 1, 2, SDL_Upsample_U16MSB_4c_x2 },
- { AUDIO_U16MSB, 4, 0, 4, SDL_Downsample_U16MSB_4c_x4 },
- { AUDIO_U16MSB, 4, 1, 4, SDL_Upsample_U16MSB_4c_x4 },
- { AUDIO_U16MSB, 6, 0, 2, SDL_Downsample_U16MSB_6c_x2 },
- { AUDIO_U16MSB, 6, 1, 2, SDL_Upsample_U16MSB_6c_x2 },
- { AUDIO_U16MSB, 6, 0, 4, SDL_Downsample_U16MSB_6c_x4 },
- { AUDIO_U16MSB, 6, 1, 4, SDL_Upsample_U16MSB_6c_x4 },
- { AUDIO_U16MSB, 8, 0, 2, SDL_Downsample_U16MSB_8c_x2 },
- { AUDIO_U16MSB, 8, 1, 2, SDL_Upsample_U16MSB_8c_x2 },
- { AUDIO_U16MSB, 8, 0, 4, SDL_Downsample_U16MSB_8c_x4 },
- { AUDIO_U16MSB, 8, 1, 4, SDL_Upsample_U16MSB_8c_x4 },
- { AUDIO_S16MSB, 1, 0, 2, SDL_Downsample_S16MSB_1c_x2 },
- { AUDIO_S16MSB, 1, 1, 2, SDL_Upsample_S16MSB_1c_x2 },
- { AUDIO_S16MSB, 1, 0, 4, SDL_Downsample_S16MSB_1c_x4 },
- { AUDIO_S16MSB, 1, 1, 4, SDL_Upsample_S16MSB_1c_x4 },
- { AUDIO_S16MSB, 2, 0, 2, SDL_Downsample_S16MSB_2c_x2 },
- { AUDIO_S16MSB, 2, 1, 2, SDL_Upsample_S16MSB_2c_x2 },
- { AUDIO_S16MSB, 2, 0, 4, SDL_Downsample_S16MSB_2c_x4 },
- { AUDIO_S16MSB, 2, 1, 4, SDL_Upsample_S16MSB_2c_x4 },
- { AUDIO_S16MSB, 4, 0, 2, SDL_Downsample_S16MSB_4c_x2 },
- { AUDIO_S16MSB, 4, 1, 2, SDL_Upsample_S16MSB_4c_x2 },
- { AUDIO_S16MSB, 4, 0, 4, SDL_Downsample_S16MSB_4c_x4 },
- { AUDIO_S16MSB, 4, 1, 4, SDL_Upsample_S16MSB_4c_x4 },
- { AUDIO_S16MSB, 6, 0, 2, SDL_Downsample_S16MSB_6c_x2 },
- { AUDIO_S16MSB, 6, 1, 2, SDL_Upsample_S16MSB_6c_x2 },
- { AUDIO_S16MSB, 6, 0, 4, SDL_Downsample_S16MSB_6c_x4 },
- { AUDIO_S16MSB, 6, 1, 4, SDL_Upsample_S16MSB_6c_x4 },
- { AUDIO_S16MSB, 8, 0, 2, SDL_Downsample_S16MSB_8c_x2 },
- { AUDIO_S16MSB, 8, 1, 2, SDL_Upsample_S16MSB_8c_x2 },
- { AUDIO_S16MSB, 8, 0, 4, SDL_Downsample_S16MSB_8c_x4 },
- { AUDIO_S16MSB, 8, 1, 4, SDL_Upsample_S16MSB_8c_x4 },
- { AUDIO_S32LSB, 1, 0, 2, SDL_Downsample_S32LSB_1c_x2 },
- { AUDIO_S32LSB, 1, 1, 2, SDL_Upsample_S32LSB_1c_x2 },
- { AUDIO_S32LSB, 1, 0, 4, SDL_Downsample_S32LSB_1c_x4 },
- { AUDIO_S32LSB, 1, 1, 4, SDL_Upsample_S32LSB_1c_x4 },
- { AUDIO_S32LSB, 2, 0, 2, SDL_Downsample_S32LSB_2c_x2 },
- { AUDIO_S32LSB, 2, 1, 2, SDL_Upsample_S32LSB_2c_x2 },
- { AUDIO_S32LSB, 2, 0, 4, SDL_Downsample_S32LSB_2c_x4 },
- { AUDIO_S32LSB, 2, 1, 4, SDL_Upsample_S32LSB_2c_x4 },
- { AUDIO_S32LSB, 4, 0, 2, SDL_Downsample_S32LSB_4c_x2 },
- { AUDIO_S32LSB, 4, 1, 2, SDL_Upsample_S32LSB_4c_x2 },
- { AUDIO_S32LSB, 4, 0, 4, SDL_Downsample_S32LSB_4c_x4 },
- { AUDIO_S32LSB, 4, 1, 4, SDL_Upsample_S32LSB_4c_x4 },
- { AUDIO_S32LSB, 6, 0, 2, SDL_Downsample_S32LSB_6c_x2 },
- { AUDIO_S32LSB, 6, 1, 2, SDL_Upsample_S32LSB_6c_x2 },
- { AUDIO_S32LSB, 6, 0, 4, SDL_Downsample_S32LSB_6c_x4 },
- { AUDIO_S32LSB, 6, 1, 4, SDL_Upsample_S32LSB_6c_x4 },
- { AUDIO_S32LSB, 8, 0, 2, SDL_Downsample_S32LSB_8c_x2 },
- { AUDIO_S32LSB, 8, 1, 2, SDL_Upsample_S32LSB_8c_x2 },
- { AUDIO_S32LSB, 8, 0, 4, SDL_Downsample_S32LSB_8c_x4 },
- { AUDIO_S32LSB, 8, 1, 4, SDL_Upsample_S32LSB_8c_x4 },
- { AUDIO_S32MSB, 1, 0, 2, SDL_Downsample_S32MSB_1c_x2 },
- { AUDIO_S32MSB, 1, 1, 2, SDL_Upsample_S32MSB_1c_x2 },
- { AUDIO_S32MSB, 1, 0, 4, SDL_Downsample_S32MSB_1c_x4 },
- { AUDIO_S32MSB, 1, 1, 4, SDL_Upsample_S32MSB_1c_x4 },
- { AUDIO_S32MSB, 2, 0, 2, SDL_Downsample_S32MSB_2c_x2 },
- { AUDIO_S32MSB, 2, 1, 2, SDL_Upsample_S32MSB_2c_x2 },
- { AUDIO_S32MSB, 2, 0, 4, SDL_Downsample_S32MSB_2c_x4 },
- { AUDIO_S32MSB, 2, 1, 4, SDL_Upsample_S32MSB_2c_x4 },
- { AUDIO_S32MSB, 4, 0, 2, SDL_Downsample_S32MSB_4c_x2 },
- { AUDIO_S32MSB, 4, 1, 2, SDL_Upsample_S32MSB_4c_x2 },
- { AUDIO_S32MSB, 4, 0, 4, SDL_Downsample_S32MSB_4c_x4 },
- { AUDIO_S32MSB, 4, 1, 4, SDL_Upsample_S32MSB_4c_x4 },
- { AUDIO_S32MSB, 6, 0, 2, SDL_Downsample_S32MSB_6c_x2 },
- { AUDIO_S32MSB, 6, 1, 2, SDL_Upsample_S32MSB_6c_x2 },
- { AUDIO_S32MSB, 6, 0, 4, SDL_Downsample_S32MSB_6c_x4 },
- { AUDIO_S32MSB, 6, 1, 4, SDL_Upsample_S32MSB_6c_x4 },
- { AUDIO_S32MSB, 8, 0, 2, SDL_Downsample_S32MSB_8c_x2 },
- { AUDIO_S32MSB, 8, 1, 2, SDL_Upsample_S32MSB_8c_x2 },
- { AUDIO_S32MSB, 8, 0, 4, SDL_Downsample_S32MSB_8c_x4 },
- { AUDIO_S32MSB, 8, 1, 4, SDL_Upsample_S32MSB_8c_x4 },
- { AUDIO_F32LSB, 1, 0, 2, SDL_Downsample_F32LSB_1c_x2 },
- { AUDIO_F32LSB, 1, 1, 2, SDL_Upsample_F32LSB_1c_x2 },
- { AUDIO_F32LSB, 1, 0, 4, SDL_Downsample_F32LSB_1c_x4 },
- { AUDIO_F32LSB, 1, 1, 4, SDL_Upsample_F32LSB_1c_x4 },
- { AUDIO_F32LSB, 2, 0, 2, SDL_Downsample_F32LSB_2c_x2 },
- { AUDIO_F32LSB, 2, 1, 2, SDL_Upsample_F32LSB_2c_x2 },
- { AUDIO_F32LSB, 2, 0, 4, SDL_Downsample_F32LSB_2c_x4 },
- { AUDIO_F32LSB, 2, 1, 4, SDL_Upsample_F32LSB_2c_x4 },
- { AUDIO_F32LSB, 4, 0, 2, SDL_Downsample_F32LSB_4c_x2 },
- { AUDIO_F32LSB, 4, 1, 2, SDL_Upsample_F32LSB_4c_x2 },
- { AUDIO_F32LSB, 4, 0, 4, SDL_Downsample_F32LSB_4c_x4 },
- { AUDIO_F32LSB, 4, 1, 4, SDL_Upsample_F32LSB_4c_x4 },
- { AUDIO_F32LSB, 6, 0, 2, SDL_Downsample_F32LSB_6c_x2 },
- { AUDIO_F32LSB, 6, 1, 2, SDL_Upsample_F32LSB_6c_x2 },
- { AUDIO_F32LSB, 6, 0, 4, SDL_Downsample_F32LSB_6c_x4 },
- { AUDIO_F32LSB, 6, 1, 4, SDL_Upsample_F32LSB_6c_x4 },
- { AUDIO_F32LSB, 8, 0, 2, SDL_Downsample_F32LSB_8c_x2 },
- { AUDIO_F32LSB, 8, 1, 2, SDL_Upsample_F32LSB_8c_x2 },
- { AUDIO_F32LSB, 8, 0, 4, SDL_Downsample_F32LSB_8c_x4 },
- { AUDIO_F32LSB, 8, 1, 4, SDL_Upsample_F32LSB_8c_x4 },
- { AUDIO_F32MSB, 1, 0, 2, SDL_Downsample_F32MSB_1c_x2 },
- { AUDIO_F32MSB, 1, 1, 2, SDL_Upsample_F32MSB_1c_x2 },
- { AUDIO_F32MSB, 1, 0, 4, SDL_Downsample_F32MSB_1c_x4 },
- { AUDIO_F32MSB, 1, 1, 4, SDL_Upsample_F32MSB_1c_x4 },
- { AUDIO_F32MSB, 2, 0, 2, SDL_Downsample_F32MSB_2c_x2 },
- { AUDIO_F32MSB, 2, 1, 2, SDL_Upsample_F32MSB_2c_x2 },
- { AUDIO_F32MSB, 2, 0, 4, SDL_Downsample_F32MSB_2c_x4 },
- { AUDIO_F32MSB, 2, 1, 4, SDL_Upsample_F32MSB_2c_x4 },
- { AUDIO_F32MSB, 4, 0, 2, SDL_Downsample_F32MSB_4c_x2 },
- { AUDIO_F32MSB, 4, 1, 2, SDL_Upsample_F32MSB_4c_x2 },
- { AUDIO_F32MSB, 4, 0, 4, SDL_Downsample_F32MSB_4c_x4 },
- { AUDIO_F32MSB, 4, 1, 4, SDL_Upsample_F32MSB_4c_x4 },
- { AUDIO_F32MSB, 6, 0, 2, SDL_Downsample_F32MSB_6c_x2 },
- { AUDIO_F32MSB, 6, 1, 2, SDL_Upsample_F32MSB_6c_x2 },
- { AUDIO_F32MSB, 6, 0, 4, SDL_Downsample_F32MSB_6c_x4 },
- { AUDIO_F32MSB, 6, 1, 4, SDL_Upsample_F32MSB_6c_x4 },
- { AUDIO_F32MSB, 8, 0, 2, SDL_Downsample_F32MSB_8c_x2 },
- { AUDIO_F32MSB, 8, 1, 2, SDL_Upsample_F32MSB_8c_x2 },
- { AUDIO_F32MSB, 8, 0, 4, SDL_Downsample_F32MSB_8c_x4 },
- { AUDIO_F32MSB, 8, 1, 4, SDL_Upsample_F32MSB_8c_x4 },
-#endif /* !LESS_RESAMPLERS */
-#endif /* !NO_RESAMPLERS */
- { 0, 0, 0, 0, NULL }
-};
-
-/* 390 converters generated. */
-
-/* *INDENT-ON* */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_mixer.c b/3rdparty/SDL2/src/audio/SDL_mixer.c
deleted file mode 100644
index e0219392d5b..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_mixer.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-/* This provides the default mixing callback for the SDL audio routines */
-
-#include "SDL_cpuinfo.h"
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "SDL_sysaudio.h"
-
-/* This table is used to add two sound values together and pin
- * the value to avoid overflow. (used with permission from ARDI)
- * Changed to use 0xFE instead of 0xFF for better sound quality.
- */
-static const Uint8 mix8[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
- 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
- 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
- 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
- 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
- 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
- 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
- 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
- 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
- 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
- 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92,
- 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
- 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8,
- 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
- 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
- 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9,
- 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
- 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
- 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
- 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE
-};
-
-/* The volume ranges from 0 - 128 */
-#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
-#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
-
-
-void
-SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
- Uint32 len, int volume)
-{
- if (volume == 0) {
- return;
- }
-
- switch (format) {
-
- case AUDIO_U8:
- {
-#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
- SDL_MixAudio_m68k_U8((char *) dst, (char *) src,
- (unsigned long) len, (long) volume,
- (char *) mix8);
-#else
- Uint8 src_sample;
-
- while (len--) {
- src_sample = *src;
- ADJUST_VOLUME_U8(src_sample, volume);
- *dst = mix8[*dst + src_sample];
- ++dst;
- ++src;
- }
-#endif
- }
- break;
-
- case AUDIO_S8:
- {
- Sint8 *dst8, *src8;
- Sint8 src_sample;
- int dst_sample;
- const int max_audioval = ((1 << (8 - 1)) - 1);
- const int min_audioval = -(1 << (8 - 1));
-
- src8 = (Sint8 *) src;
- dst8 = (Sint8 *) dst;
- while (len--) {
- src_sample = *src8;
- ADJUST_VOLUME(src_sample, volume);
- dst_sample = *dst8 + src_sample;
- if (dst_sample > max_audioval) {
- *dst8 = max_audioval;
- } else if (dst_sample < min_audioval) {
- *dst8 = min_audioval;
- } else {
- *dst8 = dst_sample;
- }
- ++dst8;
- ++src8;
- }
- }
- break;
-
- case AUDIO_S16LSB:
- {
- Sint16 src1, src2;
- int dst_sample;
- const int max_audioval = ((1 << (16 - 1)) - 1);
- const int min_audioval = -(1 << (16 - 1));
-
- len /= 2;
- while (len--) {
- src1 = ((src[1]) << 8 | src[0]);
- ADJUST_VOLUME(src1, volume);
- src2 = ((dst[1]) << 8 | dst[0]);
- src += 2;
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- dst[0] = dst_sample & 0xFF;
- dst_sample >>= 8;
- dst[1] = dst_sample & 0xFF;
- dst += 2;
- }
- }
- break;
-
- case AUDIO_S16MSB:
- {
-#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
- SDL_MixAudio_m68k_S16MSB((short *) dst, (short *) src,
- (unsigned long) len, (long) volume);
-#else
- Sint16 src1, src2;
- int dst_sample;
- const int max_audioval = ((1 << (16 - 1)) - 1);
- const int min_audioval = -(1 << (16 - 1));
-
- len /= 2;
- while (len--) {
- src1 = ((src[0]) << 8 | src[1]);
- ADJUST_VOLUME(src1, volume);
- src2 = ((dst[0]) << 8 | dst[1]);
- src += 2;
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- dst[1] = dst_sample & 0xFF;
- dst_sample >>= 8;
- dst[0] = dst_sample & 0xFF;
- dst += 2;
- }
-#endif
- }
- break;
-
- case AUDIO_U16LSB:
- {
- Uint16 src1, src2;
- int dst_sample;
- const int max_audioval = 0xFFFF;
-
- len /= 2;
- while (len--) {
- src1 = ((src[1]) << 8 | src[0]);
- ADJUST_VOLUME(src1, volume);
- src2 = ((dst[1]) << 8 | dst[0]);
- src += 2;
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- }
- dst[0] = dst_sample & 0xFF;
- dst_sample >>= 8;
- dst[1] = dst_sample & 0xFF;
- dst += 2;
- }
- }
- break;
-
- case AUDIO_U16MSB:
- {
- Uint16 src1, src2;
- int dst_sample;
- const int max_audioval = 0xFFFF;
-
- len /= 2;
- while (len--) {
- src1 = ((src[0]) << 8 | src[1]);
- ADJUST_VOLUME(src1, volume);
- src2 = ((dst[0]) << 8 | dst[1]);
- src += 2;
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- }
- dst[1] = dst_sample & 0xFF;
- dst_sample >>= 8;
- dst[0] = dst_sample & 0xFF;
- dst += 2;
- }
- }
- break;
-
- case AUDIO_S32LSB:
- {
- const Uint32 *src32 = (Uint32 *) src;
- Uint32 *dst32 = (Uint32 *) dst;
- Sint64 src1, src2;
- Sint64 dst_sample;
- const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
- const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
-
- len /= 4;
- while (len--) {
- src1 = (Sint64) ((Sint32) SDL_SwapLE32(*src32));
- src32++;
- ADJUST_VOLUME(src1, volume);
- src2 = (Sint64) ((Sint32) SDL_SwapLE32(*dst32));
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapLE32((Uint32) ((Sint32) dst_sample));
- }
- }
- break;
-
- case AUDIO_S32MSB:
- {
- const Uint32 *src32 = (Uint32 *) src;
- Uint32 *dst32 = (Uint32 *) dst;
- Sint64 src1, src2;
- Sint64 dst_sample;
- const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
- const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
-
- len /= 4;
- while (len--) {
- src1 = (Sint64) ((Sint32) SDL_SwapBE32(*src32));
- src32++;
- ADJUST_VOLUME(src1, volume);
- src2 = (Sint64) ((Sint32) SDL_SwapBE32(*dst32));
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapBE32((Uint32) ((Sint32) dst_sample));
- }
- }
- break;
-
- case AUDIO_F32LSB:
- {
- const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
- const float fvolume = (float) volume;
- const float *src32 = (float *) src;
- float *dst32 = (float *) dst;
- float src1, src2;
- double dst_sample;
- /* !!! FIXME: are these right? */
- const double max_audioval = 3.402823466e+38F;
- const double min_audioval = -3.402823466e+38F;
-
- len /= 4;
- while (len--) {
- src1 = ((SDL_SwapFloatLE(*src32) * fvolume) * fmaxvolume);
- src2 = SDL_SwapFloatLE(*dst32);
- src32++;
-
- dst_sample = ((double) src1) + ((double) src2);
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapFloatLE((float) dst_sample);
- }
- }
- break;
-
- case AUDIO_F32MSB:
- {
- const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
- const float fvolume = (float) volume;
- const float *src32 = (float *) src;
- float *dst32 = (float *) dst;
- float src1, src2;
- double dst_sample;
- /* !!! FIXME: are these right? */
- const double max_audioval = 3.402823466e+38F;
- const double min_audioval = -3.402823466e+38F;
-
- len /= 4;
- while (len--) {
- src1 = ((SDL_SwapFloatBE(*src32) * fvolume) * fmaxvolume);
- src2 = SDL_SwapFloatBE(*dst32);
- src32++;
-
- dst_sample = ((double) src1) + ((double) src2);
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapFloatBE((float) dst_sample);
- }
- }
- break;
-
- default: /* If this happens... FIXME! */
- SDL_SetError("SDL_MixAudioFormat(): unknown audio format");
- return;
- }
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_sysaudio.h b/3rdparty/SDL2/src/audio/SDL_sysaudio.h
deleted file mode 100644
index 943169bf7c1..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_sysaudio.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-#ifndef _SDL_sysaudio_h
-#define _SDL_sysaudio_h
-
-#include "SDL_mutex.h"
-#include "SDL_thread.h"
-
-/* !!! FIXME: These are wordy and unlocalized... */
-#define DEFAULT_OUTPUT_DEVNAME "System audio output device"
-#define DEFAULT_INPUT_DEVNAME "System audio capture device"
-
-/* The SDL audio driver */
-typedef struct SDL_AudioDevice SDL_AudioDevice;
-#define _THIS SDL_AudioDevice *_this
-
-/* Audio targets should call this as devices are added to the system (such as
- a USB headset being plugged in), and should also be called for
- for every device found during DetectDevices(). */
-extern void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle);
-
-/* Audio targets should call this as devices are removed, so SDL can update
- its list of available devices. */
-extern void SDL_RemoveAudioDevice(const int iscapture, void *handle);
-
-/* Audio targets should call this if an opened audio device is lost while
- being used. This can happen due to i/o errors, or a device being unplugged,
- etc. If the device is totally gone, please also call SDL_RemoveAudioDevice()
- as appropriate so SDL's list of devices is accurate. */
-extern void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device);
-
-
-/* This is the size of a packet when using SDL_QueueAudio(). We allocate
- these as necessary and pool them, under the assumption that we'll
- eventually end up with a handful that keep recycling, meeting whatever
- the app needs. We keep packing data tightly as more arrives to avoid
- wasting space, and if we get a giant block of data, we'll split them
- into multiple packets behind the scenes. My expectation is that most
- apps will have 2-3 of these in the pool. 8k should cover most needs, but
- if this is crippling for some embedded system, we can #ifdef this.
- The system preallocates enough packets for 2 callbacks' worth of data. */
-#define SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024)
-
-/* Used by apps that queue audio instead of using the callback. */
-typedef struct SDL_AudioBufferQueue
-{
- Uint8 data[SDL_AUDIOBUFFERQUEUE_PACKETLEN]; /* packet data. */
- Uint32 datalen; /* bytes currently in use in this packet. */
- Uint32 startpos; /* bytes currently consumed in this packet. */
- struct SDL_AudioBufferQueue *next; /* next item in linked list. */
-} SDL_AudioBufferQueue;
-
-typedef struct SDL_AudioDriverImpl
-{
- void (*DetectDevices) (void);
- int (*OpenDevice) (_THIS, void *handle, const char *devname, int iscapture);
- void (*ThreadInit) (_THIS); /* Called by audio thread at start */
- void (*WaitDevice) (_THIS);
- void (*PlayDevice) (_THIS);
- int (*GetPendingBytes) (_THIS);
- Uint8 *(*GetDeviceBuf) (_THIS);
- int (*CaptureFromDevice) (_THIS, void *buffer, int buflen);
- void (*FlushCapture) (_THIS);
- void (*PrepareToClose) (_THIS); /**< Called between run and draining wait for playback devices */
- void (*CloseDevice) (_THIS);
- void (*LockDevice) (_THIS);
- void (*UnlockDevice) (_THIS);
- void (*FreeDeviceHandle) (void *handle); /**< SDL is done with handle from SDL_AddAudioDevice() */
- void (*Deinitialize) (void);
-
- /* !!! FIXME: add pause(), so we can optimize instead of mixing silence. */
-
- /* Some flags to push duplicate code into the core and reduce #ifdefs. */
- /* !!! FIXME: these should be SDL_bool */
- int ProvidesOwnCallbackThread;
- int SkipMixerLock;
- int HasCaptureSupport;
- int OnlyHasDefaultOutputDevice;
- int OnlyHasDefaultCaptureDevice;
- int AllowsArbitraryDeviceNames;
-} SDL_AudioDriverImpl;
-
-
-typedef struct SDL_AudioDeviceItem
-{
- void *handle;
- struct SDL_AudioDeviceItem *next;
- #if (defined(__GNUC__) && (__GNUC__ <= 2))
- char name[1]; /* actually variable length. */
- #else
- char name[];
- #endif
-} SDL_AudioDeviceItem;
-
-
-typedef struct SDL_AudioDriver
-{
- /* * * */
- /* The name of this audio driver */
- const char *name;
-
- /* * * */
- /* The description of this audio driver */
- const char *desc;
-
- SDL_AudioDriverImpl impl;
-
- /* A mutex for device detection */
- SDL_mutex *detectionLock;
- SDL_bool captureDevicesRemoved;
- SDL_bool outputDevicesRemoved;
- int outputDeviceCount;
- int inputDeviceCount;
- SDL_AudioDeviceItem *outputDevices;
- SDL_AudioDeviceItem *inputDevices;
-} SDL_AudioDriver;
-
-
-/* Streamer */
-typedef struct
-{
- Uint8 *buffer;
- int max_len; /* the maximum length in bytes */
- int read_pos, write_pos; /* the position of the write and read heads in bytes */
-} SDL_AudioStreamer;
-
-
-/* Define the SDL audio driver structure */
-struct SDL_AudioDevice
-{
- /* * * */
- /* Data common to all devices */
- SDL_AudioDeviceID id;
-
- /* The current audio specification (shared with audio thread) */
- SDL_AudioSpec spec;
-
- /* An audio conversion block for audio format emulation */
- SDL_AudioCVT convert;
-
- /* The streamer, if sample rate conversion necessitates it */
- int use_streamer;
- SDL_AudioStreamer streamer;
-
- /* Current state flags */
- SDL_atomic_t shutdown; /* true if we are signaling the play thread to end. */
- SDL_atomic_t enabled; /* true if device is functioning and connected. */
- SDL_atomic_t paused;
- SDL_bool iscapture;
-
- /* Fake audio buffer for when the audio hardware is busy */
- Uint8 *fake_stream;
-
- /* A mutex for locking the mixing buffers */
- SDL_mutex *mixer_lock;
-
- /* A thread to feed the audio device */
- SDL_Thread *thread;
- SDL_threadID threadid;
-
- /* Queued buffers (if app not using callback). */
- SDL_AudioBufferQueue *buffer_queue_head; /* device fed from here. */
- SDL_AudioBufferQueue *buffer_queue_tail; /* queue fills to here. */
- SDL_AudioBufferQueue *buffer_queue_pool; /* these are unused packets. */
- Uint32 queued_bytes; /* number of bytes of audio data in the queue. */
-
- /* * * */
- /* Data private to this driver */
- struct SDL_PrivateAudioData *hidden;
-
- void *handle;
-};
-#undef _THIS
-
-typedef struct AudioBootStrap
-{
- const char *name;
- const char *desc;
- int (*init) (SDL_AudioDriverImpl * impl);
- int demand_only; /* 1==request explicitly, or it won't be available. */
-} AudioBootStrap;
-
-#endif /* _SDL_sysaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_wave.c b/3rdparty/SDL2/src/audio/SDL_wave.c
deleted file mode 100644
index d173b4a9217..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_wave.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-/* Microsoft WAVE file loading routines */
-
-#include "SDL_audio.h"
-#include "SDL_wave.h"
-
-
-static int ReadChunk(SDL_RWops * src, Chunk * chunk);
-
-struct MS_ADPCM_decodestate
-{
- Uint8 hPredictor;
- Uint16 iDelta;
- Sint16 iSamp1;
- Sint16 iSamp2;
-};
-static struct MS_ADPCM_decoder
-{
- WaveFMT wavefmt;
- Uint16 wSamplesPerBlock;
- Uint16 wNumCoef;
- Sint16 aCoeff[7][2];
- /* * * */
- struct MS_ADPCM_decodestate state[2];
-} MS_ADPCM_state;
-
-static int
-InitMS_ADPCM(WaveFMT * format)
-{
- Uint8 *rogue_feel;
- int i;
-
- /* Set the rogue pointer to the MS_ADPCM specific data */
- MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
- MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
- MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
- MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
- MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
- MS_ADPCM_state.wavefmt.bitspersample =
- SDL_SwapLE16(format->bitspersample);
- rogue_feel = (Uint8 *) format + sizeof(*format);
- if (sizeof(*format) == 16) {
- /* const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */
- rogue_feel += sizeof(Uint16);
- }
- MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- MS_ADPCM_state.wNumCoef = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- if (MS_ADPCM_state.wNumCoef != 7) {
- SDL_SetError("Unknown set of MS_ADPCM coefficients");
- return (-1);
- }
- for (i = 0; i < MS_ADPCM_state.wNumCoef; ++i) {
- MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- }
- return (0);
-}
-
-static Sint32
-MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
- Uint8 nybble, Sint16 * coeff)
-{
- const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
- const Sint32 min_audioval = -(1 << (16 - 1));
- const Sint32 adaptive[] = {
- 230, 230, 230, 230, 307, 409, 512, 614,
- 768, 614, 512, 409, 307, 230, 230, 230
- };
- Sint32 new_sample, delta;
-
- new_sample = ((state->iSamp1 * coeff[0]) +
- (state->iSamp2 * coeff[1])) / 256;
- if (nybble & 0x08) {
- new_sample += state->iDelta * (nybble - 0x10);
- } else {
- new_sample += state->iDelta * nybble;
- }
- if (new_sample < min_audioval) {
- new_sample = min_audioval;
- } else if (new_sample > max_audioval) {
- new_sample = max_audioval;
- }
- delta = ((Sint32) state->iDelta * adaptive[nybble]) / 256;
- if (delta < 16) {
- delta = 16;
- }
- state->iDelta = (Uint16) delta;
- state->iSamp2 = state->iSamp1;
- state->iSamp1 = (Sint16) new_sample;
- return (new_sample);
-}
-
-static int
-MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
-{
- struct MS_ADPCM_decodestate *state[2];
- Uint8 *freeable, *encoded, *decoded;
- Sint32 encoded_len, samplesleft;
- Sint8 nybble;
- Uint8 stereo;
- Sint16 *coeff[2];
- Sint32 new_sample;
-
- /* Allocate the proper sized output buffer */
- encoded_len = *audio_len;
- encoded = *audio_buf;
- freeable = *audio_buf;
- *audio_len = (encoded_len / MS_ADPCM_state.wavefmt.blockalign) *
- MS_ADPCM_state.wSamplesPerBlock *
- MS_ADPCM_state.wavefmt.channels * sizeof(Sint16);
- *audio_buf = (Uint8 *) SDL_malloc(*audio_len);
- if (*audio_buf == NULL) {
- return SDL_OutOfMemory();
- }
- decoded = *audio_buf;
-
- /* Get ready... Go! */
- stereo = (MS_ADPCM_state.wavefmt.channels == 2);
- state[0] = &MS_ADPCM_state.state[0];
- state[1] = &MS_ADPCM_state.state[stereo];
- while (encoded_len >= MS_ADPCM_state.wavefmt.blockalign) {
- /* Grab the initial information for this block */
- state[0]->hPredictor = *encoded++;
- if (stereo) {
- state[1]->hPredictor = *encoded++;
- }
- state[0]->iDelta = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- if (stereo) {
- state[1]->iDelta = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- }
- state[0]->iSamp1 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- if (stereo) {
- state[1]->iSamp1 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- }
- state[0]->iSamp2 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- if (stereo) {
- state[1]->iSamp2 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- }
- coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
- coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
-
- /* Store the two initial samples we start with */
- decoded[0] = state[0]->iSamp2 & 0xFF;
- decoded[1] = state[0]->iSamp2 >> 8;
- decoded += 2;
- if (stereo) {
- decoded[0] = state[1]->iSamp2 & 0xFF;
- decoded[1] = state[1]->iSamp2 >> 8;
- decoded += 2;
- }
- decoded[0] = state[0]->iSamp1 & 0xFF;
- decoded[1] = state[0]->iSamp1 >> 8;
- decoded += 2;
- if (stereo) {
- decoded[0] = state[1]->iSamp1 & 0xFF;
- decoded[1] = state[1]->iSamp1 >> 8;
- decoded += 2;
- }
-
- /* Decode and store the other samples in this block */
- samplesleft = (MS_ADPCM_state.wSamplesPerBlock - 2) *
- MS_ADPCM_state.wavefmt.channels;
- while (samplesleft > 0) {
- nybble = (*encoded) >> 4;
- new_sample = MS_ADPCM_nibble(state[0], nybble, coeff[0]);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2;
-
- nybble = (*encoded) & 0x0F;
- new_sample = MS_ADPCM_nibble(state[1], nybble, coeff[1]);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2;
-
- ++encoded;
- samplesleft -= 2;
- }
- encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
- }
- SDL_free(freeable);
- return (0);
-}
-
-struct IMA_ADPCM_decodestate
-{
- Sint32 sample;
- Sint8 index;
-};
-static struct IMA_ADPCM_decoder
-{
- WaveFMT wavefmt;
- Uint16 wSamplesPerBlock;
- /* * * */
- struct IMA_ADPCM_decodestate state[2];
-} IMA_ADPCM_state;
-
-static int
-InitIMA_ADPCM(WaveFMT * format)
-{
- Uint8 *rogue_feel;
-
- /* Set the rogue pointer to the IMA_ADPCM specific data */
- IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
- IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
- IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
- IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
- IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
- IMA_ADPCM_state.wavefmt.bitspersample =
- SDL_SwapLE16(format->bitspersample);
- rogue_feel = (Uint8 *) format + sizeof(*format);
- if (sizeof(*format) == 16) {
- /* const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */
- rogue_feel += sizeof(Uint16);
- }
- IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]);
- return (0);
-}
-
-static Sint32
-IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble)
-{
- const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
- const Sint32 min_audioval = -(1 << (16 - 1));
- const int index_table[16] = {
- -1, -1, -1, -1,
- 2, 4, 6, 8,
- -1, -1, -1, -1,
- 2, 4, 6, 8
- };
- const Sint32 step_table[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
- 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
- 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
- 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
- 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
- 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
- 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
- 22385, 24623, 27086, 29794, 32767
- };
- Sint32 delta, step;
-
- /* Compute difference and new sample value */
- if (state->index > 88) {
- state->index = 88;
- } else if (state->index < 0) {
- state->index = 0;
- }
- /* explicit cast to avoid gcc warning about using 'char' as array index */
- step = step_table[(int)state->index];
- delta = step >> 3;
- if (nybble & 0x04)
- delta += step;
- if (nybble & 0x02)
- delta += (step >> 1);
- if (nybble & 0x01)
- delta += (step >> 2);
- if (nybble & 0x08)
- delta = -delta;
- state->sample += delta;
-
- /* Update index value */
- state->index += index_table[nybble];
-
- /* Clamp output sample */
- if (state->sample > max_audioval) {
- state->sample = max_audioval;
- } else if (state->sample < min_audioval) {
- state->sample = min_audioval;
- }
- return (state->sample);
-}
-
-/* Fill the decode buffer with a channel block of data (8 samples) */
-static void
-Fill_IMA_ADPCM_block(Uint8 * decoded, Uint8 * encoded,
- int channel, int numchannels,
- struct IMA_ADPCM_decodestate *state)
-{
- int i;
- Sint8 nybble;
- Sint32 new_sample;
-
- decoded += (channel * 2);
- for (i = 0; i < 4; ++i) {
- nybble = (*encoded) & 0x0F;
- new_sample = IMA_ADPCM_nibble(state, nybble);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2 * numchannels;
-
- nybble = (*encoded) >> 4;
- new_sample = IMA_ADPCM_nibble(state, nybble);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2 * numchannels;
-
- ++encoded;
- }
-}
-
-static int
-IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
-{
- struct IMA_ADPCM_decodestate *state;
- Uint8 *freeable, *encoded, *decoded;
- Sint32 encoded_len, samplesleft;
- unsigned int c, channels;
-
- /* Check to make sure we have enough variables in the state array */
- channels = IMA_ADPCM_state.wavefmt.channels;
- if (channels > SDL_arraysize(IMA_ADPCM_state.state)) {
- SDL_SetError("IMA ADPCM decoder can only handle %u channels",
- (unsigned int)SDL_arraysize(IMA_ADPCM_state.state));
- return (-1);
- }
- state = IMA_ADPCM_state.state;
-
- /* Allocate the proper sized output buffer */
- encoded_len = *audio_len;
- encoded = *audio_buf;
- freeable = *audio_buf;
- *audio_len = (encoded_len / IMA_ADPCM_state.wavefmt.blockalign) *
- IMA_ADPCM_state.wSamplesPerBlock *
- IMA_ADPCM_state.wavefmt.channels * sizeof(Sint16);
- *audio_buf = (Uint8 *) SDL_malloc(*audio_len);
- if (*audio_buf == NULL) {
- return SDL_OutOfMemory();
- }
- decoded = *audio_buf;
-
- /* Get ready... Go! */
- while (encoded_len >= IMA_ADPCM_state.wavefmt.blockalign) {
- /* Grab the initial information for this block */
- for (c = 0; c < channels; ++c) {
- /* Fill the state information for this block */
- state[c].sample = ((encoded[1] << 8) | encoded[0]);
- encoded += 2;
- if (state[c].sample & 0x8000) {
- state[c].sample -= 0x10000;
- }
- state[c].index = *encoded++;
- /* Reserved byte in buffer header, should be 0 */
- if (*encoded++ != 0) {
- /* Uh oh, corrupt data? Buggy code? */ ;
- }
-
- /* Store the initial sample we start with */
- decoded[0] = (Uint8) (state[c].sample & 0xFF);
- decoded[1] = (Uint8) (state[c].sample >> 8);
- decoded += 2;
- }
-
- /* Decode and store the other samples in this block */
- samplesleft = (IMA_ADPCM_state.wSamplesPerBlock - 1) * channels;
- while (samplesleft > 0) {
- for (c = 0; c < channels; ++c) {
- Fill_IMA_ADPCM_block(decoded, encoded,
- c, channels, &state[c]);
- encoded += 4;
- samplesleft -= 8;
- }
- decoded += (channels * 8 * 2);
- }
- encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
- }
- SDL_free(freeable);
- return (0);
-}
-
-SDL_AudioSpec *
-SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
- SDL_AudioSpec * spec, Uint8 ** audio_buf, Uint32 * audio_len)
-{
- int was_error;
- Chunk chunk;
- int lenread;
- int IEEE_float_encoded, MS_ADPCM_encoded, IMA_ADPCM_encoded;
- int samplesize;
-
- /* WAV magic header */
- Uint32 RIFFchunk;
- Uint32 wavelen = 0;
- Uint32 WAVEmagic;
- Uint32 headerDiff = 0;
-
- /* FMT chunk */
- WaveFMT *format = NULL;
-
- SDL_zero(chunk);
-
- /* Make sure we are passed a valid data source */
- was_error = 0;
- if (src == NULL) {
- was_error = 1;
- goto done;
- }
-
- /* Check the magic header */
- RIFFchunk = SDL_ReadLE32(src);
- wavelen = SDL_ReadLE32(src);
- if (wavelen == WAVE) { /* The RIFFchunk has already been read */
- WAVEmagic = wavelen;
- wavelen = RIFFchunk;
- RIFFchunk = RIFF;
- } else {
- WAVEmagic = SDL_ReadLE32(src);
- }
- if ((RIFFchunk != RIFF) || (WAVEmagic != WAVE)) {
- SDL_SetError("Unrecognized file type (not WAVE)");
- was_error = 1;
- goto done;
- }
- headerDiff += sizeof(Uint32); /* for WAVE */
-
- /* Read the audio data format chunk */
- chunk.data = NULL;
- do {
- SDL_free(chunk.data);
- chunk.data = NULL;
- lenread = ReadChunk(src, &chunk);
- if (lenread < 0) {
- was_error = 1;
- goto done;
- }
- /* 2 Uint32's for chunk header+len, plus the lenread */
- headerDiff += lenread + 2 * sizeof(Uint32);
- } while ((chunk.magic == FACT) || (chunk.magic == LIST) || (chunk.magic == BEXT) || (chunk.magic == JUNK));
-
- /* Decode the audio data format */
- format = (WaveFMT *) chunk.data;
- if (chunk.magic != FMT) {
- SDL_SetError("Complex WAVE files not supported");
- was_error = 1;
- goto done;
- }
- IEEE_float_encoded = MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
- switch (SDL_SwapLE16(format->encoding)) {
- case PCM_CODE:
- /* We can understand this */
- break;
- case IEEE_FLOAT_CODE:
- IEEE_float_encoded = 1;
- /* We can understand this */
- break;
- case MS_ADPCM_CODE:
- /* Try to understand this */
- if (InitMS_ADPCM(format) < 0) {
- was_error = 1;
- goto done;
- }
- MS_ADPCM_encoded = 1;
- break;
- case IMA_ADPCM_CODE:
- /* Try to understand this */
- if (InitIMA_ADPCM(format) < 0) {
- was_error = 1;
- goto done;
- }
- IMA_ADPCM_encoded = 1;
- break;
- case MP3_CODE:
- SDL_SetError("MPEG Layer 3 data not supported");
- was_error = 1;
- goto done;
- default:
- SDL_SetError("Unknown WAVE data format: 0x%.4x",
- SDL_SwapLE16(format->encoding));
- was_error = 1;
- goto done;
- }
- SDL_zerop(spec);
- spec->freq = SDL_SwapLE32(format->frequency);
-
- if (IEEE_float_encoded) {
- if ((SDL_SwapLE16(format->bitspersample)) != 32) {
- was_error = 1;
- } else {
- spec->format = AUDIO_F32;
- }
- } else {
- switch (SDL_SwapLE16(format->bitspersample)) {
- case 4:
- if (MS_ADPCM_encoded || IMA_ADPCM_encoded) {
- spec->format = AUDIO_S16;
- } else {
- was_error = 1;
- }
- break;
- case 8:
- spec->format = AUDIO_U8;
- break;
- case 16:
- spec->format = AUDIO_S16;
- break;
- case 32:
- spec->format = AUDIO_S32;
- break;
- default:
- was_error = 1;
- break;
- }
- }
-
- if (was_error) {
- SDL_SetError("Unknown %d-bit PCM data format",
- SDL_SwapLE16(format->bitspersample));
- goto done;
- }
- spec->channels = (Uint8) SDL_SwapLE16(format->channels);
- spec->samples = 4096; /* Good default buffer size */
-
- /* Read the audio data chunk */
- *audio_buf = NULL;
- do {
- SDL_free(*audio_buf);
- *audio_buf = NULL;
- lenread = ReadChunk(src, &chunk);
- if (lenread < 0) {
- was_error = 1;
- goto done;
- }
- *audio_len = lenread;
- *audio_buf = chunk.data;
- if (chunk.magic != DATA)
- headerDiff += lenread + 2 * sizeof(Uint32);
- } while (chunk.magic != DATA);
- headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
-
- if (MS_ADPCM_encoded) {
- if (MS_ADPCM_decode(audio_buf, audio_len) < 0) {
- was_error = 1;
- goto done;
- }
- }
- if (IMA_ADPCM_encoded) {
- if (IMA_ADPCM_decode(audio_buf, audio_len) < 0) {
- was_error = 1;
- goto done;
- }
- }
-
- /* Don't return a buffer that isn't a multiple of samplesize */
- samplesize = ((SDL_AUDIO_BITSIZE(spec->format)) / 8) * spec->channels;
- *audio_len &= ~(samplesize - 1);
-
- done:
- SDL_free(format);
- if (src) {
- if (freesrc) {
- SDL_RWclose(src);
- } else {
- /* seek to the end of the file (given by the RIFF chunk) */
- SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
- }
- }
- if (was_error) {
- spec = NULL;
- }
- return (spec);
-}
-
-/* Since the WAV memory is allocated in the shared library, it must also
- be freed here. (Necessary under Win32, VC++)
- */
-void
-SDL_FreeWAV(Uint8 * audio_buf)
-{
- SDL_free(audio_buf);
-}
-
-static int
-ReadChunk(SDL_RWops * src, Chunk * chunk)
-{
- chunk->magic = SDL_ReadLE32(src);
- chunk->length = SDL_ReadLE32(src);
- chunk->data = (Uint8 *) SDL_malloc(chunk->length);
- if (chunk->data == NULL) {
- return SDL_OutOfMemory();
- }
- if (SDL_RWread(src, chunk->data, chunk->length, 1) != 1) {
- SDL_free(chunk->data);
- chunk->data = NULL;
- return SDL_Error(SDL_EFREAD);
- }
- return (chunk->length);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/SDL_wave.h b/3rdparty/SDL2/src/audio/SDL_wave.h
deleted file mode 100644
index f2f93986ee4..00000000000
--- a/3rdparty/SDL2/src/audio/SDL_wave.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-/* WAVE files are little-endian */
-
-/*******************************************/
-/* Define values for Microsoft WAVE format */
-/*******************************************/
-#define RIFF 0x46464952 /* "RIFF" */
-#define WAVE 0x45564157 /* "WAVE" */
-#define FACT 0x74636166 /* "fact" */
-#define LIST 0x5453494c /* "LIST" */
-#define BEXT 0x74786562 /* "bext" */
-#define JUNK 0x4B4E554A /* "JUNK" */
-#define FMT 0x20746D66 /* "fmt " */
-#define DATA 0x61746164 /* "data" */
-#define PCM_CODE 0x0001
-#define MS_ADPCM_CODE 0x0002
-#define IEEE_FLOAT_CODE 0x0003
-#define IMA_ADPCM_CODE 0x0011
-#define MP3_CODE 0x0055
-#define WAVE_MONO 1
-#define WAVE_STEREO 2
-
-/* Normally, these three chunks come consecutively in a WAVE file */
-typedef struct WaveFMT
-{
-/* Not saved in the chunk we read:
- Uint32 FMTchunk;
- Uint32 fmtlen;
-*/
- Uint16 encoding;
- Uint16 channels; /* 1 = mono, 2 = stereo */
- Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
- Uint32 byterate; /* Average bytes per second */
- Uint16 blockalign; /* Bytes per sample block */
- Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
-} WaveFMT;
-
-/* The general chunk found in the WAVE file */
-typedef struct Chunk
-{
- Uint32 magic;
- Uint32 length;
- Uint8 *data;
-} Chunk;
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.c b/3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.c
deleted file mode 100644
index 574d51bd5ec..00000000000
--- a/3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.c
+++ /dev/null
@@ -1,983 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_ALSA
-
-/* Allow access to a raw mixing buffer */
-
-#include <sys/types.h>
-#include <signal.h> /* For kill() */
-#include <errno.h>
-#include <string.h>
-
-#include "SDL_assert.h"
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_alsa_audio.h"
-
-#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
-#include "SDL_loadso.h"
-#endif
-
-static int (*ALSA_snd_pcm_open)
- (snd_pcm_t **, const char *, snd_pcm_stream_t, int);
-static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm);
-static snd_pcm_sframes_t (*ALSA_snd_pcm_writei)
- (snd_pcm_t *, const void *, snd_pcm_uframes_t);
-static snd_pcm_sframes_t (*ALSA_snd_pcm_readi)
- (snd_pcm_t *, void *, snd_pcm_uframes_t);
-static int (*ALSA_snd_pcm_recover) (snd_pcm_t *, int, int);
-static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *);
-static int (*ALSA_snd_pcm_drain) (snd_pcm_t *);
-static const char *(*ALSA_snd_strerror) (int);
-static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void);
-static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void);
-static void (*ALSA_snd_pcm_hw_params_copy)
- (snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *);
-static int (*ALSA_snd_pcm_hw_params_any) (snd_pcm_t *, snd_pcm_hw_params_t *);
-static int (*ALSA_snd_pcm_hw_params_set_access)
- (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t);
-static int (*ALSA_snd_pcm_hw_params_set_format)
- (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t);
-static int (*ALSA_snd_pcm_hw_params_set_channels)
- (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
-static int (*ALSA_snd_pcm_hw_params_get_channels)
- (const snd_pcm_hw_params_t *, unsigned int *);
-static int (*ALSA_snd_pcm_hw_params_set_rate_near)
- (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
-static int (*ALSA_snd_pcm_hw_params_set_period_size_near)
- (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
-static int (*ALSA_snd_pcm_hw_params_get_period_size)
- (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
-static int (*ALSA_snd_pcm_hw_params_set_periods_near)
- (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
-static int (*ALSA_snd_pcm_hw_params_get_periods)
- (const snd_pcm_hw_params_t *, unsigned int *, int *);
-static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near)
- (snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
-static int (*ALSA_snd_pcm_hw_params_get_buffer_size)
- (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
-static int (*ALSA_snd_pcm_hw_params) (snd_pcm_t *, snd_pcm_hw_params_t *);
-static int (*ALSA_snd_pcm_sw_params_current) (snd_pcm_t *,
- snd_pcm_sw_params_t *);
-static int (*ALSA_snd_pcm_sw_params_set_start_threshold)
- (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
-static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *);
-static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int);
-static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int);
-static int (*ALSA_snd_pcm_sw_params_set_avail_min)
- (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
-static int (*ALSA_snd_pcm_reset)(snd_pcm_t *);
-static int (*ALSA_snd_device_name_hint) (int, const char *, void ***);
-static char* (*ALSA_snd_device_name_get_hint) (const void *, const char *);
-static int (*ALSA_snd_device_name_free_hint) (void **);
-
-#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
-#define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof
-#define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof
-
-static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC;
-static void *alsa_handle = NULL;
-
-static int
-load_alsa_sym(const char *fn, void **addr)
-{
- *addr = SDL_LoadFunction(alsa_handle, fn);
- if (*addr == NULL) {
- /* Don't call SDL_SetError(): SDL_LoadFunction already did. */
- return 0;
- }
-
- return 1;
-}
-
-/* cast funcs to char* first, to please GCC's strict aliasing rules. */
-#define SDL_ALSA_SYM(x) \
- if (!load_alsa_sym(#x, (void **) (char *) &ALSA_##x)) return -1
-#else
-#define SDL_ALSA_SYM(x) ALSA_##x = x
-#endif
-
-static int
-load_alsa_syms(void)
-{
- SDL_ALSA_SYM(snd_pcm_open);
- SDL_ALSA_SYM(snd_pcm_close);
- SDL_ALSA_SYM(snd_pcm_writei);
- SDL_ALSA_SYM(snd_pcm_readi);
- SDL_ALSA_SYM(snd_pcm_recover);
- SDL_ALSA_SYM(snd_pcm_prepare);
- SDL_ALSA_SYM(snd_pcm_drain);
- SDL_ALSA_SYM(snd_strerror);
- SDL_ALSA_SYM(snd_pcm_hw_params_sizeof);
- SDL_ALSA_SYM(snd_pcm_sw_params_sizeof);
- SDL_ALSA_SYM(snd_pcm_hw_params_copy);
- SDL_ALSA_SYM(snd_pcm_hw_params_any);
- SDL_ALSA_SYM(snd_pcm_hw_params_set_access);
- SDL_ALSA_SYM(snd_pcm_hw_params_set_format);
- SDL_ALSA_SYM(snd_pcm_hw_params_set_channels);
- SDL_ALSA_SYM(snd_pcm_hw_params_get_channels);
- SDL_ALSA_SYM(snd_pcm_hw_params_set_rate_near);
- SDL_ALSA_SYM(snd_pcm_hw_params_set_period_size_near);
- SDL_ALSA_SYM(snd_pcm_hw_params_get_period_size);
- SDL_ALSA_SYM(snd_pcm_hw_params_set_periods_near);
- SDL_ALSA_SYM(snd_pcm_hw_params_get_periods);
- SDL_ALSA_SYM(snd_pcm_hw_params_set_buffer_size_near);
- SDL_ALSA_SYM(snd_pcm_hw_params_get_buffer_size);
- SDL_ALSA_SYM(snd_pcm_hw_params);
- SDL_ALSA_SYM(snd_pcm_sw_params_current);
- SDL_ALSA_SYM(snd_pcm_sw_params_set_start_threshold);
- SDL_ALSA_SYM(snd_pcm_sw_params);
- SDL_ALSA_SYM(snd_pcm_nonblock);
- SDL_ALSA_SYM(snd_pcm_wait);
- SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min);
- SDL_ALSA_SYM(snd_pcm_reset);
- SDL_ALSA_SYM(snd_device_name_hint);
- SDL_ALSA_SYM(snd_device_name_get_hint);
- SDL_ALSA_SYM(snd_device_name_free_hint);
-
- return 0;
-}
-
-#undef SDL_ALSA_SYM
-
-#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
-
-static void
-UnloadALSALibrary(void)
-{
- if (alsa_handle != NULL) {
- SDL_UnloadObject(alsa_handle);
- alsa_handle = NULL;
- }
-}
-
-static int
-LoadALSALibrary(void)
-{
- int retval = 0;
- if (alsa_handle == NULL) {
- alsa_handle = SDL_LoadObject(alsa_library);
- if (alsa_handle == NULL) {
- retval = -1;
- /* Don't call SDL_SetError(): SDL_LoadObject already did. */
- } else {
- retval = load_alsa_syms();
- if (retval < 0) {
- UnloadALSALibrary();
- }
- }
- }
- return retval;
-}
-
-#else
-
-static void
-UnloadALSALibrary(void)
-{
-}
-
-static int
-LoadALSALibrary(void)
-{
- load_alsa_syms();
- return 0;
-}
-
-#endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
-
-static const char *
-get_audio_device(void *handle, const int channels)
-{
- const char *device;
-
- if (handle != NULL) {
- return (const char *) handle;
- }
-
- /* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */
- device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */
- if (device != NULL) {
- return device;
- }
-
- if (channels == 6) {
- return "plug:surround51";
- } else if (channels == 4) {
- return "plug:surround40";
- }
-
- return "default";
-}
-
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-ALSA_WaitDevice(_THIS)
-{
- /* We're in blocking mode, so there's nothing to do here */
-}
-
-
-/* !!! FIXME: is there a channel swizzler in alsalib instead? */
-/*
- * http://bugzilla.libsdl.org/show_bug.cgi?id=110
- * "For Linux ALSA, this is FL-FR-RL-RR-C-LFE
- * and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-RL-RR"
- */
-#define SWIZ6(T, buf, numframes) \
- T *ptr = (T *) buf; \
- Uint32 i; \
- for (i = 0; i < numframes; i++, ptr += 6) { \
- T tmp; \
- tmp = ptr[2]; ptr[2] = ptr[4]; ptr[4] = tmp; \
- tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \
- }
-
-static SDL_INLINE void
-swizzle_alsa_channels_6_64bit(void *buffer, Uint32 bufferlen)
-{
- SWIZ6(Uint64, buffer, bufferlen);
-}
-
-static SDL_INLINE void
-swizzle_alsa_channels_6_32bit(void *buffer, Uint32 bufferlen)
-{
- SWIZ6(Uint32, buffer, bufferlen);
-}
-
-static SDL_INLINE void
-swizzle_alsa_channels_6_16bit(void *buffer, Uint32 bufferlen)
-{
- SWIZ6(Uint16, buffer, bufferlen);
-}
-
-static SDL_INLINE void
-swizzle_alsa_channels_6_8bit(void *buffer, Uint32 bufferlen)
-{
- SWIZ6(Uint8, buffer, bufferlen);
-}
-
-#undef SWIZ6
-
-
-/*
- * Called right before feeding this->hidden->mixbuf to the hardware. Swizzle
- * channels from Windows/Mac order to the format alsalib will want.
- */
-static SDL_INLINE void
-swizzle_alsa_channels(_THIS, void *buffer, Uint32 bufferlen)
-{
- if (this->spec.channels == 6) {
- switch (SDL_AUDIO_BITSIZE(this->spec.format)) {
- case 8: swizzle_alsa_channels_6_8bit(buffer, bufferlen); break;
- case 16: swizzle_alsa_channels_6_16bit(buffer, bufferlen); break;
- case 32: swizzle_alsa_channels_6_32bit(buffer, bufferlen); break;
- case 64: swizzle_alsa_channels_6_64bit(buffer, bufferlen); break;
- default: SDL_assert(!"unhandled bitsize"); break;
- }
- }
-
- /* !!! FIXME: update this for 7.1 if needed, later. */
-}
-
-
-static void
-ALSA_PlayDevice(_THIS)
-{
- const Uint8 *sample_buf = (const Uint8 *) this->hidden->mixbuf;
- const int frame_size = (((int) SDL_AUDIO_BITSIZE(this->spec.format)) / 8) *
- this->spec.channels;
- snd_pcm_uframes_t frames_left = ((snd_pcm_uframes_t) this->spec.samples);
-
- swizzle_alsa_channels(this, this->hidden->mixbuf, frames_left);
-
- while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) {
- int status;
-
- /* This wait is a work-around for a hang when USB devices are
- unplugged. Normally it should not result in any waiting,
- but in the case of a USB unplug, it serves as a way to
- join the playback thread after the timeout occurs */
- status = ALSA_snd_pcm_wait(this->hidden->pcm_handle, 1000);
- if (status == 0) {
- /*fprintf(stderr, "ALSA timeout waiting for available buffer space\n");*/
- SDL_OpenedAudioDeviceDisconnected(this);
- return;
- }
-
- status = ALSA_snd_pcm_writei(this->hidden->pcm_handle,
- sample_buf, frames_left);
-
- if (status < 0) {
- if (status == -EAGAIN) {
- /* Apparently snd_pcm_recover() doesn't handle this case -
- does it assume snd_pcm_wait() above? */
- SDL_Delay(1);
- continue;
- }
- status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
- if (status < 0) {
- /* Hmm, not much we can do - abort */
- fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
- ALSA_snd_strerror(status));
- SDL_OpenedAudioDeviceDisconnected(this);
- return;
- }
- continue;
- }
- sample_buf += status * frame_size;
- frames_left -= status;
- }
-}
-
-static Uint8 *
-ALSA_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-static int
-ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- Uint8 *sample_buf = (Uint8 *) buffer;
- const int frame_size = (((int) SDL_AUDIO_BITSIZE(this->spec.format)) / 8) *
- this->spec.channels;
- const int total_frames = buflen / frame_size;
- snd_pcm_uframes_t frames_left = total_frames;
-
- SDL_assert((buflen % frame_size) == 0);
-
- while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) {
- /* !!! FIXME: This works, but needs more testing before going live */
- /* ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1); */
- int status = ALSA_snd_pcm_readi(this->hidden->pcm_handle,
- sample_buf, frames_left);
-
- if (status < 0) {
- /*printf("ALSA: capture error %d\n", status);*/
- if (status == -EAGAIN) {
- /* Apparently snd_pcm_recover() doesn't handle this case -
- does it assume snd_pcm_wait() above? */
- SDL_Delay(1);
- continue;
- }
- status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
- if (status < 0) {
- /* Hmm, not much we can do - abort */
- fprintf(stderr, "ALSA read failed (unrecoverable): %s\n",
- ALSA_snd_strerror(status));
- return -1;
- }
- continue;
- }
-
- /*printf("ALSA: captured %d bytes\n", status * frame_size);*/
- sample_buf += status * frame_size;
- frames_left -= status;
- }
-
- swizzle_alsa_channels(this, buffer, total_frames - frames_left);
-
- return (total_frames - frames_left) * frame_size;
-}
-
-static void
-ALSA_FlushCapture(_THIS)
-{
- ALSA_snd_pcm_reset(this->hidden->pcm_handle);
-}
-
-static void
-ALSA_CloseDevice(_THIS)
-{
- if (this->hidden->pcm_handle) {
- /* Wait for the submitted audio to drain
- ALSA_snd_pcm_drop() can hang, so don't use that.
- */
- Uint32 delay = ((this->spec.samples * 1000) / this->spec.freq) * 2;
- SDL_Delay(delay);
-
- ALSA_snd_pcm_close(this->hidden->pcm_handle);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-ALSA_finalize_hardware(_THIS, snd_pcm_hw_params_t *hwparams, int override)
-{
- int status;
- snd_pcm_uframes_t bufsize;
-
- /* "set" the hardware with the desired parameters */
- status = ALSA_snd_pcm_hw_params(this->hidden->pcm_handle, hwparams);
- if ( status < 0 ) {
- return(-1);
- }
-
- /* Get samples for the actual buffer size */
- status = ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
- if ( status < 0 ) {
- return(-1);
- }
- if ( !override && bufsize != this->spec.samples * 2 ) {
- return(-1);
- }
-
- /* !!! FIXME: Is this safe to do? */
- this->spec.samples = bufsize / 2;
-
- /* This is useful for debugging */
- if ( SDL_getenv("SDL_AUDIO_ALSA_DEBUG") ) {
- snd_pcm_uframes_t persize = 0;
- unsigned int periods = 0;
-
- ALSA_snd_pcm_hw_params_get_period_size(hwparams, &persize, NULL);
- ALSA_snd_pcm_hw_params_get_periods(hwparams, &periods, NULL);
-
- fprintf(stderr,
- "ALSA: period size = %ld, periods = %u, buffer size = %lu\n",
- persize, periods, bufsize);
- }
-
- return(0);
-}
-
-static int
-ALSA_set_period_size(_THIS, snd_pcm_hw_params_t *params, int override)
-{
- const char *env;
- int status;
- snd_pcm_hw_params_t *hwparams;
- snd_pcm_uframes_t frames;
- unsigned int periods;
-
- /* Copy the hardware parameters for this setup */
- snd_pcm_hw_params_alloca(&hwparams);
- ALSA_snd_pcm_hw_params_copy(hwparams, params);
-
- if ( !override ) {
- env = SDL_getenv("SDL_AUDIO_ALSA_SET_PERIOD_SIZE");
- if ( env ) {
- override = SDL_atoi(env);
- if ( override == 0 ) {
- return(-1);
- }
- }
- }
-
- frames = this->spec.samples;
- status = ALSA_snd_pcm_hw_params_set_period_size_near(
- this->hidden->pcm_handle, hwparams, &frames, NULL);
- if ( status < 0 ) {
- return(-1);
- }
-
- periods = 2;
- status = ALSA_snd_pcm_hw_params_set_periods_near(
- this->hidden->pcm_handle, hwparams, &periods, NULL);
- if ( status < 0 ) {
- return(-1);
- }
-
- return ALSA_finalize_hardware(this, hwparams, override);
-}
-
-static int
-ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params, int override)
-{
- const char *env;
- int status;
- snd_pcm_hw_params_t *hwparams;
- snd_pcm_uframes_t frames;
-
- /* Copy the hardware parameters for this setup */
- snd_pcm_hw_params_alloca(&hwparams);
- ALSA_snd_pcm_hw_params_copy(hwparams, params);
-
- if ( !override ) {
- env = SDL_getenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE");
- if ( env ) {
- override = SDL_atoi(env);
- if ( override == 0 ) {
- return(-1);
- }
- }
- }
-
- frames = this->spec.samples * 2;
- status = ALSA_snd_pcm_hw_params_set_buffer_size_near(
- this->hidden->pcm_handle, hwparams, &frames);
- if ( status < 0 ) {
- return(-1);
- }
-
- return ALSA_finalize_hardware(this, hwparams, override);
-}
-
-static int
-ALSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- int status = 0;
- snd_pcm_t *pcm_handle = NULL;
- snd_pcm_hw_params_t *hwparams = NULL;
- snd_pcm_sw_params_t *swparams = NULL;
- snd_pcm_format_t format = 0;
- SDL_AudioFormat test_format = 0;
- unsigned int rate = 0;
- unsigned int channels = 0;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Open the audio device */
- /* Name of device should depend on # channels in spec */
- status = ALSA_snd_pcm_open(&pcm_handle,
- get_audio_device(handle, this->spec.channels),
- iscapture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK,
- SND_PCM_NONBLOCK);
-
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't open audio device: %s",
- ALSA_snd_strerror(status));
- }
-
- this->hidden->pcm_handle = pcm_handle;
-
- /* Figure out what the hardware is capable of */
- snd_pcm_hw_params_alloca(&hwparams);
- status = ALSA_snd_pcm_hw_params_any(pcm_handle, hwparams);
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't get hardware config: %s",
- ALSA_snd_strerror(status));
- }
-
- /* SDL only uses interleaved sample output */
- status = ALSA_snd_pcm_hw_params_set_access(pcm_handle, hwparams,
- SND_PCM_ACCESS_RW_INTERLEAVED);
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't set interleaved access: %s",
- ALSA_snd_strerror(status));
- }
-
- /* Try for a closest match on audio format */
- status = -1;
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- test_format && (status < 0);) {
- status = 0; /* if we can't support a format, it'll become -1. */
- switch (test_format) {
- case AUDIO_U8:
- format = SND_PCM_FORMAT_U8;
- break;
- case AUDIO_S8:
- format = SND_PCM_FORMAT_S8;
- break;
- case AUDIO_S16LSB:
- format = SND_PCM_FORMAT_S16_LE;
- break;
- case AUDIO_S16MSB:
- format = SND_PCM_FORMAT_S16_BE;
- break;
- case AUDIO_U16LSB:
- format = SND_PCM_FORMAT_U16_LE;
- break;
- case AUDIO_U16MSB:
- format = SND_PCM_FORMAT_U16_BE;
- break;
- case AUDIO_S32LSB:
- format = SND_PCM_FORMAT_S32_LE;
- break;
- case AUDIO_S32MSB:
- format = SND_PCM_FORMAT_S32_BE;
- break;
- case AUDIO_F32LSB:
- format = SND_PCM_FORMAT_FLOAT_LE;
- break;
- case AUDIO_F32MSB:
- format = SND_PCM_FORMAT_FLOAT_BE;
- break;
- default:
- status = -1;
- break;
- }
- if (status >= 0) {
- status = ALSA_snd_pcm_hw_params_set_format(pcm_handle,
- hwparams, format);
- }
- if (status < 0) {
- test_format = SDL_NextAudioFormat();
- }
- }
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't find any hardware audio formats");
- }
- this->spec.format = test_format;
-
- /* Set the number of channels */
- status = ALSA_snd_pcm_hw_params_set_channels(pcm_handle, hwparams,
- this->spec.channels);
- channels = this->spec.channels;
- if (status < 0) {
- status = ALSA_snd_pcm_hw_params_get_channels(hwparams, &channels);
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't set audio channels");
- }
- this->spec.channels = channels;
- }
-
- /* Set the audio rate */
- rate = this->spec.freq;
- status = ALSA_snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams,
- &rate, NULL);
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't set audio frequency: %s",
- ALSA_snd_strerror(status));
- }
- this->spec.freq = rate;
-
- /* Set the buffer size, in samples */
- if ( ALSA_set_period_size(this, hwparams, 0) < 0 &&
- ALSA_set_buffer_size(this, hwparams, 0) < 0 ) {
- /* Failed to set desired buffer size, do the best you can... */
- status = ALSA_set_period_size(this, hwparams, 1);
- if (status < 0) {
- return SDL_SetError("Couldn't set hardware audio parameters: %s", ALSA_snd_strerror(status));
- }
- }
- /* Set the software parameters */
- snd_pcm_sw_params_alloca(&swparams);
- status = ALSA_snd_pcm_sw_params_current(pcm_handle, swparams);
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't get software config: %s",
- ALSA_snd_strerror(status));
- }
- status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples);
- if (status < 0) {
- return SDL_SetError("Couldn't set minimum available samples: %s",
- ALSA_snd_strerror(status));
- }
- status =
- ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1);
- if (status < 0) {
- return SDL_SetError("ALSA: Couldn't set start threshold: %s",
- ALSA_snd_strerror(status));
- }
- status = ALSA_snd_pcm_sw_params(pcm_handle, swparams);
- if (status < 0) {
- return SDL_SetError("Couldn't set software audio parameters: %s",
- ALSA_snd_strerror(status));
- }
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate mixing buffer */
- if (!iscapture) {
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen);
- }
-
- /* Switch to blocking mode for playback */
- ALSA_snd_pcm_nonblock(pcm_handle, 0);
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-typedef struct ALSA_Device
-{
- char *name;
- SDL_bool iscapture;
- struct ALSA_Device *next;
-} ALSA_Device;
-
-static void
-add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSeen)
-{
- ALSA_Device *dev = SDL_malloc(sizeof (ALSA_Device));
- char *desc = ALSA_snd_device_name_get_hint(hint, "DESC");
- char *handle = NULL;
- char *ptr;
-
- if (!desc) {
- SDL_free(dev);
- return;
- } else if (!dev) {
- free(desc);
- return;
- }
-
- SDL_assert(name != NULL);
-
- /* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output".
- just chop the extra lines off, this seems to get a reasonable device
- name without extra details. */
- if ((ptr = strchr(desc, '\n')) != NULL) {
- *ptr = '\0';
- }
-
- /*printf("ALSA: adding %s device '%s' (%s)\n", iscapture ? "capture" : "output", name, desc);*/
-
- handle = SDL_strdup(name);
- if (!handle) {
- free(desc);
- SDL_free(dev);
- return;
- }
-
- SDL_AddAudioDevice(iscapture, desc, handle);
- free(desc);
-
- dev->name = handle;
- dev->iscapture = iscapture;
- dev->next = *pSeen;
- *pSeen = dev;
-}
-
-
-static SDL_atomic_t ALSA_hotplug_shutdown;
-static SDL_Thread *ALSA_hotplug_thread;
-
-static int SDLCALL
-ALSA_HotplugThread(void *arg)
-{
- SDL_sem *first_run_semaphore = (SDL_sem *) arg;
- ALSA_Device *devices = NULL;
- ALSA_Device *next;
- ALSA_Device *dev;
- Uint32 ticks;
-
- while (!SDL_AtomicGet(&ALSA_hotplug_shutdown)) {
- void **hints = NULL;
- if (ALSA_snd_device_name_hint(-1, "pcm", &hints) != -1) {
- ALSA_Device *unseen = devices;
- ALSA_Device *seen = NULL;
- ALSA_Device *prev;
- int i, j;
- const char *match = NULL;
- int bestmatch = 0xFFFF;
- size_t match_len = 0;
- int defaultdev = -1;
- static const char * const prefixes[] = {
- "hw:", "sysdefault:", "default:", NULL
- };
-
- /* Apparently there are several different ways that ALSA lists
- actual hardware. It could be prefixed with "hw:" or "default:"
- or "sysdefault:" and maybe others. Go through the list and see
- if we can find a preferred prefix for the system. */
- for (i = 0; hints[i]; i++) {
- char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
- if (!name) {
- continue;
- }
-
- /* full name, not a prefix */
- if ((defaultdev == -1) && (SDL_strcmp(name, "default") == 0)) {
- defaultdev = i;
- }
-
- for (j = 0; prefixes[j]; j++) {
- const char *prefix = prefixes[j];
- const size_t prefixlen = SDL_strlen(prefix);
- if (SDL_strncmp(name, prefix, prefixlen) == 0) {
- if (j < bestmatch) {
- bestmatch = j;
- match = prefix;
- match_len = prefixlen;
- }
- }
- }
-
- free(name);
- }
-
- /* look through the list of device names to find matches */
- for (i = 0; hints[i]; i++) {
- char *name;
-
- /* if we didn't find a device name prefix we like at all... */
- if ((!match) && (defaultdev != i)) {
- continue; /* ...skip anything that isn't the default device. */
- }
-
- name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
- if (!name) {
- continue;
- }
-
- /* only want physical hardware interfaces */
- if (!match || (SDL_strncmp(name, match, match_len) == 0)) {
- char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID");
- const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0);
- const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0);
- SDL_bool have_output = SDL_FALSE;
- SDL_bool have_input = SDL_FALSE;
-
- free(ioid);
-
- if (!isoutput && !isinput) {
- free(name);
- continue;
- }
-
- prev = NULL;
- for (dev = unseen; dev; dev = next) {
- next = dev->next;
- if ( (SDL_strcmp(dev->name, name) == 0) && (((isinput) && dev->iscapture) || ((isoutput) && !dev->iscapture)) ) {
- if (prev) {
- prev->next = next;
- } else {
- unseen = next;
- }
- dev->next = seen;
- seen = dev;
- if (isinput) have_input = SDL_TRUE;
- if (isoutput) have_output = SDL_TRUE;
- } else {
- prev = dev;
- }
- }
-
- if (isinput && !have_input) {
- add_device(SDL_TRUE, name, hints[i], &seen);
- }
- if (isoutput && !have_output) {
- add_device(SDL_FALSE, name, hints[i], &seen);
- }
- }
-
- free(name);
- }
-
- ALSA_snd_device_name_free_hint(hints);
-
- devices = seen; /* now we have a known-good list of attached devices. */
-
- /* report anything still in unseen as removed. */
- for (dev = unseen; dev; dev = next) {
- /*printf("ALSA: removing %s device '%s'\n", dev->iscapture ? "capture" : "output", dev->name);*/
- next = dev->next;
- SDL_RemoveAudioDevice(dev->iscapture, dev->name);
- SDL_free(dev->name);
- SDL_free(dev);
- }
- }
-
- /* On first run, tell ALSA_DetectDevices() that we have a complete device list so it can return. */
- if (first_run_semaphore) {
- SDL_SemPost(first_run_semaphore);
- first_run_semaphore = NULL; /* let other thread clean it up. */
- }
-
- /* Block awhile before checking again, unless we're told to stop. */
- ticks = SDL_GetTicks() + 5000;
- while (!SDL_AtomicGet(&ALSA_hotplug_shutdown) && !SDL_TICKS_PASSED(SDL_GetTicks(), ticks)) {
- SDL_Delay(100);
- }
- }
-
- /* Shutting down! Clean up any data we've gathered. */
- for (dev = devices; dev; dev = next) {
- /*printf("ALSA: at shutdown, removing %s device '%s'\n", dev->iscapture ? "capture" : "output", dev->name);*/
- next = dev->next;
- SDL_free(dev->name);
- SDL_free(dev);
- }
-
- return 0;
-}
-
-static void
-ALSA_DetectDevices(void)
-{
- /* Start the device detection thread here, wait for an initial iteration to complete. */
- SDL_sem *semaphore = SDL_CreateSemaphore(0);
- if (!semaphore) {
- return; /* oh well. */
- }
-
- SDL_AtomicSet(&ALSA_hotplug_shutdown, 0);
-
- ALSA_hotplug_thread = SDL_CreateThread(ALSA_HotplugThread, "SDLHotplugALSA", semaphore);
- if (ALSA_hotplug_thread) {
- SDL_SemWait(semaphore); /* wait for the first iteration to finish. */
- }
-
- SDL_DestroySemaphore(semaphore);
-}
-
-static void
-ALSA_Deinitialize(void)
-{
- if (ALSA_hotplug_thread != NULL) {
- SDL_AtomicSet(&ALSA_hotplug_shutdown, 1);
- SDL_WaitThread(ALSA_hotplug_thread, NULL);
- ALSA_hotplug_thread = NULL;
- }
-
- UnloadALSALibrary();
-}
-
-static int
-ALSA_Init(SDL_AudioDriverImpl * impl)
-{
- if (LoadALSALibrary() < 0) {
- return 0;
- }
-
- /* Set the function pointers */
- impl->DetectDevices = ALSA_DetectDevices;
- impl->OpenDevice = ALSA_OpenDevice;
- impl->WaitDevice = ALSA_WaitDevice;
- impl->GetDeviceBuf = ALSA_GetDeviceBuf;
- impl->PlayDevice = ALSA_PlayDevice;
- impl->CloseDevice = ALSA_CloseDevice;
- impl->Deinitialize = ALSA_Deinitialize;
- impl->CaptureFromDevice = ALSA_CaptureFromDevice;
- impl->FlushCapture = ALSA_FlushCapture;
-
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-
-AudioBootStrap ALSA_bootstrap = {
- "alsa", "ALSA PCM audio", ALSA_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_ALSA */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.h b/3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.h
deleted file mode 100644
index 3080aea2306..00000000000
--- a/3rdparty/SDL2/src/audio/alsa/SDL_alsa_audio.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_ALSA_audio_h
-#define _SDL_ALSA_audio_h
-
-#include <alsa/asoundlib.h>
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The audio device handle */
- snd_pcm_t *pcm_handle;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-};
-
-#endif /* _SDL_ALSA_audio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/android/SDL_androidaudio.c b/3rdparty/SDL2/src/audio/android/SDL_androidaudio.c
deleted file mode 100644
index 0e60fb0c6f2..00000000000
--- a/3rdparty/SDL2/src/audio/android/SDL_androidaudio.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_ANDROID
-
-/* Output audio to Android */
-
-#include "SDL_assert.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_androidaudio.h"
-
-#include "../../core/android/SDL_android.h"
-
-#include "opensl_io.h"
-
-#include <android/log.h>
-
-static SDL_AudioDevice* audioDevice = NULL;
-static SDL_AudioDevice* captureDevice = NULL;
-static OPENSL_STREAM *sl = NULL;
-
-static int
-ANDROIDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- SDL_AudioFormat test_format;
-
- SDL_assert((captureDevice == NULL) || !iscapture);
- SDL_assert((audioDevice == NULL) || iscapture);
-
- if (iscapture) {
- captureDevice = this;
- } else {
- audioDevice = this;
- }
-
- this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
-
- test_format = SDL_FirstAudioFormat(this->spec.format);
- while (test_format != 0) { /* no "UNKNOWN" constant */
-// if ((test_format == AUDIO_U8) || (test_format == AUDIO_S16LSB)) {
- if (test_format == AUDIO_S16MSB) {
- this->spec.format = test_format;
- break;
- }
- test_format = SDL_NextAudioFormat();
- }
-
- if (test_format == 0) {
- /* Didn't find a compatible format :( */
- return SDL_SetError("No compatible audio format!");
- }
-
- if (this->spec.channels > 1) {
- this->spec.channels = 2;
- } else {
- this->spec.channels = 1;
- }
-
- #if 0
- if (this->spec.freq < 8000) {
- this->spec.freq = 8000;
- }
- if (this->spec.freq > 48000) {
- this->spec.freq = 48000;
- }
- #endif
- /* TODO: pass in/return a (Java) device ID */
- //this->spec.samples = Android_JNI_OpenAudioDevice(iscapture, this->spec.freq, this->spec.format == AUDIO_U8 ? 0 : 1, this->spec.channels, this->spec.samples);
- if (!sl & !iscapture)
- {
- if (this->spec.size != 0)
- {
-// this->spec.samples = this->spec.size / this->spec.channels / 2;
- } else {
- this->spec.samples = 400;
- this->spec.size = this->spec.channels * this->spec.samples;
- }
- sl = android_OpenAudioDevice(this->spec.freq, this->spec.channels, this->spec.channels, this->spec.samples);
- __android_log_print(ANDROID_LOG_INFO, "SDL", "android_OpenAudioDevice: %x, freq=%d, channels=%d, %d samples", (int)sl, this->spec.freq, this->spec.channels, this->spec.samples);
- if (!sl) {
- /* Init failed? */
- return SDL_SetError("Java-side initialization failed!");
- }
- }
-
- SDL_CalculateAudioSpec(&this->spec);
-
- return 0;
-}
-
-static void
-ANDROIDAUDIO_PlayDevice(_THIS)
-{
- //Android_JNI_WriteAudioBuffer();
- android_AudioOut2(sl);
-}
-
-static Uint8 *
-ANDROIDAUDIO_GetDeviceBuf(_THIS)
-{
- //return Android_JNI_GetAudioBuffer();
- Uint8 *buf = android_GetDeviceBuffer(sl);
-// __android_log_print(ANDROID_LOG_INFO, "SDL", "GetDeviceBuf: %x", (int) buf);
- return buf;
-}
-
-static int
-ANDROIDAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- return Android_JNI_CaptureAudioBuffer(buffer, buflen);
-}
-
-static void
-ANDROIDAUDIO_FlushCapture(_THIS)
-{
- Android_JNI_FlushCapturedAudio();
-}
-
-static void
-ANDROIDAUDIO_CloseDevice(_THIS)
-{
- /* At this point SDL_CloseAudioDevice via close_audio_device took care of terminating the audio thread
- so it's safe to terminate the Java side buffer and AudioTrack
- */
- Android_JNI_CloseAudioDevice(this->iscapture);
- if (this->iscapture) {
- SDL_assert(captureDevice == this);
- captureDevice = NULL;
- } else {
- SDL_assert(audioDevice == this);
- audioDevice = NULL;
- }
- SDL_free(this->hidden);
-}
-
-static int
-ANDROIDAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->OpenDevice = ANDROIDAUDIO_OpenDevice;
- impl->PlayDevice = ANDROIDAUDIO_PlayDevice;
- impl->GetDeviceBuf = ANDROIDAUDIO_GetDeviceBuf;
- impl->CloseDevice = ANDROIDAUDIO_CloseDevice;
- impl->CaptureFromDevice = ANDROIDAUDIO_CaptureFromDevice;
- impl->FlushCapture = ANDROIDAUDIO_FlushCapture;
-
- /* and the capabilities */
- impl->HasCaptureSupport = SDL_FALSE;
- impl->OnlyHasDefaultOutputDevice = 1;
- impl->OnlyHasDefaultCaptureDevice = 0;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap ANDROIDAUDIO_bootstrap = {
- "android", "SDL Android audio driver", ANDROIDAUDIO_Init, 0
-};
-
-/* Pause (block) all non already paused audio devices by taking their mixer lock */
-void ANDROIDAUDIO_PauseDevices(void)
-{
- /* TODO: Handle multiple devices? */
- struct SDL_PrivateAudioData *private;
- if(audioDevice != NULL && audioDevice->hidden != NULL) {
- private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
- if (SDL_AtomicGet(&audioDevice->paused)) {
- /* The device is already paused, leave it alone */
- private->resume = SDL_FALSE;
- }
- else {
- SDL_LockMutex(audioDevice->mixer_lock);
- SDL_AtomicSet(&audioDevice->paused, 1);
- private->resume = SDL_TRUE;
- }
- }
-
- if(captureDevice != NULL && captureDevice->hidden != NULL) {
- private = (struct SDL_PrivateAudioData *) captureDevice->hidden;
- if (SDL_AtomicGet(&captureDevice->paused)) {
- /* The device is already paused, leave it alone */
- private->resume = SDL_FALSE;
- }
- else {
- SDL_LockMutex(captureDevice->mixer_lock);
- SDL_AtomicSet(&captureDevice->paused, 1);
- private->resume = SDL_TRUE;
- }
- }
-}
-
-/* Resume (unblock) all non already paused audio devices by releasing their mixer lock */
-void ANDROIDAUDIO_ResumeDevices(void)
-{
- /* TODO: Handle multiple devices? */
- struct SDL_PrivateAudioData *private;
- if(audioDevice != NULL && audioDevice->hidden != NULL) {
- private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
- if (private->resume) {
- SDL_AtomicSet(&audioDevice->paused, 0);
- private->resume = SDL_FALSE;
- SDL_UnlockMutex(audioDevice->mixer_lock);
- }
- }
-
- if(captureDevice != NULL && captureDevice->hidden != NULL) {
- private = (struct SDL_PrivateAudioData *) captureDevice->hidden;
- if (private->resume) {
- SDL_AtomicSet(&captureDevice->paused, 0);
- private->resume = SDL_FALSE;
- SDL_UnlockMutex(captureDevice->mixer_lock);
- }
- }
-}
-
-
-#endif /* SDL_AUDIO_DRIVER_ANDROID */
-
-/* vi: set ts=4 sw=4 expandtab: */
-
diff --git a/3rdparty/SDL2/src/audio/android/SDL_androidaudio.h b/3rdparty/SDL2/src/audio/android/SDL_androidaudio.h
deleted file mode 100644
index 1336153020b..00000000000
--- a/3rdparty/SDL2/src/audio/android/SDL_androidaudio.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_androidaudio_h
-#define _SDL_androidaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* Resume device if it was paused automatically */
- int resume;
-};
-
-#endif /* _SDL_androidaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/android/opensl_io.c b/3rdparty/SDL2/src/audio/android/opensl_io.c
deleted file mode 100644
index aec6994d55d..00000000000
--- a/3rdparty/SDL2/src/audio/android/opensl_io.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
-opensl_io.c:
-Android OpenSL input/output module
-Copyright (c) 2012, Victor Lazzarini
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the <organization> nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <limits.h>
-#include <string.h>
-#include "opensl_io.h"
-#define CONV16BIT 32768
-#define CONVMYFLT (1./32768.)
-
-#include <android/log.h>
-#define LOG_TAG "SDL_android"
-
-static void* createThreadLock(void);
-static int waitThreadLock(void *lock);
-static void notifyThreadLock(void *lock);
-static void destroyThreadLock(void *lock);
-static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context);
-static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context);
-
-// creates the OpenSL ES audio engine
-static SLresult openSLCreateEngine(OPENSL_STREAM *p)
-{
- SLresult result;
- // create engine
- result = slCreateEngine(&(p->engineObject), 0, NULL, 0, NULL, NULL);
- if(result != SL_RESULT_SUCCESS) goto engine_end;
-
- // realize the engine
- result = (*p->engineObject)->Realize(p->engineObject, SL_BOOLEAN_FALSE);
- if(result != SL_RESULT_SUCCESS) goto engine_end;
-
- // get the engine interface, which is needed in order to create other objects
- result = (*p->engineObject)->GetInterface(p->engineObject, SL_IID_ENGINE, &(p->engineEngine));
- if(result != SL_RESULT_SUCCESS) goto engine_end;
-
- engine_end:
- return result;
-}
-
-// opens the OpenSL ES device for output
-static SLresult openSLPlayOpen(OPENSL_STREAM *p)
-{
- SLresult result;
- SLuint32 sr = p->sr;
- SLuint32 channels = p->outchannels;
-
- if(channels){
- // configure audio source
- SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
-
- switch(sr){
-
- case 8000:
- sr = SL_SAMPLINGRATE_8;
- break;
- case 11025:
- sr = SL_SAMPLINGRATE_11_025;
- break;
- case 16000:
- sr = SL_SAMPLINGRATE_16;
- break;
- case 22050:
- sr = SL_SAMPLINGRATE_22_05;
- break;
- case 24000:
- sr = SL_SAMPLINGRATE_24;
- break;
- case 32000:
- sr = SL_SAMPLINGRATE_32;
- break;
- case 44100:
- sr = SL_SAMPLINGRATE_44_1;
- break;
- case 48000:
- sr = SL_SAMPLINGRATE_48;
- break;
- case 64000:
- sr = SL_SAMPLINGRATE_64;
- break;
- case 88200:
- sr = SL_SAMPLINGRATE_88_2;
- break;
- case 96000:
- sr = SL_SAMPLINGRATE_96;
- break;
- case 192000:
- sr = SL_SAMPLINGRATE_192;
- break;
- default:
- return -1;
- }
-
- const SLInterfaceID ids[] = {SL_IID_VOLUME};
- const SLboolean req[] = {SL_BOOLEAN_FALSE};
- result = (*p->engineEngine)->CreateOutputMix(p->engineEngine, &(p->outputMixObject), 1, ids, req);
- if(result != SL_RESULT_SUCCESS) goto end_openaudio;
-
- // realize the output mix
- result = (*p->outputMixObject)->Realize(p->outputMixObject, SL_BOOLEAN_FALSE);
-
- int speakers;
- if(channels > 1)
- speakers = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- else speakers = SL_SPEAKER_FRONT_CENTER;
- SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM,channels, sr,
- SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
- speakers, SL_BYTEORDER_LITTLEENDIAN};
-
- SLDataSource audioSrc = {&loc_bufq, &format_pcm};
-
- // configure audio sink
- SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, p->outputMixObject};
- SLDataSink audioSnk = {&loc_outmix, NULL};
-
- // create audio player
- const SLInterfaceID ids1[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
- const SLboolean req1[] = {SL_BOOLEAN_TRUE};
- result = (*p->engineEngine)->CreateAudioPlayer(p->engineEngine, &(p->bqPlayerObject), &audioSrc, &audioSnk,
- 1, ids1, req1);
- if(result != SL_RESULT_SUCCESS) goto end_openaudio;
-
- // realize the player
- result = (*p->bqPlayerObject)->Realize(p->bqPlayerObject, SL_BOOLEAN_FALSE);
- if(result != SL_RESULT_SUCCESS) goto end_openaudio;
-
- // get the play interface
- result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_PLAY, &(p->bqPlayerPlay));
- if(result != SL_RESULT_SUCCESS) goto end_openaudio;
-
- // get the buffer queue interface
- result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- &(p->bqPlayerBufferQueue));
- if(result != SL_RESULT_SUCCESS) goto end_openaudio;
-
- // register callback on the buffer queue
- result = (*p->bqPlayerBufferQueue)->RegisterCallback(p->bqPlayerBufferQueue, bqPlayerCallback, p);
- if(result != SL_RESULT_SUCCESS) goto end_openaudio;
-
- // set the player's state to playing
- result = (*p->bqPlayerPlay)->SetPlayState(p->bqPlayerPlay, SL_PLAYSTATE_PLAYING);
-
- end_openaudio:
- return result;
- }
- return SL_RESULT_SUCCESS;
-}
-
-// Open the OpenSL ES device for input
-static SLresult openSLRecOpen(OPENSL_STREAM *p){
-
- SLresult result;
- SLuint32 sr = p->sr;
- SLuint32 channels = p->inchannels;
-
- if(channels){
-
- switch(sr){
-
- case 8000:
- sr = SL_SAMPLINGRATE_8;
- break;
- case 11025:
- sr = SL_SAMPLINGRATE_11_025;
- break;
- case 16000:
- sr = SL_SAMPLINGRATE_16;
- break;
- case 22050:
- sr = SL_SAMPLINGRATE_22_05;
- break;
- case 24000:
- sr = SL_SAMPLINGRATE_24;
- break;
- case 32000:
- sr = SL_SAMPLINGRATE_32;
- break;
- case 44100:
- sr = SL_SAMPLINGRATE_44_1;
- break;
- case 48000:
- sr = SL_SAMPLINGRATE_48;
- break;
- case 64000:
- sr = SL_SAMPLINGRATE_64;
- break;
- case 88200:
- sr = SL_SAMPLINGRATE_88_2;
- break;
- case 96000:
- sr = SL_SAMPLINGRATE_96;
- break;
- case 192000:
- sr = SL_SAMPLINGRATE_192;
- break;
- default:
- return -1;
- }
-
- // configure audio source
- SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT,
- SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};
- SLDataSource audioSrc = {&loc_dev, NULL};
-
- // configure audio sink
- int speakers;
- if(channels > 1)
- speakers = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- else speakers = SL_SPEAKER_FRONT_CENTER;
- SLDataLocator_AndroidSimpleBufferQueue loc_bq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
- SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, channels, sr,
- SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
- speakers, SL_BYTEORDER_LITTLEENDIAN};
- SLDataSink audioSnk = {&loc_bq, &format_pcm};
-
- // create audio recorder
- // (requires the RECORD_AUDIO permission)
- const SLInterfaceID id[1] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
- const SLboolean req[1] = {SL_BOOLEAN_TRUE};
- result = (*p->engineEngine)->CreateAudioRecorder(p->engineEngine, &(p->recorderObject), &audioSrc,
- &audioSnk, 1, id, req);
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
-
- // realize the audio recorder
- result = (*p->recorderObject)->Realize(p->recorderObject, SL_BOOLEAN_FALSE);
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
-
- // get the record interface
- result = (*p->recorderObject)->GetInterface(p->recorderObject, SL_IID_RECORD, &(p->recorderRecord));
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
-
- // get the buffer queue interface
- result = (*p->recorderObject)->GetInterface(p->recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- &(p->recorderBufferQueue));
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
-
- // register callback on the buffer queue
- result = (*p->recorderBufferQueue)->RegisterCallback(p->recorderBufferQueue, bqRecorderCallback,
- p);
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
- result = (*p->recorderRecord)->SetRecordState(p->recorderRecord, SL_RECORDSTATE_RECORDING);
-
- end_recopen:
- return result;
- }
- else return SL_RESULT_SUCCESS;
-
-
-}
-
-// close the OpenSL IO and destroy the audio engine
-static void openSLDestroyEngine(OPENSL_STREAM *p){
-
- // destroy buffer queue audio player object, and invalidate all associated interfaces
- if (p->bqPlayerObject != NULL) {
- (*p->bqPlayerObject)->Destroy(p->bqPlayerObject);
- p->bqPlayerObject = NULL;
- p->bqPlayerPlay = NULL;
- p->bqPlayerBufferQueue = NULL;
- p->bqPlayerEffectSend = NULL;
- }
-
- // destroy audio recorder object, and invalidate all associated interfaces
- if (p->recorderObject != NULL) {
- (*p->recorderObject)->Destroy(p->recorderObject);
- p->recorderObject = NULL;
- p->recorderRecord = NULL;
- p->recorderBufferQueue = NULL;
- }
-
- // destroy output mix object, and invalidate all associated interfaces
- if (p->outputMixObject != NULL) {
- (*p->outputMixObject)->Destroy(p->outputMixObject);
- p->outputMixObject = NULL;
- }
-
- // destroy engine object, and invalidate all associated interfaces
- if (p->engineObject != NULL) {
- (*p->engineObject)->Destroy(p->engineObject);
- p->engineObject = NULL;
- p->engineEngine = NULL;
- }
-
-}
-
-
-// open the android audio device for input and/or output
-OPENSL_STREAM *android_OpenAudioDevice(int sr, int inchannels, int outchannels, int bufferframes){
-
- OPENSL_STREAM *p;
- p = (OPENSL_STREAM *) calloc(sizeof(OPENSL_STREAM),1);
-
- p->inchannels = inchannels;
- p->outchannels = outchannels;
- p->sr = sr;
- p->inlock = createThreadLock();
- p->outlock = createThreadLock();
-
- if((p->outBufSamples = bufferframes*outchannels) != 0) {
- if((p->outputBuffer[0] = (short *) calloc(p->outBufSamples, sizeof(short))) == NULL ||
- (p->outputBuffer[1] = (short *) calloc(p->outBufSamples, sizeof(short))) == NULL) {
- android_CloseAudioDevice(p);
- return NULL;
- }
- __android_log_print(ANDROID_LOG_INFO, "OPENSL", "android_OpenAudioDevice: outBufSamples(%d), %x, %x", p->outBufSamples, (int) p->outputBuffer[0], (int) p->outputBuffer[1]);
- }
-
- if((p->inBufSamples = bufferframes*inchannels) != 0){
- if((p->inputBuffer[0] = (short *) calloc(p->inBufSamples, sizeof(short))) == NULL ||
- (p->inputBuffer[1] = (short *) calloc(p->inBufSamples, sizeof(short))) == NULL){
- android_CloseAudioDevice(p);
- return NULL;
- }
- __android_log_print(ANDROID_LOG_INFO, "OPENSL", "android_OpenAudioDevice: inBufSamples(%d)", p->inBufSamples);
- }
-
- p->currentInputIndex = 0;
- p->currentOutputBuffer = 0;
- p->currentInputIndex = p->inBufSamples;
- p->currentInputBuffer = 0;
-
- if(openSLCreateEngine(p) != SL_RESULT_SUCCESS) {
- android_CloseAudioDevice(p);
- return NULL;
- }
-// __android_log_print(ANDROID_LOG_INFO, "OPENSL", "android_OpenAudioDevice: openSLCreateEngine");
-#if 1
- if(openSLRecOpen(p) != SL_RESULT_SUCCESS) {
-// android_CloseAudioDevice(p);
-// return NULL;
- }
-// __android_log_print(ANDROID_LOG_INFO, "OPENSL", "android_OpenAudioDevice: openSLRecOpen");
-#endif
- if(openSLPlayOpen(p) != SL_RESULT_SUCCESS) {
- android_CloseAudioDevice(p);
- return NULL;
- }
-// __android_log_print(ANDROID_LOG_INFO, "OPENSL", "android_OpenAudioDevice: openSLPlayOpen");
-
- notifyThreadLock(p->outlock);
- notifyThreadLock(p->inlock);
-
- p->time = 0.;
- return p;
-}
-
-// close the android audio device
-void android_CloseAudioDevice(OPENSL_STREAM *p){
-
- if (p == NULL)
- return;
-
- openSLDestroyEngine(p);
-
- if (p->inlock != NULL) {
- notifyThreadLock(p->inlock);
- destroyThreadLock(p->inlock);
- p->inlock = NULL;
- }
-
- if (p->outlock != NULL) {
- notifyThreadLock(p->outlock);
- destroyThreadLock(p->outlock);
- p->inlock = NULL;
- }
-
- if (p->outputBuffer[0] != NULL) {
- free(p->outputBuffer[0]);
- p->outputBuffer[0] = NULL;
- }
-
- if (p->outputBuffer[1] != NULL) {
- free(p->outputBuffer[1]);
- p->outputBuffer[1] = NULL;
- }
-
- if (p->inputBuffer[0] != NULL) {
- free(p->inputBuffer[0]);
- p->inputBuffer[0] = NULL;
- }
-
- if (p->inputBuffer[1] != NULL) {
- free(p->inputBuffer[1]);
- p->inputBuffer[1] = NULL;
- }
-
- free(p);
-}
-
-// returns timestamp of the processed stream
-double android_GetTimestamp(OPENSL_STREAM *p){
- return p->time;
-}
-
-
-// this callback handler is called every time a buffer finishes recording
-void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
-{
- OPENSL_STREAM *p = (OPENSL_STREAM *) context;
- notifyThreadLock(p->inlock);
-}
-
-// gets a buffer of size samples from the device
-int android_AudioIn(OPENSL_STREAM *p,float *buffer,int size){
- short *inBuffer;
- int i, bufsamps = p->inBufSamples, index = p->currentInputIndex;
- if(p == NULL || bufsamps == 0) return 0;
-
- inBuffer = p->inputBuffer[p->currentInputBuffer];
- for(i=0; i < size; i++){
- if (index >= bufsamps) {
- waitThreadLock(p->inlock);
- (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue,
- inBuffer,bufsamps*sizeof(short));
- p->currentInputBuffer = (p->currentInputBuffer ? 0 : 1);
- index = 0;
- inBuffer = p->inputBuffer[p->currentInputBuffer];
- }
- buffer[i] = (float) inBuffer[index++]*CONVMYFLT;
- }
- p->currentInputIndex = index;
- if(p->outchannels == 0) p->time += (double) size/(p->sr*p->inchannels);
- return i;
-}
-
-// this callback handler is called every time a buffer finishes playing
-void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
-{
- OPENSL_STREAM *p = (OPENSL_STREAM *) context;
- notifyThreadLock(p->outlock);
-}
-
-unsigned char *android_GetDeviceBuffer(OPENSL_STREAM *p)
-{
- p->currentOutputBuffer = (p->currentOutputBuffer ? 0 : 1);
- waitThreadLock(p->outlock);
-// __android_log_print(ANDROID_LOG_INFO, "OPENSL", "android_GetDeviceBuffer: buf[%d]=%x", p->currentOutputBuffer, (int) p->outputBuffer[p->currentOutputBuffer]);
- return (unsigned char *)p->outputBuffer[p->currentOutputBuffer];
-}
-
-void android_AudioOut2(OPENSL_STREAM *p)
-{
- short *outBuffer = p->outputBuffer[p->currentOutputBuffer];
- int bufsamps = p->outBufSamples;
- (*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue, outBuffer, bufsamps*sizeof(short));
-}
-// puts a buffer of size samples to the device
-int android_AudioOut(OPENSL_STREAM *p, float *buffer, int size){
-
- short *outBuffer;
- int i, bufsamps = p->outBufSamples, index = p->currentOutputIndex;
- if(p == NULL || bufsamps == 0) return 0;
- outBuffer = p->outputBuffer[p->currentOutputBuffer];
-
- for (i=0; i < size; i++) {
-
- // clean conversion from float to short int
- float x = buffer[i];
- if (x>1.0) { x=1.0; } else if (x<-1.0) { x=-1.0; };
- outBuffer[index++] = (short)( x * 32767.0 );
-
- if (index >= p->outBufSamples) {
- waitThreadLock(p->outlock);
- (*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue,
- outBuffer,bufsamps*sizeof(short));
- p->currentOutputBuffer = (p->currentOutputBuffer ? 0 : 1);
- index = 0;
- outBuffer = p->outputBuffer[p->currentOutputBuffer];
- }
- }
- p->currentOutputIndex = index;
- p->time += (double) size/(p->sr*p->outchannels);
- return i;
-}
-
-//----------------------------------------------------------------------
-// thread Locks
-// to ensure synchronisation between callbacks and processing code
-void* createThreadLock(void)
-{
- threadLock *p;
- p = (threadLock*) malloc(sizeof(threadLock));
- if (p == NULL)
- return NULL;
- memset(p, 0, sizeof(threadLock));
- if (pthread_mutex_init(&(p->m), (pthread_mutexattr_t*) NULL) != 0) {
- free((void*) p);
- return NULL;
- }
- if (pthread_cond_init(&(p->c), (pthread_condattr_t*) NULL) != 0) {
- pthread_mutex_destroy(&(p->m));
- free((void*) p);
- return NULL;
- }
- p->s = (unsigned char) 1;
-
- return p;
-}
-
-int waitThreadLock(void *lock)
-{
- threadLock *p;
- p = (threadLock*) lock;
- pthread_mutex_lock(&(p->m));
- while (!p->s) {
- pthread_cond_wait(&(p->c), &(p->m));
- }
- p->s = (unsigned char) 0;
- pthread_mutex_unlock(&(p->m));
- return 0;
-}
-
-void notifyThreadLock(void *lock)
-{
- threadLock *p;
- p = (threadLock*) lock;
- pthread_mutex_lock(&(p->m));
- p->s = (unsigned char) 1;
- pthread_cond_signal(&(p->c));
- pthread_mutex_unlock(&(p->m));
-}
-
-void destroyThreadLock(void *lock)
-{
- threadLock *p;
- p = (threadLock*) lock;
- if (p == NULL)
- return;
- notifyThreadLock(p);
- pthread_cond_destroy(&(p->c));
- pthread_mutex_destroy(&(p->m));
- free(p);
-} \ No newline at end of file
diff --git a/3rdparty/SDL2/src/audio/android/opensl_io.h b/3rdparty/SDL2/src/audio/android/opensl_io.h
deleted file mode 100644
index 5c04cd2fdd7..00000000000
--- a/3rdparty/SDL2/src/audio/android/opensl_io.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-opensl_io.c:
-Android OpenSL input/output module header
-Copyright (c) 2012, Victor Lazzarini
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the <organization> nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef OPENSL_IO
-#define OPENSL_IO
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-#include <pthread.h>
-#include <stdlib.h>
-
-typedef struct threadLock_{
- pthread_mutex_t m;
- pthread_cond_t c;
- unsigned char s;
-} threadLock;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct opensl_stream {
-
- // engine interfaces
- SLObjectItf engineObject;
- SLEngineItf engineEngine;
-
- // output mix interfaces
- SLObjectItf outputMixObject;
-
- // buffer queue player interfaces
- SLObjectItf bqPlayerObject;
- SLPlayItf bqPlayerPlay;
- SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
- SLEffectSendItf bqPlayerEffectSend;
-
- // recorder interfaces
- SLObjectItf recorderObject;
- SLRecordItf recorderRecord;
- SLAndroidSimpleBufferQueueItf recorderBufferQueue;
-
- // buffer indexes
- int currentInputIndex;
- int currentOutputIndex;
-
- // current buffer half (0, 1)
- int currentOutputBuffer;
- int currentInputBuffer;
-
- // buffers
- short *outputBuffer[2];
- short *inputBuffer[2];
-
- // size of buffers
- int outBufSamples;
- int inBufSamples;
-
- // locks
- void* inlock;
- void* outlock;
-
- double time;
- int inchannels;
- int outchannels;
- int sr;
-
-} OPENSL_STREAM;
-
- /*
- Open the audio device with a given sampling rate (sr), input and output channels and IO buffer size
- in frames. Returns a handle to the OpenSL stream
- */
- OPENSL_STREAM* android_OpenAudioDevice(int sr, int inchannels, int outchannels, int bufferframes);
- /*
- Close the audio device
- */
- void android_CloseAudioDevice(OPENSL_STREAM *p);
- /*
- Read a buffer from the OpenSL stream *p, of size samples. Returns the number of samples read.
- */
- int android_AudioIn(OPENSL_STREAM *p, float *buffer,int size);
- /*
- Write a buffer to the OpenSL stream *p, of size samples. Returns the number of samples written.
- */
- int android_AudioOut(OPENSL_STREAM *p, float *buffer,int size);
- /*
- Get the current IO block time in seconds
- */
- double android_GetTimestamp(OPENSL_STREAM *p);
- /*
- Android SDL interface for playing
- */
- void android_AudioOut2(OPENSL_STREAM *p);
- /*
- Android SDL interface for getBuffer
- */
- unsigned char *android_GetDeviceBuffer(OPENSL_STREAM *p);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif // #ifndef OPENSL_IO \ No newline at end of file
diff --git a/3rdparty/SDL2/src/audio/arts/SDL_artsaudio.c b/3rdparty/SDL2/src/audio/arts/SDL_artsaudio.c
deleted file mode 100644
index 6054e36b68f..00000000000
--- a/3rdparty/SDL2/src/audio/arts/SDL_artsaudio.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_ARTS
-
-/* Allow access to a raw mixing buffer */
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#include <unistd.h>
-#include <errno.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_artsaudio.h"
-
-#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
-#include "SDL_name.h"
-#include "SDL_loadso.h"
-#else
-#define SDL_NAME(X) X
-#endif
-
-#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
-
-static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC;
-static void *arts_handle = NULL;
-
-/* !!! FIXME: I hate this SDL_NAME clutter...it makes everything so messy! */
-static int (*SDL_NAME(arts_init)) (void);
-static void (*SDL_NAME(arts_free)) (void);
-static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits,
- int channels,
- const char *name);
-static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s,
- arts_parameter_t param, int value);
-static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
- arts_parameter_t param);
-static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer,
- int count);
-static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s);
-static int (*SDL_NAME(arts_suspend))(void);
-static int (*SDL_NAME(arts_suspended)) (void);
-static const char *(*SDL_NAME(arts_error_text)) (int errorcode);
-
-#define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
-static struct
-{
- const char *name;
- void **func;
-} arts_functions[] = {
-/* *INDENT-OFF* */
- SDL_ARTS_SYM(arts_init),
- SDL_ARTS_SYM(arts_free),
- SDL_ARTS_SYM(arts_play_stream),
- SDL_ARTS_SYM(arts_stream_set),
- SDL_ARTS_SYM(arts_stream_get),
- SDL_ARTS_SYM(arts_write),
- SDL_ARTS_SYM(arts_close_stream),
- SDL_ARTS_SYM(arts_suspend),
- SDL_ARTS_SYM(arts_suspended),
- SDL_ARTS_SYM(arts_error_text),
-/* *INDENT-ON* */
-};
-
-#undef SDL_ARTS_SYM
-
-static void
-UnloadARTSLibrary()
-{
- if (arts_handle != NULL) {
- SDL_UnloadObject(arts_handle);
- arts_handle = NULL;
- }
-}
-
-static int
-LoadARTSLibrary(void)
-{
- int i, retval = -1;
-
- if (arts_handle == NULL) {
- arts_handle = SDL_LoadObject(arts_library);
- if (arts_handle != NULL) {
- retval = 0;
- for (i = 0; i < SDL_arraysize(arts_functions); ++i) {
- *arts_functions[i].func =
- SDL_LoadFunction(arts_handle, arts_functions[i].name);
- if (!*arts_functions[i].func) {
- retval = -1;
- UnloadARTSLibrary();
- break;
- }
- }
- }
- }
-
- return retval;
-}
-
-#else
-
-static void
-UnloadARTSLibrary()
-{
- return;
-}
-
-static int
-LoadARTSLibrary(void)
-{
- return 0;
-}
-
-#endif /* SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-ARTS_WaitDevice(_THIS)
-{
- Sint32 ticks;
-
- /* Check to see if the thread-parent process is still alive */
- {
- static int cnt = 0;
- /* Note that this only works with thread implementations
- that use a different process id for each thread.
- */
- /* Check every 10 loops */
- if (this->hidden->parent && (((++cnt) % 10) == 0)) {
- if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
- }
- }
-
- /* Use timer for general audio synchronization */
- ticks =
- ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
- if (ticks > 0) {
- SDL_Delay(ticks);
- }
-}
-
-static void
-ARTS_PlayDevice(_THIS)
-{
- /* Write the audio data */
- int written = SDL_NAME(arts_write) (this->hidden->stream,
- this->hidden->mixbuf,
- this->hidden->mixlen);
-
- /* If timer synchronization is enabled, set the next write frame */
- if (this->hidden->frame_ticks) {
- this->hidden->next_frame += this->hidden->frame_ticks;
- }
-
- /* If we couldn't write, assume fatal error for now */
- if (written < 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", written);
-#endif
-}
-
-static Uint8 *
-ARTS_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-
-static void
-ARTS_CloseDevice(_THIS)
-{
- if (this->hidden->stream) {
- SDL_NAME(arts_close_stream) (this->hidden->stream);
- }
- SDL_NAME(arts_free) ();
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-ARTS_Suspend(void)
-{
- const Uint32 abortms = SDL_GetTicks() + 3000; /* give up after 3 secs */
- while ( (!SDL_NAME(arts_suspended)()) && !SDL_TICKS_PASSED(SDL_GetTicks(), abortms) ) {
- if ( SDL_NAME(arts_suspend)() ) {
- break;
- }
- }
- return SDL_NAME(arts_suspended)();
-}
-
-static int
-ARTS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- int rc = 0;
- int bits = 0, frag_spec = 0;
- SDL_AudioFormat test_format = 0, format = 0;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Try for a closest match on audio format */
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- !format && test_format;) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
-#endif
- switch (test_format) {
- case AUDIO_U8:
- bits = 8;
- format = 1;
- break;
- case AUDIO_S16LSB:
- bits = 16;
- format = 1;
- break;
- default:
- format = 0;
- break;
- }
- if (!format) {
- test_format = SDL_NextAudioFormat();
- }
- }
- if (format == 0) {
- return SDL_SetError("Couldn't find any hardware audio formats");
- }
- this->spec.format = test_format;
-
- if ((rc = SDL_NAME(arts_init) ()) != 0) {
- return SDL_SetError("Unable to initialize ARTS: %s",
- SDL_NAME(arts_error_text) (rc));
- }
-
- if (!ARTS_Suspend()) {
- return SDL_SetError("ARTS can not open audio device");
- }
-
- this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
- bits,
- this->spec.channels,
- "SDL");
-
- /* Play nothing so we have at least one write (server bug workaround). */
- SDL_NAME(arts_write) (this->hidden->stream, "", 0);
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Determine the power of two of the fragment size */
- for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec);
- if ((0x01 << frag_spec) != this->spec.size) {
- return SDL_SetError("Fragment size must be a power of two");
- }
- frag_spec |= 0x00020000; /* two fragments, for low latency */
-
-#ifdef ARTS_P_PACKET_SETTINGS
- SDL_NAME(arts_stream_set) (this->hidden->stream,
- ARTS_P_PACKET_SETTINGS, frag_spec);
-#else
- SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_SIZE,
- frag_spec & 0xffff);
- SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_COUNT,
- frag_spec >> 16);
-#endif
- this->spec.size = SDL_NAME(arts_stream_get) (this->hidden->stream,
- ARTS_P_PACKET_SIZE);
-
- /* Allocate mixing buffer */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
-
- /* Get the parent process id (we're the parent of the audio thread) */
- this->hidden->parent = getpid();
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-
-static void
-ARTS_Deinitialize(void)
-{
- UnloadARTSLibrary();
-}
-
-
-static int
-ARTS_Init(SDL_AudioDriverImpl * impl)
-{
- if (LoadARTSLibrary() < 0) {
- return 0;
- } else {
- if (SDL_NAME(arts_init) () != 0) {
- UnloadARTSLibrary();
- SDL_SetError("ARTS: arts_init failed (no audio server?)");
- return 0;
- }
-
- /* Play a stream so aRts doesn't crash */
- if (ARTS_Suspend()) {
- arts_stream_t stream;
- stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
- SDL_NAME(arts_write) (stream, "", 0);
- SDL_NAME(arts_close_stream) (stream);
- }
-
- SDL_NAME(arts_free) ();
- }
-
- /* Set the function pointers */
- impl->OpenDevice = ARTS_OpenDevice;
- impl->PlayDevice = ARTS_PlayDevice;
- impl->WaitDevice = ARTS_WaitDevice;
- impl->GetDeviceBuf = ARTS_GetDeviceBuf;
- impl->CloseDevice = ARTS_CloseDevice;
- impl->Deinitialize = ARTS_Deinitialize;
- impl->OnlyHasDefaultOutputDevice = 1;
-
- return 1; /* this audio target is available. */
-}
-
-
-AudioBootStrap ARTS_bootstrap = {
- "arts", "Analog RealTime Synthesizer", ARTS_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_ARTS */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/arts/SDL_artsaudio.h b/3rdparty/SDL2/src/audio/arts/SDL_artsaudio.h
deleted file mode 100644
index 6b9bf3037bf..00000000000
--- a/3rdparty/SDL2/src/audio/arts/SDL_artsaudio.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_artscaudio_h
-#define _SDL_artscaudio_h
-
-#include <artsc.h>
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The stream descriptor for the audio device */
- arts_stream_t stream;
-
- /* The parent process id, to detect when application quits */
- pid_t parent;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-
- /* Support for audio timing using a timer, in addition to select() */
- float frame_ticks;
- float next_frame;
-};
-#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */
-
-#endif /* _SDL_artscaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.c b/3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.c
deleted file mode 100644
index 6a970b9c70a..00000000000
--- a/3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_BSD
-
-/*
- * Driver for native OpenBSD/NetBSD audio(4).
- * vedge@vedge.com.ar.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/audioio.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_audiodev_c.h"
-#include "SDL_bsdaudio.h"
-
-/* Use timer for synchronization */
-/* #define USE_TIMER_SYNC */
-
-/* #define DEBUG_AUDIO */
-/* #define DEBUG_AUDIO_STREAM */
-
-
-static void
-BSDAUDIO_DetectDevices(void)
-{
- SDL_EnumUnixAudioDevices(0, NULL);
-}
-
-
-static void
-BSDAUDIO_Status(_THIS)
-{
-#ifdef DEBUG_AUDIO
- /* *INDENT-OFF* */
- audio_info_t info;
- const audio_prinfo *prinfo;
-
- if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) {
- fprintf(stderr, "AUDIO_GETINFO failed.\n");
- return;
- }
-
- prinfo = this->iscapture ? &info.play : &info.record;
-
- fprintf(stderr, "\n"
- "[%s info]\n"
- "buffer size : %d bytes\n"
- "sample rate : %i Hz\n"
- "channels : %i\n"
- "precision : %i-bit\n"
- "encoding : 0x%x\n"
- "seek : %i\n"
- "sample count : %i\n"
- "EOF count : %i\n"
- "paused : %s\n"
- "error occured : %s\n"
- "waiting : %s\n"
- "active : %s\n"
- "",
- this->iscapture ? "record" : "play",
- prinfo->buffer_size,
- prinfo->sample_rate,
- prinfo->channels,
- prinfo->precision,
- prinfo->encoding,
- prinfo->seek,
- prinfo->samples,
- prinfo->eof,
- prinfo->pause ? "yes" : "no",
- prinfo->error ? "yes" : "no",
- prinfo->waiting ? "yes" : "no",
- prinfo->active ? "yes" : "no");
-
- fprintf(stderr, "\n"
- "[audio info]\n"
- "monitor_gain : %i\n"
- "hw block size : %d bytes\n"
- "hi watermark : %i\n"
- "lo watermark : %i\n"
- "audio mode : %s\n"
- "",
- info.monitor_gain,
- info.blocksize,
- info.hiwat, info.lowat,
- (info.mode == AUMODE_PLAY) ? "PLAY"
- : (info.mode = AUMODE_RECORD) ? "RECORD"
- : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?"));
- /* *INDENT-ON* */
-#endif /* DEBUG_AUDIO */
-}
-
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-BSDAUDIO_WaitDevice(_THIS)
-{
-#ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */
- /* See if we need to use timed audio synchronization */
- if (this->hidden->frame_ticks) {
- /* Use timer for general audio synchronization */
- Sint32 ticks;
-
- ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
- if (ticks > 0) {
- SDL_Delay(ticks);
- }
- } else {
- /* Use select() for audio synchronization */
- fd_set fdset;
- struct timeval timeout;
-
- FD_ZERO(&fdset);
- FD_SET(this->hidden->audio_fd, &fdset);
- timeout.tv_sec = 10;
- timeout.tv_usec = 0;
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Waiting for audio to get ready\n");
-#endif
- if (select(this->hidden->audio_fd + 1, NULL, &fdset, NULL, &timeout)
- <= 0) {
- const char *message =
- "Audio timeout - buggy audio driver? (disabled)";
- /* In general we should never print to the screen,
- but in this case we have no other way of letting
- the user know what happened.
- */
- fprintf(stderr, "SDL: %s\n", message);
- SDL_OpenedAudioDeviceDisconnected(this);
- /* Don't try to close - may hang */
- this->hidden->audio_fd = -1;
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Done disabling audio\n");
-#endif
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Ready!\n");
-#endif
- }
-#endif /* !USE_BLOCKING_WRITES */
-}
-
-static void
-BSDAUDIO_PlayDevice(_THIS)
-{
- int written, p = 0;
-
- /* Write the audio data, checking for EAGAIN on broken audio drivers */
- do {
- written = write(this->hidden->audio_fd,
- &this->hidden->mixbuf[p], this->hidden->mixlen - p);
-
- if (written > 0)
- p += written;
- if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) {
- /* Non recoverable error has occurred. It should be reported!!! */
- perror("audio");
- break;
- }
-
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", written);
-#endif
-
- if (p < this->hidden->mixlen
- || ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) {
- SDL_Delay(1); /* Let a little CPU time go by */
- }
- } while (p < this->hidden->mixlen);
-
- /* If timer synchronization is enabled, set the next write frame */
- if (this->hidden->frame_ticks) {
- this->hidden->next_frame += this->hidden->frame_ticks;
- }
-
- /* If we couldn't write, assume fatal error for now */
- if (written < 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-}
-
-static Uint8 *
-BSDAUDIO_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-
-static int
-BSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
-{
- Uint8 *buffer = (Uint8 *) _buffer;
- int br, p = 0;
-
- /* Write the audio data, checking for EAGAIN on broken audio drivers */
- do {
- br = read(this->hidden->audio_fd, buffer + p, buflen - p);
- if (br > 0)
- p += br;
- if (br == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) {
- /* Non recoverable error has occurred. It should be reported!!! */
- perror("audio");
- return p ? p : -1;
- }
-
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Captured %d bytes of audio data\n", br);
-#endif
-
- if (p < buflen
- || ((br < 0) && ((errno == 0) || (errno == EAGAIN)))) {
- SDL_Delay(1); /* Let a little CPU time go by */
- }
- } while (p < buflen);
-}
-
-static void
-BSDAUDIO_FlushCapture(_THIS)
-{
- audio_info_t info;
- size_t remain;
- Uint8 buf[512];
-
- if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) {
- return; /* oh well. */
- }
-
- remain = (size_t) (info.record.samples * (SDL_AUDIO_BITSIZE(this->spec.format) / 8));
- while (remain > 0) {
- const size_t len = SDL_min(sizeof (buf), remain);
- const int br = read(this->hidden->audio_fd, buf, len);
- if (br <= 0) {
- return; /* oh well. */
- }
- remain -= br;
- }
-}
-
-static void
-BSDAUDIO_CloseDevice(_THIS)
-{
- if (this->hidden->audio_fd >= 0) {
- close(this->hidden->audio_fd);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-BSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
- SDL_AudioFormat format = 0;
- audio_info_t info;
- audio_prinfo *prinfo = iscapture ? &info.play : &info.record;
-
- /* We don't care what the devname is...we'll try to open anything. */
- /* ...but default to first name in the list... */
- if (devname == NULL) {
- devname = SDL_GetAudioDeviceName(0, iscapture);
- if (devname == NULL) {
- return SDL_SetError("No such audio device");
- }
- }
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Open the audio device */
- this->hidden->audio_fd = open(devname, flags, 0);
- if (this->hidden->audio_fd < 0) {
- return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
- }
-
- AUDIO_INITINFO(&info);
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Set to play mode */
- info.mode = iscapture ? AUMODE_RECORD : AUMODE_PLAY;
- if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) < 0) {
- return SDL_SetError("Couldn't put device into play mode");
- }
-
- AUDIO_INITINFO(&info);
- for (format = SDL_FirstAudioFormat(this->spec.format);
- format; format = SDL_NextAudioFormat()) {
- switch (format) {
- case AUDIO_U8:
- prinfo->encoding = AUDIO_ENCODING_ULINEAR;
- prinfo->precision = 8;
- break;
- case AUDIO_S8:
- prinfo->encoding = AUDIO_ENCODING_SLINEAR;
- prinfo->precision = 8;
- break;
- case AUDIO_S16LSB:
- prinfo->encoding = AUDIO_ENCODING_SLINEAR_LE;
- prinfo->precision = 16;
- break;
- case AUDIO_S16MSB:
- prinfo->encoding = AUDIO_ENCODING_SLINEAR_BE;
- prinfo->precision = 16;
- break;
- case AUDIO_U16LSB:
- prinfo->encoding = AUDIO_ENCODING_ULINEAR_LE;
- prinfo->precision = 16;
- break;
- case AUDIO_U16MSB:
- prinfo->encoding = AUDIO_ENCODING_ULINEAR_BE;
- prinfo->precision = 16;
- break;
- default:
- continue;
- }
-
- if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) == 0) {
- break;
- }
- }
-
- if (!format) {
- return SDL_SetError("No supported encoding for 0x%x", this->spec.format);
- }
-
- this->spec.format = format;
-
- AUDIO_INITINFO(&info);
- prinfo->channels = this->spec.channels;
- if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) == -1) {
- this->spec.channels = 1;
- }
- AUDIO_INITINFO(&info);
- prinfo->sample_rate = this->spec.freq;
- info.blocksize = this->spec.size;
- info.hiwat = 5;
- info.lowat = 3;
- (void) ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info);
- (void) ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info);
- this->spec.freq = prinfo->sample_rate;
-
- if (!iscapture) {
- /* Allocate mixing buffer */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
- }
-
- BSDAUDIO_Status(this);
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-static int
-BSDAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->DetectDevices = BSDAUDIO_DetectDevices;
- impl->OpenDevice = BSDAUDIO_OpenDevice;
- impl->PlayDevice = BSDAUDIO_PlayDevice;
- impl->WaitDevice = BSDAUDIO_WaitDevice;
- impl->GetDeviceBuf = BSDAUDIO_GetDeviceBuf;
- impl->CloseDevice = BSDAUDIO_CloseDevice;
- impl->CaptureFromDevice = BSDAUDIO_CaptureFromDevice;
- impl->FlushCapture = BSDAUDIO_FlushCapture;
-
- impl->HasCaptureSupport = SDL_TRUE;
- impl->AllowsArbitraryDeviceNames = 1;
-
- return 1; /* this audio target is available. */
-}
-
-
-AudioBootStrap BSD_AUDIO_bootstrap = {
- "bsd", "BSD audio", BSDAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_BSD */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.h b/3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.h
deleted file mode 100644
index 7fe141b14e0..00000000000
--- a/3rdparty/SDL2/src/audio/bsd/SDL_bsdaudio.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_bsdaudio_h
-#define _SDL_bsdaudio_h
-
-#include "../SDL_sysaudio.h"
-
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The file descriptor for the audio device */
- int audio_fd;
-
- /* The parent process id, to detect when application quits */
- pid_t parent;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-
- /* Support for audio timing using a timer, in addition to select() */
- float frame_ticks;
- float next_frame;
-};
-
-#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */
-
-#endif /* _SDL_bsdaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.h b/3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.h
deleted file mode 100644
index b7e5b8e2143..00000000000
--- a/3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_coreaudio_h
-#define _SDL_coreaudio_h
-
-#include "../SDL_sysaudio.h"
-
-#if !defined(__IPHONEOS__)
-#define MACOSX_COREAUDIO 1
-#endif
-
-#if MACOSX_COREAUDIO
-#include <CoreAudio/CoreAudio.h>
-#include <CoreServices/CoreServices.h>
-#else
-#import <AVFoundation/AVFoundation.h>
-#import <UIKit/UIApplication.h>
-#endif
-
-#include <AudioToolbox/AudioToolbox.h>
-#include <AudioUnit/AudioUnit.h>
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- SDL_Thread *thread;
- AudioQueueRef audioQueue;
- AudioQueueBufferRef audioBuffer[2];
- void *buffer;
- UInt32 bufferOffset;
- UInt32 bufferSize;
- AudioStreamBasicDescription strdesc;
- SDL_sem *ready_semaphore;
- char *thread_error;
- SDL_atomic_t shutdown;
-#if MACOSX_COREAUDIO
- AudioDeviceID deviceID;
-#else
- SDL_bool interrupted;
- CFTypeRef interruption_listener;
-#endif
-};
-
-#endif /* _SDL_coreaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.m b/3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.m
deleted file mode 100644
index 85129050fe2..00000000000
--- a/3rdparty/SDL2/src/audio/coreaudio/SDL_coreaudio.m
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_COREAUDIO
-
-/* !!! FIXME: clean out some of the macro salsa in here. */
-
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_coreaudio.h"
-#include "SDL_assert.h"
-#include "../../thread/SDL_systhread.h"
-
-#define DEBUG_COREAUDIO 0
-
-#define CHECK_RESULT(msg) \
- if (result != noErr) { \
- SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \
- return 0; \
- }
-
-#if MACOSX_COREAUDIO
-static const AudioObjectPropertyAddress devlist_address = {
- kAudioHardwarePropertyDevices,
- kAudioObjectPropertyScopeGlobal,
- kAudioObjectPropertyElementMaster
-};
-
-typedef void (*addDevFn)(const char *name, const int iscapture, AudioDeviceID devId, void *data);
-
-typedef struct AudioDeviceList
-{
- AudioDeviceID devid;
- SDL_bool alive;
- struct AudioDeviceList *next;
-} AudioDeviceList;
-
-static AudioDeviceList *output_devs = NULL;
-static AudioDeviceList *capture_devs = NULL;
-
-static SDL_bool
-add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
-{
- AudioDeviceList *item = (AudioDeviceList *) SDL_malloc(sizeof (AudioDeviceList));
- if (item == NULL) {
- return SDL_FALSE;
- }
- item->devid = devId;
- item->alive = SDL_TRUE;
- item->next = iscapture ? capture_devs : output_devs;
- if (iscapture) {
- capture_devs = item;
- } else {
- output_devs = item;
- }
-
- return SDL_TRUE;
-}
-
-static void
-addToDevList(const char *name, const int iscapture, AudioDeviceID devId, void *data)
-{
- if (add_to_internal_dev_list(iscapture, devId)) {
- SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId));
- }
-}
-
-static void
-build_device_list(int iscapture, addDevFn addfn, void *addfndata)
-{
- OSStatus result = noErr;
- UInt32 size = 0;
- AudioDeviceID *devs = NULL;
- UInt32 i = 0;
- UInt32 max = 0;
-
- result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
- &devlist_address, 0, NULL, &size);
- if (result != kAudioHardwareNoError)
- return;
-
- devs = (AudioDeviceID *) alloca(size);
- if (devs == NULL)
- return;
-
- result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
- &devlist_address, 0, NULL, &size, devs);
- if (result != kAudioHardwareNoError)
- return;
-
- max = size / sizeof (AudioDeviceID);
- for (i = 0; i < max; i++) {
- CFStringRef cfstr = NULL;
- char *ptr = NULL;
- AudioDeviceID dev = devs[i];
- AudioBufferList *buflist = NULL;
- int usable = 0;
- CFIndex len = 0;
- const AudioObjectPropertyAddress addr = {
- kAudioDevicePropertyStreamConfiguration,
- iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
- kAudioObjectPropertyElementMaster
- };
-
- const AudioObjectPropertyAddress nameaddr = {
- kAudioObjectPropertyName,
- iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
- kAudioObjectPropertyElementMaster
- };
-
- result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size);
- if (result != noErr)
- continue;
-
- buflist = (AudioBufferList *) SDL_malloc(size);
- if (buflist == NULL)
- continue;
-
- result = AudioObjectGetPropertyData(dev, &addr, 0, NULL,
- &size, buflist);
-
- if (result == noErr) {
- UInt32 j;
- for (j = 0; j < buflist->mNumberBuffers; j++) {
- if (buflist->mBuffers[j].mNumberChannels > 0) {
- usable = 1;
- break;
- }
- }
- }
-
- SDL_free(buflist);
-
- if (!usable)
- continue;
-
-
- size = sizeof (CFStringRef);
- result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr);
- if (result != kAudioHardwareNoError)
- continue;
-
- len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr),
- kCFStringEncodingUTF8);
-
- ptr = (char *) SDL_malloc(len + 1);
- usable = ((ptr != NULL) &&
- (CFStringGetCString
- (cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
-
- CFRelease(cfstr);
-
- if (usable) {
- len = strlen(ptr);
- /* Some devices have whitespace at the end...trim it. */
- while ((len > 0) && (ptr[len - 1] == ' ')) {
- len--;
- }
- usable = (len > 0);
- }
-
- if (usable) {
- ptr[len] = '\0';
-
-#if DEBUG_COREAUDIO
- printf("COREAUDIO: Found %s device #%d: '%s' (devid %d)\n",
- ((iscapture) ? "capture" : "output"),
- (int) i, ptr, (int) dev);
-#endif
- addfn(ptr, iscapture, dev, addfndata);
- }
- SDL_free(ptr); /* addfn() would have copied the string. */
- }
-}
-
-static void
-free_audio_device_list(AudioDeviceList **list)
-{
- AudioDeviceList *item = *list;
- while (item) {
- AudioDeviceList *next = item->next;
- SDL_free(item);
- item = next;
- }
- *list = NULL;
-}
-
-static void
-COREAUDIO_DetectDevices(void)
-{
- build_device_list(SDL_TRUE, addToDevList, NULL);
- build_device_list(SDL_FALSE, addToDevList, NULL);
-}
-
-static void
-build_device_change_list(const char *name, const int iscapture, AudioDeviceID devId, void *data)
-{
- AudioDeviceList **list = (AudioDeviceList **) data;
- AudioDeviceList *item;
- for (item = *list; item != NULL; item = item->next) {
- if (item->devid == devId) {
- item->alive = SDL_TRUE;
- return;
- }
- }
-
- add_to_internal_dev_list(iscapture, devId); /* new device, add it. */
- SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId));
-}
-
-static void
-reprocess_device_list(const int iscapture, AudioDeviceList **list)
-{
- AudioDeviceList *item;
- AudioDeviceList *prev = NULL;
- for (item = *list; item != NULL; item = item->next) {
- item->alive = SDL_FALSE;
- }
-
- build_device_list(iscapture, build_device_change_list, list);
-
- /* free items in the list that aren't still alive. */
- item = *list;
- while (item != NULL) {
- AudioDeviceList *next = item->next;
- if (item->alive) {
- prev = item;
- } else {
- SDL_RemoveAudioDevice(iscapture, (void *) ((size_t) item->devid));
- if (prev) {
- prev->next = item->next;
- } else {
- *list = item->next;
- }
- SDL_free(item);
- }
- item = next;
- }
-}
-
-/* this is called when the system's list of available audio devices changes. */
-static OSStatus
-device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
-{
- reprocess_device_list(SDL_TRUE, &capture_devs);
- reprocess_device_list(SDL_FALSE, &output_devs);
- return 0;
-}
-#endif
-
-
-static int open_playback_devices = 0;
-static int open_capture_devices = 0;
-
-#if !MACOSX_COREAUDIO
-
-static void interruption_begin(_THIS)
-{
- if (this != NULL && this->hidden->audioQueue != NULL) {
- this->hidden->interrupted = SDL_TRUE;
- AudioQueuePause(this->hidden->audioQueue);
- }
-}
-
-static void interruption_end(_THIS)
-{
- if (this != NULL && this->hidden != NULL && this->hidden->audioQueue != NULL
- && this->hidden->interrupted) {
- this->hidden->interrupted = SDL_FALSE;
- AudioQueueStart(this->hidden->audioQueue, NULL);
- }
-}
-
-@interface SDLInterruptionListener : NSObject
-
-@property (nonatomic, assign) SDL_AudioDevice *device;
-
-@end
-
-@implementation SDLInterruptionListener
-
-- (void)audioSessionInterruption:(NSNotification *)note
-{
- @synchronized (self) {
- NSNumber *type = note.userInfo[AVAudioSessionInterruptionTypeKey];
- if (type.unsignedIntegerValue == AVAudioSessionInterruptionTypeBegan) {
- interruption_begin(self.device);
- } else {
- interruption_end(self.device);
- }
- }
-}
-
-- (void)applicationBecameActive:(NSNotification *)note
-{
- @synchronized (self) {
- interruption_end(self.device);
- }
-}
-
-@end
-
-static BOOL update_audio_session(_THIS, SDL_bool open)
-{
- @autoreleasepool {
- AVAudioSession *session = [AVAudioSession sharedInstance];
- NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
- NSString *category;
- NSError *err = nil;
-
- if (open_playback_devices && open_capture_devices) {
- category = AVAudioSessionCategoryPlayAndRecord;
- } else if (open_capture_devices) {
- category = AVAudioSessionCategoryRecord;
- } else {
- /* Set category to ambient so that other music continues playing.
- You can change this at runtime in your own code if you need different
- behavior. If this is common, we can add an SDL hint for this. */
- category = AVAudioSessionCategoryAmbient;
- }
-
- if (![session setCategory:category error:&err]) {
- NSString *desc = err.description;
- SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
- return NO;
- }
-
- if (open_playback_devices + open_capture_devices == 1) {
- if (![session setActive:YES error:&err]) {
- NSString *desc = err.description;
- SDL_SetError("Could not activate Audio Session: %s", desc.UTF8String);
- return NO;
- }
- } else if (!open_playback_devices && !open_capture_devices) {
- [session setActive:NO error:nil];
- }
-
- if (open) {
- SDLInterruptionListener *listener = [SDLInterruptionListener new];
- listener.device = this;
-
- [center addObserver:listener
- selector:@selector(audioSessionInterruption:)
- name:AVAudioSessionInterruptionNotification
- object:session];
-
- /* An interruption end notification is not guaranteed to be sent if
- we were previously interrupted... resuming if needed when the app
- becomes active seems to be the way to go. */
- [center addObserver:listener
- selector:@selector(applicationBecameActive:)
- name:UIApplicationDidBecomeActiveNotification
- object:session];
-
- [center addObserver:listener
- selector:@selector(applicationBecameActive:)
- name:UIApplicationWillEnterForegroundNotification
- object:session];
-
- this->hidden->interruption_listener = CFBridgingRetain(listener);
- } else {
- if (this->hidden->interruption_listener != NULL) {
- SDLInterruptionListener *listener = nil;
- listener = (SDLInterruptionListener *) CFBridgingRelease(this->hidden->interruption_listener);
- @synchronized (listener) {
- listener.device = NULL;
- }
- [center removeObserver:listener];
- }
- }
- }
-
- return YES;
-}
-#endif
-
-
-/* The AudioQueue callback */
-static void
-outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) inUserData;
- if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
- /* Supply silence if audio is enabled and not paused */
- SDL_memset(inBuffer->mAudioData, this->spec.silence, inBuffer->mAudioDataBytesCapacity);
- } else {
- UInt32 remaining = inBuffer->mAudioDataBytesCapacity;
- Uint8 *ptr = (Uint8 *) inBuffer->mAudioData;
-
- while (remaining > 0) {
- UInt32 len;
- if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
- /* Generate the data */
- SDL_LockMutex(this->mixer_lock);
- (*this->spec.callback)(this->spec.userdata,
- this->hidden->buffer, this->hidden->bufferSize);
- SDL_UnlockMutex(this->mixer_lock);
- this->hidden->bufferOffset = 0;
- }
-
- len = this->hidden->bufferSize - this->hidden->bufferOffset;
- if (len > remaining) {
- len = remaining;
- }
- SDL_memcpy(ptr, (char *)this->hidden->buffer +
- this->hidden->bufferOffset, len);
- ptr = ptr + len;
- remaining -= len;
- this->hidden->bufferOffset += len;
- }
- }
-
- if (!SDL_AtomicGet(&this->hidden->shutdown)) {
- AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL);
- }
-
- inBuffer->mAudioDataByteSize = inBuffer->mAudioDataBytesCapacity;
-}
-
-static void
-inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer,
- const AudioTimeStamp *inStartTime, UInt32 inNumberPacketDescriptions,
- const AudioStreamPacketDescription *inPacketDescs )
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) inUserData;
- if (SDL_AtomicGet(&this->enabled) && !SDL_AtomicGet(&this->paused)) { /* ignore unless we're active. */
- const Uint8 *ptr = (const Uint8 *) inBuffer->mAudioData;
- UInt32 remaining = inBuffer->mAudioDataByteSize;
- while (remaining > 0) {
- UInt32 len = this->hidden->bufferSize - this->hidden->bufferOffset;
- if (len > remaining) {
- len = remaining;
- }
-
- SDL_memcpy((char *)this->hidden->buffer + this->hidden->bufferOffset, ptr, len);
- ptr += len;
- remaining -= len;
- this->hidden->bufferOffset += len;
-
- if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
- SDL_LockMutex(this->mixer_lock);
- (*this->spec.callback)(this->spec.userdata, this->hidden->buffer, this->hidden->bufferSize);
- SDL_UnlockMutex(this->mixer_lock);
- this->hidden->bufferOffset = 0;
- }
- }
- }
-
- if (!SDL_AtomicGet(&this->hidden->shutdown)) {
- AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL);
- }
-}
-
-
-#if MACOSX_COREAUDIO
-static const AudioObjectPropertyAddress alive_address =
-{
- kAudioDevicePropertyDeviceIsAlive,
- kAudioObjectPropertyScopeGlobal,
- kAudioObjectPropertyElementMaster
-};
-
-static OSStatus
-device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) data;
- SDL_bool dead = SDL_FALSE;
- UInt32 isAlive = 1;
- UInt32 size = sizeof (isAlive);
- OSStatus error;
-
- if (!SDL_AtomicGet(&this->enabled)) {
- return 0; /* already known to be dead. */
- }
-
- error = AudioObjectGetPropertyData(this->hidden->deviceID, &alive_address,
- 0, NULL, &size, &isAlive);
-
- if (error == kAudioHardwareBadDeviceError) {
- dead = SDL_TRUE; /* device was unplugged. */
- } else if ((error == kAudioHardwareNoError) && (!isAlive)) {
- dead = SDL_TRUE; /* device died in some other way. */
- }
-
- if (dead) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-
- return 0;
-}
-#endif
-
-static void
-COREAUDIO_CloseDevice(_THIS)
-{
- const SDL_bool iscapture = this->iscapture;
- int i;
-
-/* !!! FIXME: what does iOS do when a bluetooth audio device vanishes? Headphones unplugged? */
-/* !!! FIXME: (we only do a "default" device on iOS right now...can we do more?) */
-#if MACOSX_COREAUDIO
- /* Fire a callback if the device stops being "alive" (disconnected, etc). */
- AudioObjectRemovePropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this);
-#endif
-
-#if !MACOSX_COREAUDIO
- update_audio_session(this, SDL_FALSE);
-#endif
-
- if (this->hidden->thread) {
- SDL_AtomicSet(&this->hidden->shutdown, 1);
- SDL_WaitThread(this->hidden->thread, NULL);
- }
-
- if (this->hidden->audioQueue) {
- for (i = 0; i < SDL_arraysize(this->hidden->audioBuffer); i++) {
- if (this->hidden->audioBuffer[i]) {
- AudioQueueFreeBuffer(this->hidden->audioQueue, this->hidden->audioBuffer[i]);
- }
- }
- AudioQueueDispose(this->hidden->audioQueue, 1);
- }
-
- if (this->hidden->ready_semaphore) {
- SDL_DestroySemaphore(this->hidden->ready_semaphore);
- }
-
- SDL_free(this->hidden->thread_error);
- SDL_free(this->hidden->buffer);
- SDL_free(this->hidden);
-
- if (iscapture) {
- open_capture_devices--;
- } else {
- open_playback_devices--;
- }
-}
-
-#if MACOSX_COREAUDIO
-static int
-prepare_device(_THIS, void *handle, int iscapture)
-{
- AudioDeviceID devid = (AudioDeviceID) ((size_t) handle);
- OSStatus result = noErr;
- UInt32 size = 0;
- UInt32 alive = 0;
- pid_t pid = 0;
-
- AudioObjectPropertyAddress addr = {
- 0,
- kAudioObjectPropertyScopeGlobal,
- kAudioObjectPropertyElementMaster
- };
-
- if (handle == NULL) {
- size = sizeof (AudioDeviceID);
- addr.mSelector =
- ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
- kAudioHardwarePropertyDefaultOutputDevice);
- result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
- 0, NULL, &size, &devid);
- CHECK_RESULT("AudioHardwareGetProperty (default device)");
- }
-
- addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
- addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
- kAudioDevicePropertyScopeOutput;
-
- size = sizeof (alive);
- result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
- CHECK_RESULT
- ("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
-
- if (!alive) {
- SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
- return 0;
- }
-
- addr.mSelector = kAudioDevicePropertyHogMode;
- size = sizeof (pid);
- result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid);
-
- /* some devices don't support this property, so errors are fine here. */
- if ((result == noErr) && (pid != -1)) {
- SDL_SetError("CoreAudio: requested device is being hogged.");
- return 0;
- }
-
- this->hidden->deviceID = devid;
- return 1;
-}
-#endif
-
-static int
-prepare_audioqueue(_THIS)
-{
- const AudioStreamBasicDescription *strdesc = &this->hidden->strdesc;
- const int iscapture = this->iscapture;
- OSStatus result;
- int i;
-
- SDL_assert(CFRunLoopGetCurrent() != NULL);
-
- if (iscapture) {
- result = AudioQueueNewInput(strdesc, inputCallback, this, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 0, &this->hidden->audioQueue);
- CHECK_RESULT("AudioQueueNewInput");
- } else {
- result = AudioQueueNewOutput(strdesc, outputCallback, this, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 0, &this->hidden->audioQueue);
- CHECK_RESULT("AudioQueueNewOutput");
- }
-
-#if MACOSX_COREAUDIO
-{
- const AudioObjectPropertyAddress prop = {
- kAudioDevicePropertyDeviceUID,
- iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
- kAudioObjectPropertyElementMaster
- };
- CFStringRef devuid;
- UInt32 devuidsize = sizeof (devuid);
- result = AudioObjectGetPropertyData(this->hidden->deviceID, &prop, 0, NULL, &devuidsize, &devuid);
- CHECK_RESULT("AudioObjectGetPropertyData (kAudioDevicePropertyDeviceUID)");
- result = AudioQueueSetProperty(this->hidden->audioQueue, kAudioQueueProperty_CurrentDevice, &devuid, devuidsize);
- CHECK_RESULT("AudioQueueSetProperty (kAudioQueueProperty_CurrentDevice)");
-
- /* !!! FIXME: what does iOS do when a bluetooth audio device vanishes? Headphones unplugged? */
- /* !!! FIXME: (we only do a "default" device on iOS right now...can we do more?) */
- /* Fire a callback if the device stops being "alive" (disconnected, etc). */
- AudioObjectAddPropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this);
-}
-#endif
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate a sample buffer */
- this->hidden->bufferSize = this->spec.size;
- this->hidden->bufferOffset = iscapture ? 0 : this->hidden->bufferSize;
-
- this->hidden->buffer = SDL_malloc(this->hidden->bufferSize);
- if (this->hidden->buffer == NULL) {
- SDL_OutOfMemory();
- return 0;
- }
-
- for (i = 0; i < SDL_arraysize(this->hidden->audioBuffer); i++) {
- result = AudioQueueAllocateBuffer(this->hidden->audioQueue, this->spec.size, &this->hidden->audioBuffer[i]);
- CHECK_RESULT("AudioQueueAllocateBuffer");
- SDL_memset(this->hidden->audioBuffer[i]->mAudioData, this->spec.silence, this->hidden->audioBuffer[i]->mAudioDataBytesCapacity);
- this->hidden->audioBuffer[i]->mAudioDataByteSize = this->hidden->audioBuffer[i]->mAudioDataBytesCapacity;
- result = AudioQueueEnqueueBuffer(this->hidden->audioQueue, this->hidden->audioBuffer[i], 0, NULL);
- CHECK_RESULT("AudioQueueEnqueueBuffer");
- }
-
- result = AudioQueueStart(this->hidden->audioQueue, NULL);
- CHECK_RESULT("AudioQueueStart");
-
- /* We're running! */
- return 1;
-}
-
-static int
-audioqueue_thread(void *arg)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) arg;
- const int rc = prepare_audioqueue(this);
- if (!rc) {
- this->hidden->thread_error = SDL_strdup(SDL_GetError());
- SDL_SemPost(this->hidden->ready_semaphore);
- return 0;
- }
-
- /* init was successful, alert parent thread and start running... */
- SDL_SemPost(this->hidden->ready_semaphore);
- while (!SDL_AtomicGet(&this->hidden->shutdown)) {
- CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1);
- }
-
- if (this->iscapture) { /* just stop immediately for capture devices. */
- AudioQueueStop(this->hidden->audioQueue, 1);
- } else { /* Drain off any pending playback. */
- AudioQueueStop(this->hidden->audioQueue, 0);
- const CFTimeInterval secs = (((this->spec.size / (SDL_AUDIO_BITSIZE(this->spec.format) / 8)) / this->spec.channels) / ((CFTimeInterval) this->spec.freq)) * 2.0;
- CFRunLoopRunInMode(kCFRunLoopDefaultMode, secs, 0);
- }
-
- return 0;
-}
-
-static int
-COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- AudioStreamBasicDescription *strdesc;
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
- int valid_datatype = 0;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- strdesc = &this->hidden->strdesc;
-
- if (iscapture) {
- open_capture_devices++;
- } else {
- open_playback_devices++;
- }
-
-#if !MACOSX_COREAUDIO
- if (!update_audio_session(this, SDL_TRUE)) {
- return -1;
- }
-#endif
-
- /* Setup a AudioStreamBasicDescription with the requested format */
- SDL_zerop(strdesc);
- strdesc->mFormatID = kAudioFormatLinearPCM;
- strdesc->mFormatFlags = kLinearPCMFormatFlagIsPacked;
- strdesc->mChannelsPerFrame = this->spec.channels;
- strdesc->mSampleRate = this->spec.freq;
- strdesc->mFramesPerPacket = 1;
-
- while ((!valid_datatype) && (test_format)) {
- this->spec.format = test_format;
- /* Just a list of valid SDL formats, so people don't pass junk here. */
- switch (test_format) {
- case AUDIO_U8:
- case AUDIO_S8:
- case AUDIO_U16LSB:
- case AUDIO_S16LSB:
- case AUDIO_U16MSB:
- case AUDIO_S16MSB:
- case AUDIO_S32LSB:
- case AUDIO_S32MSB:
- case AUDIO_F32LSB:
- case AUDIO_F32MSB:
- valid_datatype = 1;
- strdesc->mBitsPerChannel = SDL_AUDIO_BITSIZE(this->spec.format);
- if (SDL_AUDIO_ISBIGENDIAN(this->spec.format))
- strdesc->mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
-
- if (SDL_AUDIO_ISFLOAT(this->spec.format))
- strdesc->mFormatFlags |= kLinearPCMFormatFlagIsFloat;
- else if (SDL_AUDIO_ISSIGNED(this->spec.format))
- strdesc->mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
- break;
- }
- }
-
- if (!valid_datatype) { /* shouldn't happen, but just in case... */
- return SDL_SetError("Unsupported audio format");
- }
-
- strdesc->mBytesPerFrame = strdesc->mBitsPerChannel * strdesc->mChannelsPerFrame / 8;
- strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket;
-
-#if MACOSX_COREAUDIO
- if (!prepare_device(this, handle, iscapture)) {
- return -1;
- }
-#endif
-
- /* This has to init in a new thread so it can get its own CFRunLoop. :/ */
- SDL_AtomicSet(&this->hidden->shutdown, 0);
- this->hidden->ready_semaphore = SDL_CreateSemaphore(0);
- if (!this->hidden->ready_semaphore) {
- return -1; /* oh well. */
- }
-
- this->hidden->thread = SDL_CreateThreadInternal(audioqueue_thread, "AudioQueue thread", 512 * 1024, this);
- if (!this->hidden->thread) {
- return -1;
- }
-
- SDL_SemWait(this->hidden->ready_semaphore);
- SDL_DestroySemaphore(this->hidden->ready_semaphore);
- this->hidden->ready_semaphore = NULL;
-
- if ((this->hidden->thread != NULL) && (this->hidden->thread_error != NULL)) {
- SDL_SetError("%s", this->hidden->thread_error);
- return -1;
- }
-
- return (this->hidden->thread != NULL) ? 0 : -1;
-}
-
-static void
-COREAUDIO_Deinitialize(void)
-{
-#if MACOSX_COREAUDIO
- AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
- free_audio_device_list(&capture_devs);
- free_audio_device_list(&output_devs);
-#endif
-}
-
-static int
-COREAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->OpenDevice = COREAUDIO_OpenDevice;
- impl->CloseDevice = COREAUDIO_CloseDevice;
- impl->Deinitialize = COREAUDIO_Deinitialize;
-
-#if MACOSX_COREAUDIO
- impl->DetectDevices = COREAUDIO_DetectDevices;
- AudioObjectAddPropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
-#else
- impl->OnlyHasDefaultOutputDevice = 1;
- impl->OnlyHasDefaultCaptureDevice = 1;
-#endif
-
- impl->ProvidesOwnCallbackThread = 1;
- impl->HasCaptureSupport = 1;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap COREAUDIO_bootstrap = {
- "coreaudio", "CoreAudio", COREAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_COREAUDIO */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/directsound/SDL_directsound.c b/3rdparty/SDL2/src/audio/directsound/SDL_directsound.c
deleted file mode 100644
index 5d261c92eba..00000000000
--- a/3rdparty/SDL2/src/audio/directsound/SDL_directsound.c
+++ /dev/null
@@ -1,605 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_DSOUND
-
-/* Allow access to a raw mixing buffer */
-
-#include "SDL_assert.h"
-#include "SDL_timer.h"
-#include "SDL_loadso.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_directsound.h"
-
-#ifndef WAVE_FORMAT_IEEE_FLOAT
-#define WAVE_FORMAT_IEEE_FLOAT 0x0003
-#endif
-
-/* DirectX function pointers for audio */
-static void* DSoundDLL = NULL;
-typedef HRESULT (WINAPI *fnDirectSoundCreate8)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN);
-typedef HRESULT (WINAPI *fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
-typedef HRESULT (WINAPI *fnDirectSoundCaptureCreate8)(LPCGUID,LPDIRECTSOUNDCAPTURE8 *,LPUNKNOWN);
-typedef HRESULT (WINAPI *fnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW,LPVOID);
-static fnDirectSoundCreate8 pDirectSoundCreate8 = NULL;
-static fnDirectSoundEnumerateW pDirectSoundEnumerateW = NULL;
-static fnDirectSoundCaptureCreate8 pDirectSoundCaptureCreate8 = NULL;
-static fnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL;
-
-static void
-DSOUND_Unload(void)
-{
- pDirectSoundCreate8 = NULL;
- pDirectSoundEnumerateW = NULL;
- pDirectSoundCaptureCreate8 = NULL;
- pDirectSoundCaptureEnumerateW = NULL;
-
- if (DSoundDLL != NULL) {
- SDL_UnloadObject(DSoundDLL);
- DSoundDLL = NULL;
- }
-}
-
-
-static int
-DSOUND_Load(void)
-{
- int loaded = 0;
-
- DSOUND_Unload();
-
- DSoundDLL = SDL_LoadObject("DSOUND.DLL");
- if (DSoundDLL == NULL) {
- SDL_SetError("DirectSound: failed to load DSOUND.DLL");
- } else {
- /* Now make sure we have DirectX 8 or better... */
- #define DSOUNDLOAD(f) { \
- p##f = (fn##f) SDL_LoadFunction(DSoundDLL, #f); \
- if (!p##f) loaded = 0; \
- }
- loaded = 1; /* will reset if necessary. */
- DSOUNDLOAD(DirectSoundCreate8);
- DSOUNDLOAD(DirectSoundEnumerateW);
- DSOUNDLOAD(DirectSoundCaptureCreate8);
- DSOUNDLOAD(DirectSoundCaptureEnumerateW);
- #undef DSOUNDLOAD
-
- if (!loaded) {
- SDL_SetError("DirectSound: System doesn't appear to have DX8.");
- }
- }
-
- if (!loaded) {
- DSOUND_Unload();
- }
-
- return loaded;
-}
-
-static int
-SetDSerror(const char *function, int code)
-{
- static const char *error;
- static char errbuf[1024];
-
- errbuf[0] = 0;
- switch (code) {
- case E_NOINTERFACE:
- error = "Unsupported interface -- Is DirectX 8.0 or later installed?";
- break;
- case DSERR_ALLOCATED:
- error = "Audio device in use";
- break;
- case DSERR_BADFORMAT:
- error = "Unsupported audio format";
- break;
- case DSERR_BUFFERLOST:
- error = "Mixing buffer was lost";
- break;
- case DSERR_CONTROLUNAVAIL:
- error = "Control requested is not available";
- break;
- case DSERR_INVALIDCALL:
- error = "Invalid call for the current state";
- break;
- case DSERR_INVALIDPARAM:
- error = "Invalid parameter";
- break;
- case DSERR_NODRIVER:
- error = "No audio device found";
- break;
- case DSERR_OUTOFMEMORY:
- error = "Out of memory";
- break;
- case DSERR_PRIOLEVELNEEDED:
- error = "Caller doesn't have priority";
- break;
- case DSERR_UNSUPPORTED:
- error = "Function not supported";
- break;
- default:
- SDL_snprintf(errbuf, SDL_arraysize(errbuf),
- "%s: Unknown DirectSound error: 0x%x", function, code);
- break;
- }
- if (!errbuf[0]) {
- SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
- error);
- }
- return SDL_SetError("%s", errbuf);
-}
-
-static void
-DSOUND_FreeDeviceHandle(void *handle)
-{
- SDL_free(handle);
-}
-
-static BOOL CALLBACK
-FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
-{
- const int iscapture = (int) ((size_t) data);
- if (guid != NULL) { /* skip default device */
- char *str = WIN_LookupAudioDeviceName(desc, guid);
- if (str != NULL) {
- LPGUID cpyguid = (LPGUID) SDL_malloc(sizeof (GUID));
- SDL_memcpy(cpyguid, guid, sizeof (GUID));
- SDL_AddAudioDevice(iscapture, str, cpyguid);
- SDL_free(str); /* addfn() makes a copy of this string. */
- }
- }
- return TRUE; /* keep enumerating. */
-}
-
-static void
-DSOUND_DetectDevices(void)
-{
- pDirectSoundCaptureEnumerateW(FindAllDevs, (void *) ((size_t) 1));
- pDirectSoundEnumerateW(FindAllDevs, (void *) ((size_t) 0));
-}
-
-
-static void
-DSOUND_WaitDevice(_THIS)
-{
- DWORD status = 0;
- DWORD cursor = 0;
- DWORD junk = 0;
- HRESULT result = DS_OK;
-
- /* Semi-busy wait, since we have no way of getting play notification
- on a primary mixing buffer located in hardware (DirectX 5.0)
- */
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- if (result != DS_OK) {
- if (result == DSERR_BUFFERLOST) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- }
-#ifdef DEBUG_SOUND
- SetDSerror("DirectSound GetCurrentPosition", result);
-#endif
- return;
- }
-
- while ((cursor / this->spec.size) == this->hidden->lastchunk) {
- /* FIXME: find out how much time is left and sleep that long */
- SDL_Delay(1);
-
- /* Try to restore a lost sound buffer */
- IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
- if ((status & DSBSTATUS_BUFFERLOST)) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
- if ((status & DSBSTATUS_BUFFERLOST)) {
- break;
- }
- }
- if (!(status & DSBSTATUS_PLAYING)) {
- result = IDirectSoundBuffer_Play(this->hidden->mixbuf, 0, 0,
- DSBPLAY_LOOPING);
- if (result == DS_OK) {
- continue;
- }
-#ifdef DEBUG_SOUND
- SetDSerror("DirectSound Play", result);
-#endif
- return;
- }
-
- /* Find out where we are playing */
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- if (result != DS_OK) {
- SetDSerror("DirectSound GetCurrentPosition", result);
- return;
- }
- }
-}
-
-static void
-DSOUND_PlayDevice(_THIS)
-{
- /* Unlock the buffer, allowing it to play */
- if (this->hidden->locked_buf) {
- IDirectSoundBuffer_Unlock(this->hidden->mixbuf,
- this->hidden->locked_buf,
- this->spec.size, NULL, 0);
- }
-}
-
-static Uint8 *
-DSOUND_GetDeviceBuf(_THIS)
-{
- DWORD cursor = 0;
- DWORD junk = 0;
- HRESULT result = DS_OK;
- DWORD rawlen = 0;
-
- /* Figure out which blocks to fill next */
- this->hidden->locked_buf = NULL;
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- if (result == DSERR_BUFFERLOST) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- }
- if (result != DS_OK) {
- SetDSerror("DirectSound GetCurrentPosition", result);
- return (NULL);
- }
- cursor /= this->spec.size;
-#ifdef DEBUG_SOUND
- /* Detect audio dropouts */
- {
- DWORD spot = cursor;
- if (spot < this->hidden->lastchunk) {
- spot += this->hidden->num_buffers;
- }
- if (spot > this->hidden->lastchunk + 1) {
- fprintf(stderr, "Audio dropout, missed %d fragments\n",
- (spot - (this->hidden->lastchunk + 1)));
- }
- }
-#endif
- this->hidden->lastchunk = cursor;
- cursor = (cursor + 1) % this->hidden->num_buffers;
- cursor *= this->spec.size;
-
- /* Lock the audio buffer */
- result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
- this->spec.size,
- (LPVOID *) & this->hidden->locked_buf,
- &rawlen, NULL, &junk, 0);
- if (result == DSERR_BUFFERLOST) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
- this->spec.size,
- (LPVOID *) & this->
- hidden->locked_buf, &rawlen, NULL,
- &junk, 0);
- }
- if (result != DS_OK) {
- SetDSerror("DirectSound Lock", result);
- return (NULL);
- }
- return (this->hidden->locked_buf);
-}
-
-static int
-DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- DWORD junk, cursor, ptr1len, ptr2len;
- VOID *ptr1, *ptr2;
-
- SDL_assert(buflen == this->spec.size);
-
- while (SDL_TRUE) {
- if (SDL_AtomicGet(&this->shutdown)) { /* in case the buffer froze... */
- SDL_memset(buffer, this->spec.silence, buflen);
- return buflen;
- }
-
- if (IDirectSoundCaptureBuffer_GetCurrentPosition(h->capturebuf, &junk, &cursor) != DS_OK) {
- return -1;
- }
- if ((cursor / this->spec.size) == h->lastchunk) {
- SDL_Delay(1); /* FIXME: find out how much time is left and sleep that long */
- } else {
- break;
- }
- }
-
- if (IDirectSoundCaptureBuffer_Lock(h->capturebuf, h->lastchunk * this->spec.size, this->spec.size, &ptr1, &ptr1len, &ptr2, &ptr2len, 0) != DS_OK) {
- return -1;
- }
-
- SDL_assert(ptr1len == this->spec.size);
- SDL_assert(ptr2 == NULL);
- SDL_assert(ptr2len == 0);
-
- SDL_memcpy(buffer, ptr1, ptr1len);
-
- if (IDirectSoundCaptureBuffer_Unlock(h->capturebuf, ptr1, ptr1len, ptr2, ptr2len) != DS_OK) {
- return -1;
- }
-
- h->lastchunk = (h->lastchunk + 1) % h->num_buffers;
-
- return ptr1len;
-}
-
-static void
-DSOUND_FlushCapture(_THIS)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- DWORD junk, cursor;
- if (IDirectSoundCaptureBuffer_GetCurrentPosition(h->capturebuf, &junk, &cursor) == DS_OK) {
- h->lastchunk = cursor / this->spec.size;
- }
-}
-
-static void
-DSOUND_CloseDevice(_THIS)
-{
- if (this->hidden->mixbuf != NULL) {
- IDirectSoundBuffer_Stop(this->hidden->mixbuf);
- IDirectSoundBuffer_Release(this->hidden->mixbuf);
- }
- if (this->hidden->sound != NULL) {
- IDirectSound_Release(this->hidden->sound);
- }
- if (this->hidden->capturebuf != NULL) {
- IDirectSoundCaptureBuffer_Stop(this->hidden->capturebuf);
- IDirectSoundCaptureBuffer_Release(this->hidden->capturebuf);
- }
- if (this->hidden->capture != NULL) {
- IDirectSoundCapture_Release(this->hidden->capture);
- }
- SDL_free(this->hidden);
-}
-
-/* This function tries to create a secondary audio buffer, and returns the
- number of audio chunks available in the created buffer. This is for
- playback devices, not capture.
-*/
-static int
-CreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
-{
- LPDIRECTSOUND sndObj = this->hidden->sound;
- LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf;
- HRESULT result = DS_OK;
- DSBUFFERDESC format;
- LPVOID pvAudioPtr1, pvAudioPtr2;
- DWORD dwAudioBytes1, dwAudioBytes2;
-
- /* Try to create the secondary buffer */
- SDL_zero(format);
- format.dwSize = sizeof(format);
- format.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
- format.dwFlags |= DSBCAPS_GLOBALFOCUS;
- format.dwBufferBytes = bufsize;
- format.lpwfxFormat = wfmt;
- result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL);
- if (result != DS_OK) {
- return SetDSerror("DirectSound CreateSoundBuffer", result);
- }
- IDirectSoundBuffer_SetFormat(*sndbuf, wfmt);
-
- /* Silence the initial audio buffer */
- result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes,
- (LPVOID *) & pvAudioPtr1, &dwAudioBytes1,
- (LPVOID *) & pvAudioPtr2, &dwAudioBytes2,
- DSBLOCK_ENTIREBUFFER);
- if (result == DS_OK) {
- SDL_memset(pvAudioPtr1, this->spec.silence, dwAudioBytes1);
- IDirectSoundBuffer_Unlock(*sndbuf,
- (LPVOID) pvAudioPtr1, dwAudioBytes1,
- (LPVOID) pvAudioPtr2, dwAudioBytes2);
- }
-
- /* We're ready to go */
- return 0;
-}
-
-/* This function tries to create a capture buffer, and returns the
- number of audio chunks available in the created buffer. This is for
- capture devices, not playback.
-*/
-static int
-CreateCaptureBuffer(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt)
-{
- LPDIRECTSOUNDCAPTURE capture = this->hidden->capture;
- LPDIRECTSOUNDCAPTUREBUFFER *capturebuf = &this->hidden->capturebuf;
- DSCBUFFERDESC format;
-// DWORD junk, cursor;
- HRESULT result;
-
- SDL_zero(format);
- format.dwSize = sizeof (format);
- format.dwFlags = DSCBCAPS_WAVEMAPPED;
- format.dwBufferBytes = bufsize;
- format.lpwfxFormat = wfmt;
-
- result = IDirectSoundCapture_CreateCaptureBuffer(capture, &format, capturebuf, NULL);
- if (result != DS_OK) {
- return SetDSerror("DirectSound CreateCaptureBuffer", result);
- }
-
- result = IDirectSoundCaptureBuffer_Start(*capturebuf, DSCBSTART_LOOPING);
- if (result != DS_OK) {
- IDirectSoundCaptureBuffer_Release(*capturebuf);
- return SetDSerror("DirectSound Start", result);
- }
-
-#if 0
- /* presumably this starts at zero, but just in case... */
- result = IDirectSoundCaptureBuffer_GetCurrentPosition(*capturebuf, &junk, &cursor);
- if (result != DS_OK) {
- IDirectSoundCaptureBuffer_Stop(*capturebuf);
- IDirectSoundCaptureBuffer_Release(*capturebuf);
- return SetDSerror("DirectSound GetCurrentPosition", result);
- }
-
- this->hidden->lastchunk = cursor / this->spec.size;
-#endif
-
- return 0;
-}
-
-static int
-DSOUND_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- const DWORD numchunks = 8;
- HRESULT result;
- SDL_bool valid_format = SDL_FALSE;
- SDL_bool tried_format = SDL_FALSE;
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
- LPGUID guid = (LPGUID) handle;
- DWORD bufsize;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Open the audio device */
- if (iscapture) {
- result = pDirectSoundCaptureCreate8(guid, &this->hidden->capture, NULL);
- if (result != DS_OK) {
- return SetDSerror("DirectSoundCaptureCreate8", result);
- }
- } else {
- result = pDirectSoundCreate8(guid, &this->hidden->sound, NULL);
- if (result != DS_OK) {
- return SetDSerror("DirectSoundCreate8", result);
- }
- result = IDirectSound_SetCooperativeLevel(this->hidden->sound,
- GetDesktopWindow(),
- DSSCL_NORMAL);
- if (result != DS_OK) {
- return SetDSerror("DirectSound SetCooperativeLevel", result);
- }
- }
-
- while ((!valid_format) && (test_format)) {
- switch (test_format) {
- case AUDIO_U8:
- case AUDIO_S16:
- case AUDIO_S32:
- case AUDIO_F32:
- tried_format = SDL_TRUE;
-
- this->spec.format = test_format;
-
- /* Update the fragment size as size in bytes */
- SDL_CalculateAudioSpec(&this->spec);
-
- bufsize = numchunks * this->spec.size;
- if ((bufsize < DSBSIZE_MIN) || (bufsize > DSBSIZE_MAX)) {
- SDL_SetError("Sound buffer size must be between %d and %d",
- (DSBSIZE_MIN < numchunks) ? 1 : DSBSIZE_MIN / numchunks,
- DSBSIZE_MAX / numchunks);
- } else {
- int rc;
- WAVEFORMATEX wfmt;
- SDL_zero(wfmt);
- if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
- wfmt.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- wfmt.wFormatTag = WAVE_FORMAT_PCM;
- }
-
- wfmt.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
- wfmt.nChannels = this->spec.channels;
- wfmt.nSamplesPerSec = this->spec.freq;
- wfmt.nBlockAlign = wfmt.nChannels * (wfmt.wBitsPerSample / 8);
- wfmt.nAvgBytesPerSec = wfmt.nSamplesPerSec * wfmt.nBlockAlign;
-
- rc = iscapture ? CreateCaptureBuffer(this, bufsize, &wfmt) : CreateSecondary(this, bufsize, &wfmt);
- if (rc == 0) {
- this->hidden->num_buffers = numchunks;
- valid_format = SDL_TRUE;
- }
- }
- break;
- }
- test_format = SDL_NextAudioFormat();
- }
-
- if (!valid_format) {
- if (tried_format) {
- return -1; /* CreateSecondary() should have called SDL_SetError(). */
- }
- return SDL_SetError("DirectSound: Unsupported audio format");
- }
-
- /* Playback buffers will auto-start playing in DSOUND_WaitDevice() */
-
- return 0; /* good to go. */
-}
-
-
-static void
-DSOUND_Deinitialize(void)
-{
- DSOUND_Unload();
-}
-
-
-static int
-DSOUND_Init(SDL_AudioDriverImpl * impl)
-{
- if (!DSOUND_Load()) {
- return 0;
- }
-
- /* Set the function pointers */
- impl->DetectDevices = DSOUND_DetectDevices;
- impl->OpenDevice = DSOUND_OpenDevice;
- impl->PlayDevice = DSOUND_PlayDevice;
- impl->WaitDevice = DSOUND_WaitDevice;
- impl->GetDeviceBuf = DSOUND_GetDeviceBuf;
- impl->CaptureFromDevice = DSOUND_CaptureFromDevice;
- impl->FlushCapture = DSOUND_FlushCapture;
- impl->CloseDevice = DSOUND_CloseDevice;
- impl->FreeDeviceHandle = DSOUND_FreeDeviceHandle;
- impl->Deinitialize = DSOUND_Deinitialize;
-
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap DSOUND_bootstrap = {
- "directsound", "DirectSound", DSOUND_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_DSOUND */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/directsound/SDL_directsound.h b/3rdparty/SDL2/src/audio/directsound/SDL_directsound.h
deleted file mode 100644
index d646c303f55..00000000000
--- a/3rdparty/SDL2/src/audio/directsound/SDL_directsound.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_directsound_h
-#define _SDL_directsound_h
-
-#include "../../core/windows/SDL_directx.h"
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-/* The DirectSound objects */
-struct SDL_PrivateAudioData
-{
- LPDIRECTSOUND sound;
- LPDIRECTSOUNDBUFFER mixbuf;
- LPDIRECTSOUNDCAPTURE capture;
- LPDIRECTSOUNDCAPTUREBUFFER capturebuf;
- int num_buffers;
- DWORD lastchunk;
- Uint8 *locked_buf;
-};
-
-#endif /* _SDL_directsound_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/disk/SDL_diskaudio.c b/3rdparty/SDL2/src/audio/disk/SDL_diskaudio.c
deleted file mode 100644
index ee5368844e7..00000000000
--- a/3rdparty/SDL2/src/audio/disk/SDL_diskaudio.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_DISK
-
-/* Output raw audio data to a file. */
-
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-
-#include "SDL_rwops.h"
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_diskaudio.h"
-
-/* !!! FIXME: these should be SDL hints, not environment variables. */
-/* environment variables and defaults. */
-#define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE"
-#define DISKDEFAULT_OUTFILE "sdlaudio.raw"
-#define DISKENVR_INFILE "SDL_DISKAUDIOFILEIN"
-#define DISKDEFAULT_INFILE "sdlaudio-in.raw"
-#define DISKENVR_IODELAY "SDL_DISKAUDIODELAY"
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-DISKAUDIO_WaitDevice(_THIS)
-{
- SDL_Delay(this->hidden->io_delay);
-}
-
-static void
-DISKAUDIO_PlayDevice(_THIS)
-{
- const size_t written = SDL_RWwrite(this->hidden->io,
- this->hidden->mixbuf,
- 1, this->spec.size);
-
- /* If we couldn't write, assume fatal error for now */
- if (written != this->spec.size) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", written);
-#endif
-}
-
-static Uint8 *
-DISKAUDIO_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-static int
-DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- const int origbuflen = buflen;
-
- SDL_Delay(h->io_delay);
-
- if (h->io) {
- const size_t br = SDL_RWread(h->io, buffer, 1, buflen);
- buflen -= (int) br;
- buffer = ((Uint8 *) buffer) + br;
- if (buflen > 0) { /* EOF (or error, but whatever). */
- SDL_RWclose(h->io);
- h->io = NULL;
- }
- }
-
- /* if we ran out of file, just write silence. */
- SDL_memset(buffer, this->spec.silence, buflen);
-
- return origbuflen;
-}
-
-static void
-DISKAUDIO_FlushCapture(_THIS)
-{
- /* no op...we don't advance the file pointer or anything. */
-}
-
-
-static void
-DISKAUDIO_CloseDevice(_THIS)
-{
- if (this->hidden->io != NULL) {
- SDL_RWclose(this->hidden->io);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-
-static const char *
-get_filename(const int iscapture, const char *devname)
-{
- if (devname == NULL) {
- devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE);
- if (devname == NULL) {
- devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE;
- }
- }
- return devname;
-}
-
-static int
-DISKAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- /* handle != NULL means "user specified the placeholder name on the fake detected device list" */
- const char *fname = get_filename(iscapture, handle ? NULL : devname);
- const char *envr = SDL_getenv(DISKENVR_IODELAY);
-
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc(sizeof(*this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- if (envr != NULL) {
- this->hidden->io_delay = SDL_atoi(envr);
- } else {
- this->hidden->io_delay = ((this->spec.samples * 1000) / this->spec.freq);
- }
-
- /* Open the audio device */
- this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb");
- if (this->hidden->io == NULL) {
- return -1;
- }
-
- /* Allocate mixing buffer */
- if (!iscapture) {
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
- }
-
-#if HAVE_STDIO_H
- fprintf(stderr,
- "WARNING: You are using the SDL disk i/o audio driver!\n"
- " %s file [%s].\n", iscapture ? "Reading from" : "Writing to",
- fname);
-#endif
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-static void
-DISKAUDIO_DetectDevices(void)
-{
- SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, (void *) 0x1);
- SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, (void *) 0x2);
-}
-
-static int
-DISKAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->OpenDevice = DISKAUDIO_OpenDevice;
- impl->WaitDevice = DISKAUDIO_WaitDevice;
- impl->PlayDevice = DISKAUDIO_PlayDevice;
- impl->GetDeviceBuf = DISKAUDIO_GetDeviceBuf;
- impl->CaptureFromDevice = DISKAUDIO_CaptureFromDevice;
- impl->FlushCapture = DISKAUDIO_FlushCapture;
-
- impl->CloseDevice = DISKAUDIO_CloseDevice;
- impl->DetectDevices = DISKAUDIO_DetectDevices;
-
- impl->AllowsArbitraryDeviceNames = 1;
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap DISKAUDIO_bootstrap = {
- "disk", "direct-to-disk audio", DISKAUDIO_Init, 1
-};
-
-#endif /* SDL_AUDIO_DRIVER_DISK */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/disk/SDL_diskaudio.h b/3rdparty/SDL2/src/audio/disk/SDL_diskaudio.h
deleted file mode 100644
index ad152a9ceb1..00000000000
--- a/3rdparty/SDL2/src/audio/disk/SDL_diskaudio.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_diskaudio_h
-#define _SDL_diskaudio_h
-
-#include "SDL_rwops.h"
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The file descriptor for the audio device */
- SDL_RWops *io;
- Uint32 io_delay;
- Uint8 *mixbuf;
-};
-
-#endif /* _SDL_diskaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.c b/3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.c
deleted file mode 100644
index a5a31b3aa88..00000000000
--- a/3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_OSS
-
-/* Allow access to a raw mixing buffer */
-
-#include <stdio.h> /* For perror() */
-#include <string.h> /* For strerror() */
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-
-#if SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
-/* This is installed on some systems */
-#include <soundcard.h>
-#else
-/* This is recommended by OSS */
-#include <sys/soundcard.h>
-#endif
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_audiodev_c.h"
-#include "SDL_dspaudio.h"
-
-
-static void
-DSP_DetectDevices(void)
-{
- SDL_EnumUnixAudioDevices(0, NULL);
-}
-
-
-static void
-DSP_CloseDevice(_THIS)
-{
- if (this->hidden->audio_fd >= 0) {
- close(this->hidden->audio_fd);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-
-static int
-DSP_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
- int format;
- int value;
- int frag_spec;
- SDL_AudioFormat test_format;
-
- /* We don't care what the devname is...we'll try to open anything. */
- /* ...but default to first name in the list... */
- if (devname == NULL) {
- devname = SDL_GetAudioDeviceName(0, iscapture);
- if (devname == NULL) {
- return SDL_SetError("No such audio device");
- }
- }
-
- /* Make sure fragment size stays a power of 2, or OSS fails. */
- /* I don't know which of these are actually legal values, though... */
- if (this->spec.channels > 8)
- this->spec.channels = 8;
- else if (this->spec.channels > 4)
- this->spec.channels = 4;
- else if (this->spec.channels > 2)
- this->spec.channels = 2;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Open the audio device */
- this->hidden->audio_fd = open(devname, flags, 0);
- if (this->hidden->audio_fd < 0) {
- return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
- }
-
- /* Make the file descriptor use blocking i/o with fcntl() */
- {
- long ctlflags;
- ctlflags = fcntl(this->hidden->audio_fd, F_GETFL);
- ctlflags &= ~O_NONBLOCK;
- if (fcntl(this->hidden->audio_fd, F_SETFL, ctlflags) < 0) {
- return SDL_SetError("Couldn't set audio blocking mode");
- }
- }
-
- /* Get a list of supported hardware formats */
- if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
- perror("SNDCTL_DSP_GETFMTS");
- return SDL_SetError("Couldn't get audio format list");
- }
-
- /* Try for a closest match on audio format */
- format = 0;
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- !format && test_format;) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
-#endif
- switch (test_format) {
- case AUDIO_U8:
- if (value & AFMT_U8) {
- format = AFMT_U8;
- }
- break;
- case AUDIO_S16LSB:
- if (value & AFMT_S16_LE) {
- format = AFMT_S16_LE;
- }
- break;
- case AUDIO_S16MSB:
- if (value & AFMT_S16_BE) {
- format = AFMT_S16_BE;
- }
- break;
-#if 0
-/*
- * These formats are not used by any real life systems so they are not
- * needed here.
- */
- case AUDIO_S8:
- if (value & AFMT_S8) {
- format = AFMT_S8;
- }
- break;
- case AUDIO_U16LSB:
- if (value & AFMT_U16_LE) {
- format = AFMT_U16_LE;
- }
- break;
- case AUDIO_U16MSB:
- if (value & AFMT_U16_BE) {
- format = AFMT_U16_BE;
- }
- break;
-#endif
- default:
- format = 0;
- break;
- }
- if (!format) {
- test_format = SDL_NextAudioFormat();
- }
- }
- if (format == 0) {
- return SDL_SetError("Couldn't find any hardware audio formats");
- }
- this->spec.format = test_format;
-
- /* Set the audio format */
- value = format;
- if ((ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
- (value != format)) {
- perror("SNDCTL_DSP_SETFMT");
- return SDL_SetError("Couldn't set audio format");
- }
-
- /* Set the number of channels of output */
- value = this->spec.channels;
- if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0) {
- perror("SNDCTL_DSP_CHANNELS");
- return SDL_SetError("Cannot set the number of channels");
- }
- this->spec.channels = value;
-
- /* Set the DSP frequency */
- value = this->spec.freq;
- if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
- perror("SNDCTL_DSP_SPEED");
- return SDL_SetError("Couldn't set audio frequency");
- }
- this->spec.freq = value;
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Determine the power of two of the fragment size */
- for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec);
- if ((0x01U << frag_spec) != this->spec.size) {
- return SDL_SetError("Fragment size must be a power of two");
- }
- frag_spec |= 0x00020000; /* two fragments, for low latency */
-
- /* Set the audio buffering parameters */
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Requesting %d fragments of size %d\n",
- (frag_spec >> 16), 1 << (frag_spec & 0xFFFF));
-#endif
- if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) {
- perror("SNDCTL_DSP_SETFRAGMENT");
- }
-#ifdef DEBUG_AUDIO
- {
- audio_buf_info info;
- ioctl(this->hidden->audio_fd, SNDCTL_DSP_GETOSPACE, &info);
- fprintf(stderr, "fragments = %d\n", info.fragments);
- fprintf(stderr, "fragstotal = %d\n", info.fragstotal);
- fprintf(stderr, "fragsize = %d\n", info.fragsize);
- fprintf(stderr, "bytes = %d\n", info.bytes);
- }
-#endif
-
- /* Allocate mixing buffer */
- if (!iscapture) {
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
- }
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-
-static void
-DSP_PlayDevice(_THIS)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- if (write(h->audio_fd, h->mixbuf, h->mixlen) == -1) {
- perror("Audio write");
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", h->mixlen);
-#endif
-}
-
-static Uint8 *
-DSP_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-static int
-DSP_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- return (int) read(this->hidden->audio_fd, buffer, buflen);
-}
-
-static void
-DSP_FlushCapture(_THIS)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- audio_buf_info info;
- if (ioctl(h->audio_fd, SNDCTL_DSP_GETISPACE, &info) == 0) {
- while (info.bytes > 0) {
- char buf[512];
- const size_t len = SDL_min(sizeof (buf), info.bytes);
- const ssize_t br = read(h->audio_fd, buf, len);
- if (br <= 0) {
- break;
- }
- info.bytes -= br;
- }
- }
-}
-
-static int
-DSP_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->DetectDevices = DSP_DetectDevices;
- impl->OpenDevice = DSP_OpenDevice;
- impl->PlayDevice = DSP_PlayDevice;
- impl->GetDeviceBuf = DSP_GetDeviceBuf;
- impl->CloseDevice = DSP_CloseDevice;
- impl->CaptureFromDevice = DSP_CaptureFromDevice;
- impl->FlushCapture = DSP_FlushCapture;
-
- impl->AllowsArbitraryDeviceNames = 1;
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-
-AudioBootStrap DSP_bootstrap = {
- "dsp", "OSS /dev/dsp standard audio", DSP_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_OSS */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.h b/3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.h
deleted file mode 100644
index 0e4acfcaba2..00000000000
--- a/3rdparty/SDL2/src/audio/dsp/SDL_dspaudio.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_dspaudio_h
-#define _SDL_dspaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The file descriptor for the audio device */
- int audio_fd;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-};
-#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */
-
-#endif /* _SDL_dspaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.c b/3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.c
deleted file mode 100644
index b39f8e32704..00000000000
--- a/3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-/* Output audio to nowhere... */
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_dummyaudio.h"
-
-static int
-DUMMYAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- return 0; /* always succeeds. */
-}
-
-static int
-DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- /* Delay to make this sort of simulate real audio input. */
- SDL_Delay((this->spec.samples * 1000) / this->spec.freq);
-
- /* always return a full buffer of silence. */
- SDL_memset(buffer, this->spec.silence, buflen);
- return buflen;
-}
-
-static int
-DUMMYAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->OpenDevice = DUMMYAUDIO_OpenDevice;
- impl->CaptureFromDevice = DUMMYAUDIO_CaptureFromDevice;
-
- impl->OnlyHasDefaultOutputDevice = 1;
- impl->OnlyHasDefaultCaptureDevice = 1;
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap DUMMYAUDIO_bootstrap = {
- "dummy", "SDL dummy audio driver", DUMMYAUDIO_Init, 1
-};
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.h b/3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.h
deleted file mode 100644
index b1f88b1cb3a..00000000000
--- a/3rdparty/SDL2/src/audio/dummy/SDL_dummyaudio.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_dummyaudio_h
-#define _SDL_dummyaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The file descriptor for the audio device */
- Uint8 *mixbuf;
- Uint32 mixlen;
- Uint32 write_delay;
- Uint32 initial_calls;
-};
-
-#endif /* _SDL_dummyaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.c b/3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.c
deleted file mode 100644
index 839d445ee61..00000000000
--- a/3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_EMSCRIPTEN
-
-#include "SDL_audio.h"
-#include "SDL_log.h"
-#include "../SDL_audio_c.h"
-#include "SDL_emscriptenaudio.h"
-
-#include <emscripten/emscripten.h>
-
-static int
-copyData(_THIS)
-{
- int byte_len;
-
- if (this->hidden->write_off + this->convert.len_cvt > this->hidden->mixlen) {
- if (this->hidden->write_off > this->hidden->read_off) {
- SDL_memmove(this->hidden->mixbuf,
- this->hidden->mixbuf + this->hidden->read_off,
- this->hidden->mixlen - this->hidden->read_off);
- this->hidden->write_off = this->hidden->write_off - this->hidden->read_off;
- } else {
- this->hidden->write_off = 0;
- }
- this->hidden->read_off = 0;
- }
-
- SDL_memcpy(this->hidden->mixbuf + this->hidden->write_off,
- this->convert.buf,
- this->convert.len_cvt);
- this->hidden->write_off += this->convert.len_cvt;
- byte_len = this->hidden->write_off - this->hidden->read_off;
-
- return byte_len;
-}
-
-static void
-HandleAudioProcess(_THIS)
-{
- Uint8 *buf = NULL;
- int byte_len = 0;
- int bytes = SDL_AUDIO_BITSIZE(this->spec.format) / 8;
-
- /* Only do something if audio is enabled */
- if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
- return;
- }
-
- if (this->convert.needed) {
- const int bytes_in = SDL_AUDIO_BITSIZE(this->convert.src_format) / 8;
-
- if (this->hidden->conv_in_len != 0) {
- this->convert.len = this->hidden->conv_in_len * bytes_in * this->spec.channels;
- }
-
- (*this->spec.callback) (this->spec.userdata,
- this->convert.buf,
- this->convert.len);
- SDL_ConvertAudio(&this->convert);
- buf = this->convert.buf;
- byte_len = this->convert.len_cvt;
-
- /* size mismatch*/
- if (byte_len != this->spec.size) {
- if (!this->hidden->mixbuf) {
- this->hidden->mixlen = this->spec.size > byte_len ? this->spec.size * 2 : byte_len * 2;
- this->hidden->mixbuf = SDL_malloc(this->hidden->mixlen);
- }
-
- /* copy existing data */
- byte_len = copyData(this);
-
- /* read more data*/
- while (byte_len < this->spec.size) {
- (*this->spec.callback) (this->spec.userdata,
- this->convert.buf,
- this->convert.len);
- SDL_ConvertAudio(&this->convert);
- byte_len = copyData(this);
- }
-
- byte_len = this->spec.size;
- buf = this->hidden->mixbuf + this->hidden->read_off;
- this->hidden->read_off += byte_len;
- }
-
- } else {
- if (!this->hidden->mixbuf) {
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = SDL_malloc(this->hidden->mixlen);
- }
- (*this->spec.callback) (this->spec.userdata,
- this->hidden->mixbuf,
- this->hidden->mixlen);
- buf = this->hidden->mixbuf;
- byte_len = this->hidden->mixlen;
- }
-
- if (buf) {
- EM_ASM_ARGS({
- var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels'];
- for (var c = 0; c < numChannels; ++c) {
- var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c);
- if (channelData.length != $1) {
- throw 'Web Audio output buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!';
- }
-
- for (var j = 0; j < $1; ++j) {
- channelData[j] = HEAPF32[$0 + ((j*numChannels + c) << 2) >> 2];
- }
- }
- }, buf, byte_len / bytes / this->spec.channels);
- }
-}
-
-static void
-HandleCaptureProcess(_THIS)
-{
- Uint8 *buf;
- int buflen;
-
- /* Only do something if audio is enabled */
- if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
- return;
- }
-
- if (this->convert.needed) {
- buf = this->convert.buf;
- buflen = this->convert.len_cvt;
- } else {
- if (!this->hidden->mixbuf) {
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size);
- if (!this->hidden->mixbuf) {
- return; /* oh well. */
- }
- }
- buf = this->hidden->mixbuf;
- buflen = this->spec.size;
- }
-
- EM_ASM_ARGS({
- var numChannels = SDL2.capture.currentCaptureBuffer.numberOfChannels;
- if (numChannels == 1) { /* fastpath this a little for the common (mono) case. */
- var channelData = SDL2.capture.currentCaptureBuffer.getChannelData(0);
- if (channelData.length != $1) {
- throw 'Web Audio capture buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!';
- }
- for (var j = 0; j < $1; ++j) {
- setValue($0 + (j * 4), channelData[j], 'float');
- }
- } else {
- for (var c = 0; c < numChannels; ++c) {
- var channelData = SDL2.capture.currentCaptureBuffer.getChannelData(c);
- if (channelData.length != $1) {
- throw 'Web Audio capture buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!';
- }
-
- for (var j = 0; j < $1; ++j) {
- setValue($0 + (((j * numChannels) + c) * 4), channelData[j], 'float');
- }
- }
- }
- }, buf, (this->spec.size / sizeof (float)) / this->spec.channels);
-
- /* okay, we've got an interleaved float32 array in C now. */
-
- if (this->convert.needed) {
- SDL_ConvertAudio(&this->convert);
- }
-
- /* Send it to the app. */
- (*this->spec.callback) (this->spec.userdata, buf, buflen);
-}
-
-
-
-static void
-EMSCRIPTENAUDIO_CloseDevice(_THIS)
-{
- EM_ASM_({
- if ($0) {
- if (SDL2.capture.silenceTimer !== undefined) {
- clearTimeout(SDL2.capture.silenceTimer);
- }
- if (SDL2.capture.stream !== undefined) {
- var tracks = SDL2.capture.stream.getAudioTracks();
- for (var i = 0; i < tracks.length; i++) {
- SDL2.capture.stream.removeTrack(tracks[i]);
- }
- SDL2.capture.stream = undefined;
- }
- if (SDL2.capture.scriptProcessorNode !== undefined) {
- SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) {};
- SDL2.capture.scriptProcessorNode.disconnect();
- SDL2.capture.scriptProcessorNode = undefined;
- }
- if (SDL2.capture.mediaStreamNode !== undefined) {
- SDL2.capture.mediaStreamNode.disconnect();
- SDL2.capture.mediaStreamNode = undefined;
- }
- if (SDL2.capture.silenceBuffer !== undefined) {
- SDL2.capture.silenceBuffer = undefined
- }
- SDL2.capture = undefined;
- } else {
- if (SDL2.audio.scriptProcessorNode != undefined) {
- SDL2.audio.scriptProcessorNode.disconnect();
- SDL2.audio.scriptProcessorNode = undefined;
- }
- SDL2.audio = undefined;
- }
- if ((SDL2.audioContext !== undefined) && (SDL2.audio === undefined) && (SDL2.capture === undefined)) {
- SDL2.audioContext.close();
- SDL2.audioContext = undefined;
- }
- }, this->iscapture);
-
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-EMSCRIPTENAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- SDL_bool valid_format = SDL_FALSE;
- SDL_AudioFormat test_format;
- int i;
- float f;
- int result;
-
- /* based on parts of library_sdl.js */
-
- /* create context (TODO: this puts stuff in the global namespace...)*/
- result = EM_ASM_INT({
- if(typeof(SDL2) === 'undefined') {
- SDL2 = {};
- }
- if (!$0) {
- SDL2.audio = {};
- } else {
- SDL2.capture = {};
- }
-
- if (!SDL2.audioContext) {
- if (typeof(AudioContext) !== 'undefined') {
- SDL2.audioContext = new AudioContext();
- } else if (typeof(webkitAudioContext) !== 'undefined') {
- SDL2.audioContext = new webkitAudioContext();
- }
- }
- return SDL2.audioContext === undefined ? -1 : 0;
- }, iscapture);
- if (result < 0) {
- return SDL_SetError("Web Audio API is not available!");
- }
-
- test_format = SDL_FirstAudioFormat(this->spec.format);
- while ((!valid_format) && (test_format)) {
- switch (test_format) {
- case AUDIO_F32: /* web audio only supports floats */
- this->spec.format = test_format;
-
- valid_format = SDL_TRUE;
- break;
- }
- test_format = SDL_NextAudioFormat();
- }
-
- if (!valid_format) {
- /* Didn't find a compatible format :( */
- return SDL_SetError("No compatible audio format!");
- }
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* limit to native freq */
- const int sampleRate = EM_ASM_INT_V({
- return SDL2.audioContext.sampleRate;
- });
-
- if(this->spec.freq != sampleRate) {
- for (i = this->spec.samples; i > 0; i--) {
- f = (float)i / (float)sampleRate * (float)this->spec.freq;
- if (SDL_floor(f) == f) {
- this->hidden->conv_in_len = SDL_floor(f);
- break;
- }
- }
-
- this->spec.freq = sampleRate;
- }
-
- SDL_CalculateAudioSpec(&this->spec);
-
- if (iscapture) {
- /* The idea is to take the capture media stream, hook it up to an
- audio graph where we can pass it through a ScriptProcessorNode
- to access the raw PCM samples and push them to the SDL app's
- callback. From there, we "process" the audio data into silence
- and forget about it. */
-
- /* This should, strictly speaking, use MediaRecorder for capture, but
- this API is cleaner to use and better supported, and fires a
- callback whenever there's enough data to fire down into the app.
- The downside is that we are spending CPU time silencing a buffer
- that the audiocontext uselessly mixes into any output. On the
- upside, both of those things are not only run in native code in
- the browser, they're probably SIMD code, too. MediaRecorder
- feels like it's a pretty inefficient tapdance in similar ways,
- to be honest. */
-
- EM_ASM_({
- var have_microphone = function(stream) {
- //console.log('SDL audio capture: we have a microphone! Replacing silence callback.');
- if (SDL2.capture.silenceTimer !== undefined) {
- clearTimeout(SDL2.capture.silenceTimer);
- SDL2.capture.silenceTimer = undefined;
- }
- SDL2.capture.mediaStreamNode = SDL2.audioContext.createMediaStreamSource(stream);
- SDL2.capture.scriptProcessorNode = SDL2.audioContext.createScriptProcessor($1, $0, 1);
- SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) {
- if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; }
- audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0);
- SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer;
- Runtime.dynCall('vi', $2, [$3]);
- };
- SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode);
- SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination);
- SDL2.capture.stream = stream;
- };
-
- var no_microphone = function(error) {
- //console.log('SDL audio capture: we DO NOT have a microphone! (' + error.name + ')...leaving silence callback running.');
- };
-
- /* we write silence to the audio callback until the microphone is available (user approves use, etc). */
- SDL2.capture.silenceBuffer = SDL2.audioContext.createBuffer($0, $1, SDL2.audioContext.sampleRate);
- SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0);
- var silence_callback = function() {
- SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer;
- Runtime.dynCall('vi', $2, [$3]);
- };
-
- SDL2.capture.silenceTimer = setTimeout(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000);
-
- if ((navigator.mediaDevices !== undefined) && (navigator.mediaDevices.getUserMedia !== undefined)) {
- navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(have_microphone).catch(no_microphone);
- } else if (navigator.webkitGetUserMedia !== undefined) {
- navigator.webkitGetUserMedia({ audio: true, video: false }, have_microphone, no_microphone);
- }
- }, this->spec.channels, this->spec.samples, HandleCaptureProcess, this);
- } else {
- /* setup a ScriptProcessorNode */
- EM_ASM_ARGS({
- SDL2.audio.scriptProcessorNode = SDL2.audioContext['createScriptProcessor']($1, 0, $0);
- SDL2.audio.scriptProcessorNode['onaudioprocess'] = function (e) {
- if ((SDL2 === undefined) || (SDL2.audio === undefined)) { return; }
- SDL2.audio.currentOutputBuffer = e['outputBuffer'];
- Runtime.dynCall('vi', $2, [$3]);
- };
- SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
- }, this->spec.channels, this->spec.samples, HandleAudioProcess, this);
- }
-
- return 0;
-}
-
-static int
-EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->OpenDevice = EMSCRIPTENAUDIO_OpenDevice;
- impl->CloseDevice = EMSCRIPTENAUDIO_CloseDevice;
-
- impl->OnlyHasDefaultOutputDevice = 1;
-
- /* no threads here */
- impl->SkipMixerLock = 1;
- impl->ProvidesOwnCallbackThread = 1;
-
- /* check availability */
- const int available = EM_ASM_INT_V({
- if (typeof(AudioContext) !== 'undefined') {
- return 1;
- } else if (typeof(webkitAudioContext) !== 'undefined') {
- return 1;
- }
- return 0;
- });
-
- if (!available) {
- SDL_SetError("No audio context available");
- }
-
- const int capture_available = available && EM_ASM_INT_V({
- if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) {
- return 1;
- } else if (typeof(navigator.webkitGetUserMedia) !== 'undefined') {
- return 1;
- }
- return 0;
- });
-
- impl->HasCaptureSupport = capture_available ? SDL_TRUE : SDL_FALSE;
- impl->OnlyHasDefaultCaptureDevice = capture_available ? SDL_TRUE : SDL_FALSE;
-
- return available;
-}
-
-AudioBootStrap EMSCRIPTENAUDIO_bootstrap = {
- "emscripten", "SDL emscripten audio driver", EMSCRIPTENAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_EMSCRIPTEN */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.h b/3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.h
deleted file mode 100644
index cd5377d86cc..00000000000
--- a/3rdparty/SDL2/src/audio/emscripten/SDL_emscriptenaudio.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_emscriptenaudio_h
-#define _SDL_emscriptenaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- Uint8 *mixbuf;
- Uint32 mixlen;
-
- Uint32 conv_in_len;
-
- Uint32 write_off, read_off;
-};
-
-#endif /* _SDL_emscriptenaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/esd/SDL_esdaudio.c b/3rdparty/SDL2/src/audio/esd/SDL_esdaudio.c
deleted file mode 100644
index 3eb71979106..00000000000
--- a/3rdparty/SDL2/src/audio/esd/SDL_esdaudio.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_ESD
-
-/* Allow access to an ESD network stream mixing buffer */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <esd.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_esdaudio.h"
-
-#ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC
-#include "SDL_name.h"
-#include "SDL_loadso.h"
-#else
-#define SDL_NAME(X) X
-#endif
-
-#ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC
-
-static const char *esd_library = SDL_AUDIO_DRIVER_ESD_DYNAMIC;
-static void *esd_handle = NULL;
-
-static int (*SDL_NAME(esd_open_sound)) (const char *host);
-static int (*SDL_NAME(esd_close)) (int esd);
-static int (*SDL_NAME(esd_play_stream)) (esd_format_t format, int rate,
- const char *host, const char *name);
-
-#define SDL_ESD_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
-static struct
-{
- const char *name;
- void **func;
-} const esd_functions[] = {
- SDL_ESD_SYM(esd_open_sound),
- SDL_ESD_SYM(esd_close), SDL_ESD_SYM(esd_play_stream),
-};
-
-#undef SDL_ESD_SYM
-
-static void
-UnloadESDLibrary()
-{
- if (esd_handle != NULL) {
- SDL_UnloadObject(esd_handle);
- esd_handle = NULL;
- }
-}
-
-static int
-LoadESDLibrary(void)
-{
- int i, retval = -1;
-
- if (esd_handle == NULL) {
- esd_handle = SDL_LoadObject(esd_library);
- if (esd_handle) {
- retval = 0;
- for (i = 0; i < SDL_arraysize(esd_functions); ++i) {
- *esd_functions[i].func =
- SDL_LoadFunction(esd_handle, esd_functions[i].name);
- if (!*esd_functions[i].func) {
- retval = -1;
- UnloadESDLibrary();
- break;
- }
- }
- }
- }
- return retval;
-}
-
-#else
-
-static void
-UnloadESDLibrary()
-{
- return;
-}
-
-static int
-LoadESDLibrary(void)
-{
- return 0;
-}
-
-#endif /* SDL_AUDIO_DRIVER_ESD_DYNAMIC */
-
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-ESD_WaitDevice(_THIS)
-{
- Sint32 ticks;
-
- /* Check to see if the thread-parent process is still alive */
- {
- static int cnt = 0;
- /* Note that this only works with thread implementations
- that use a different process id for each thread.
- */
- /* Check every 10 loops */
- if (this->hidden->parent && (((++cnt) % 10) == 0)) {
- if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
- }
- }
-
- /* Use timer for general audio synchronization */
- ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
- if (ticks > 0) {
- SDL_Delay(ticks);
- }
-}
-
-static void
-ESD_PlayDevice(_THIS)
-{
- int written = 0;
-
- /* Write the audio data, checking for EAGAIN on broken audio drivers */
- do {
- written = write(this->hidden->audio_fd,
- this->hidden->mixbuf, this->hidden->mixlen);
- if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
- SDL_Delay(1); /* Let a little CPU time go by */
- }
- } while ((written < 0) &&
- ((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
-
- /* Set the next write frame */
- this->hidden->next_frame += this->hidden->frame_ticks;
-
- /* If we couldn't write, assume fatal error for now */
- if (written < 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-}
-
-static Uint8 *
-ESD_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-static void
-ESD_CloseDevice(_THIS)
-{
- if (this->hidden->audio_fd >= 0) {
- SDL_NAME(esd_close) (this->hidden->audio_fd);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-/* Try to get the name of the program */
-static char *
-get_progname(void)
-{
- char *progname = NULL;
-#ifdef __LINUX__
- FILE *fp;
- static char temp[BUFSIZ];
-
- SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid());
- fp = fopen(temp, "r");
- if (fp != NULL) {
- if (fgets(temp, sizeof(temp) - 1, fp)) {
- progname = SDL_strrchr(temp, '/');
- if (progname == NULL) {
- progname = temp;
- } else {
- progname = progname + 1;
- }
- }
- fclose(fp);
- }
-#endif
- return (progname);
-}
-
-
-static int
-ESD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- esd_format_t format = (ESD_STREAM | ESD_PLAY);
- SDL_AudioFormat test_format = 0;
- int found = 0;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
- this->hidden->audio_fd = -1;
-
- /* Convert audio spec to the ESD audio format */
- /* Try for a closest match on audio format */
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- !found && test_format; test_format = SDL_NextAudioFormat()) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
-#endif
- found = 1;
- switch (test_format) {
- case AUDIO_U8:
- format |= ESD_BITS8;
- break;
- case AUDIO_S16SYS:
- format |= ESD_BITS16;
- break;
- default:
- found = 0;
- break;
- }
- }
-
- if (!found) {
- return SDL_SetError("Couldn't find any hardware audio formats");
- }
-
- if (this->spec.channels == 1) {
- format |= ESD_MONO;
- } else {
- format |= ESD_STEREO;
- }
-#if 0
- this->spec.samples = ESD_BUF_SIZE; /* Darn, no way to change this yet */
-#endif
-
- /* Open a connection to the ESD audio server */
- this->hidden->audio_fd =
- SDL_NAME(esd_play_stream) (format, this->spec.freq, NULL,
- get_progname());
-
- if (this->hidden->audio_fd < 0) {
- return SDL_SetError("Couldn't open ESD connection");
- }
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
- this->hidden->frame_ticks =
- (float) (this->spec.samples * 1000) / this->spec.freq;
- this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks;
-
- /* Allocate mixing buffer */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
-
- /* Get the parent process id (we're the parent of the audio thread) */
- this->hidden->parent = getpid();
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-static void
-ESD_Deinitialize(void)
-{
- UnloadESDLibrary();
-}
-
-static int
-ESD_Init(SDL_AudioDriverImpl * impl)
-{
- if (LoadESDLibrary() < 0) {
- return 0;
- } else {
- int connection = 0;
-
- /* Don't start ESD if it's not running */
- SDL_setenv("ESD_NO_SPAWN", "1", 0);
-
- connection = SDL_NAME(esd_open_sound) (NULL);
- if (connection < 0) {
- UnloadESDLibrary();
- SDL_SetError("ESD: esd_open_sound failed (no audio server?)");
- return 0;
- }
- SDL_NAME(esd_close) (connection);
- }
-
- /* Set the function pointers */
- impl->OpenDevice = ESD_OpenDevice;
- impl->PlayDevice = ESD_PlayDevice;
- impl->WaitDevice = ESD_WaitDevice;
- impl->GetDeviceBuf = ESD_GetDeviceBuf;
- impl->CloseDevice = ESD_CloseDevice;
- impl->Deinitialize = ESD_Deinitialize;
- impl->OnlyHasDefaultOutputDevice = 1;
-
- return 1; /* this audio target is available. */
-}
-
-
-AudioBootStrap ESD_bootstrap = {
- "esd", "Enlightened Sound Daemon", ESD_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_ESD */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/esd/SDL_esdaudio.h b/3rdparty/SDL2/src/audio/esd/SDL_esdaudio.h
deleted file mode 100644
index d362b16ce07..00000000000
--- a/3rdparty/SDL2/src/audio/esd/SDL_esdaudio.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_esdaudio_h
-#define _SDL_esdaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The file descriptor for the audio device */
- int audio_fd;
-
- /* The parent process id, to detect when application quits */
- pid_t parent;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-
- /* Support for audio timing using a timer */
- float frame_ticks;
- float next_frame;
-};
-#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */
-
-#endif /* _SDL_esdaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.c b/3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.c
deleted file mode 100644
index daa0f9dd66c..00000000000
--- a/3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_FUSIONSOUND
-
-/* !!! FIXME: why is this is SDL_FS_* instead of FUSIONSOUND_*? */
-
-/* Allow access to a raw mixing buffer */
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#include <unistd.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_fsaudio.h"
-
-#include <fusionsound/fusionsound_version.h>
-
-/* #define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so" */
-
-#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC
-#include "SDL_name.h"
-#include "SDL_loadso.h"
-#else
-#define SDL_NAME(X) X
-#endif
-
-#if (FUSIONSOUND_MAJOR_VERSION == 1) && (FUSIONSOUND_MINOR_VERSION < 1)
-typedef DFBResult DirectResult;
-#endif
-
-/* Buffers to use - more than 2 gives a lot of latency */
-#define FUSION_BUFFERS (2)
-
-#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC
-
-static const char *fs_library = SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC;
-static void *fs_handle = NULL;
-
-static DirectResult (*SDL_NAME(FusionSoundInit)) (int *argc, char *(*argv[]));
-static DirectResult (*SDL_NAME(FusionSoundCreate)) (IFusionSound **
- ret_interface);
-
-#define SDL_FS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
-static struct
-{
- const char *name;
- void **func;
-} fs_functions[] = {
-/* *INDENT-OFF* */
- SDL_FS_SYM(FusionSoundInit),
- SDL_FS_SYM(FusionSoundCreate),
-/* *INDENT-ON* */
-};
-
-#undef SDL_FS_SYM
-
-static void
-UnloadFusionSoundLibrary()
-{
- if (fs_handle != NULL) {
- SDL_UnloadObject(fs_handle);
- fs_handle = NULL;
- }
-}
-
-static int
-LoadFusionSoundLibrary(void)
-{
- int i, retval = -1;
-
- if (fs_handle == NULL) {
- fs_handle = SDL_LoadObject(fs_library);
- if (fs_handle != NULL) {
- retval = 0;
- for (i = 0; i < SDL_arraysize(fs_functions); ++i) {
- *fs_functions[i].func =
- SDL_LoadFunction(fs_handle, fs_functions[i].name);
- if (!*fs_functions[i].func) {
- retval = -1;
- UnloadFusionSoundLibrary();
- break;
- }
- }
- }
- }
-
- return retval;
-}
-
-#else
-
-static void
-UnloadFusionSoundLibrary()
-{
- return;
-}
-
-static int
-LoadFusionSoundLibrary(void)
-{
- return 0;
-}
-
-#endif /* SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-SDL_FS_WaitDevice(_THIS)
-{
- this->hidden->stream->Wait(this->hidden->stream,
- this->hidden->mixsamples);
-}
-
-static void
-SDL_FS_PlayDevice(_THIS)
-{
- DirectResult ret;
-
- ret = this->hidden->stream->Write(this->hidden->stream,
- this->hidden->mixbuf,
- this->hidden->mixsamples);
- /* If we couldn't write, assume fatal error for now */
- if (ret) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen);
-#endif
-}
-
-
-static Uint8 *
-SDL_FS_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-
-static void
-SDL_FS_CloseDevice(_THIS)
-{
- if (this->hidden->stream) {
- this->hidden->stream->Release(this->hidden->stream);
- }
- if (this->hidden->fs) {
- this->hidden->fs->Release(this->hidden->fs);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-
-static int
-SDL_FS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- int bytes;
- SDL_AudioFormat test_format = 0, format = 0;
- FSSampleFormat fs_format;
- FSStreamDescription desc;
- DirectResult ret;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Try for a closest match on audio format */
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- !format && test_format;) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
-#endif
- switch (test_format) {
- case AUDIO_U8:
- fs_format = FSSF_U8;
- bytes = 1;
- format = 1;
- break;
- case AUDIO_S16SYS:
- fs_format = FSSF_S16;
- bytes = 2;
- format = 1;
- break;
- case AUDIO_S32SYS:
- fs_format = FSSF_S32;
- bytes = 4;
- format = 1;
- break;
- case AUDIO_F32SYS:
- fs_format = FSSF_FLOAT;
- bytes = 4;
- format = 1;
- break;
- default:
- format = 0;
- break;
- }
- if (!format) {
- test_format = SDL_NextAudioFormat();
- }
- }
-
- if (format == 0) {
- return SDL_SetError("Couldn't find any hardware audio formats");
- }
- this->spec.format = test_format;
-
- /* Retrieve the main sound interface. */
- ret = SDL_NAME(FusionSoundCreate) (&this->hidden->fs);
- if (ret) {
- return SDL_SetError("Unable to initialize FusionSound: %d", ret);
- }
-
- this->hidden->mixsamples = this->spec.size / bytes / this->spec.channels;
-
- /* Fill stream description. */
- desc.flags = FSSDF_SAMPLERATE | FSSDF_BUFFERSIZE |
- FSSDF_CHANNELS | FSSDF_SAMPLEFORMAT | FSSDF_PREBUFFER;
- desc.samplerate = this->spec.freq;
- desc.buffersize = this->spec.size * FUSION_BUFFERS;
- desc.channels = this->spec.channels;
- desc.prebuffer = 10;
- desc.sampleformat = fs_format;
-
- ret =
- this->hidden->fs->CreateStream(this->hidden->fs, &desc,
- &this->hidden->stream);
- if (ret) {
- return SDL_SetError("Unable to create FusionSoundStream: %d", ret);
- }
-
- /* See what we got */
- desc.flags = FSSDF_SAMPLERATE | FSSDF_BUFFERSIZE |
- FSSDF_CHANNELS | FSSDF_SAMPLEFORMAT;
- ret = this->hidden->stream->GetDescription(this->hidden->stream, &desc);
-
- this->spec.freq = desc.samplerate;
- this->spec.size =
- desc.buffersize / FUSION_BUFFERS * bytes * desc.channels;
- this->spec.channels = desc.channels;
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate mixing buffer */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-
-static void
-SDL_FS_Deinitialize(void)
-{
- UnloadFusionSoundLibrary();
-}
-
-
-static int
-SDL_FS_Init(SDL_AudioDriverImpl * impl)
-{
- if (LoadFusionSoundLibrary() < 0) {
- return 0;
- } else {
- DirectResult ret;
-
- ret = SDL_NAME(FusionSoundInit) (NULL, NULL);
- if (ret) {
- UnloadFusionSoundLibrary();
- SDL_SetError
- ("FusionSound: SDL_FS_init failed (FusionSoundInit: %d)",
- ret);
- return 0;
- }
- }
-
- /* Set the function pointers */
- impl->OpenDevice = SDL_FS_OpenDevice;
- impl->PlayDevice = SDL_FS_PlayDevice;
- impl->WaitDevice = SDL_FS_WaitDevice;
- impl->GetDeviceBuf = SDL_FS_GetDeviceBuf;
- impl->CloseDevice = SDL_FS_CloseDevice;
- impl->Deinitialize = SDL_FS_Deinitialize;
- impl->OnlyHasDefaultOutputDevice = 1;
-
- return 1; /* this audio target is available. */
-}
-
-
-AudioBootStrap FUSIONSOUND_bootstrap = {
- "fusionsound", "FusionSound", SDL_FS_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_FUSIONSOUND */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.h b/3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.h
deleted file mode 100644
index 5cf8a2009b1..00000000000
--- a/3rdparty/SDL2/src/audio/fusionsound/SDL_fsaudio.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_fsaudio_h
-#define _SDL_fsaudio_h
-
-#include <fusionsound/fusionsound.h>
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* Interface */
- IFusionSound *fs;
-
- /* The stream interface for the audio device */
- IFusionSoundStream *stream;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
- int mixsamples;
-
-};
-
-#endif /* _SDL_fsaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.cc b/3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.cc
deleted file mode 100644
index 25b1fa2179f..00000000000
--- a/3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.cc
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_HAIKU
-
-/* Allow access to the audio stream on Haiku */
-
-#include <SoundPlayer.h>
-#include <signal.h>
-
-#include "../../main/haiku/SDL_BeApp.h"
-
-extern "C"
-{
-
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_haikuaudio.h"
-
-}
-
-
-/* !!! FIXME: have the callback call the higher level to avoid code dupe. */
-/* The Haiku callback for handling the audio buffer */
-static void
-FillSound(void *device, void *stream, size_t len,
- const media_raw_audio_format & format)
-{
- SDL_AudioDevice *audio = (SDL_AudioDevice *) device;
-
- /* Only do soemthing if audio is enabled */
- if (!SDL_AtomicGet(&audio->enabled)) {
- return;
- }
-
- if (!SDL_AtomicGet(&audio->paused)) {
- if (audio->convert.needed) {
- SDL_LockMutex(audio->mixer_lock);
- (*audio->spec.callback) (audio->spec.userdata,
- (Uint8 *) audio->convert.buf,
- audio->convert.len);
- SDL_UnlockMutex(audio->mixer_lock);
- SDL_ConvertAudio(&audio->convert);
- SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
- } else {
- SDL_LockMutex(audio->mixer_lock);
- (*audio->spec.callback) (audio->spec.userdata,
- (Uint8 *) stream, len);
- SDL_UnlockMutex(audio->mixer_lock);
- }
- }
-}
-
-static void
-HAIKUAUDIO_CloseDevice(_THIS)
-{
- if (_this->hidden->audio_obj) {
- _this->hidden->audio_obj->Stop();
- delete _this->hidden->audio_obj;
- }
- delete _this->hidden;
-}
-
-
-static const int sig_list[] = {
- SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
-};
-
-static inline void
-MaskSignals(sigset_t * omask)
-{
- sigset_t mask;
- int i;
-
- sigemptyset(&mask);
- for (i = 0; sig_list[i]; ++i) {
- sigaddset(&mask, sig_list[i]);
- }
- sigprocmask(SIG_BLOCK, &mask, omask);
-}
-
-static inline void
-UnmaskSignals(sigset_t * omask)
-{
- sigprocmask(SIG_SETMASK, omask, NULL);
-}
-
-
-static int
-HAIKUAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- int valid_datatype = 0;
- media_raw_audio_format format;
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format);
-
- /* Initialize all variables that we clean on shutdown */
- _this->hidden = new SDL_PrivateAudioData;
- if (_this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(_this->hidden);
-
- /* Parse the audio format and fill the Be raw audio format */
- SDL_zero(format);
- format.byte_order = B_MEDIA_LITTLE_ENDIAN;
- format.frame_rate = (float) _this->spec.freq;
- format.channel_count = _this->spec.channels; /* !!! FIXME: support > 2? */
- while ((!valid_datatype) && (test_format)) {
- valid_datatype = 1;
- _this->spec.format = test_format;
- switch (test_format) {
- case AUDIO_S8:
- format.format = media_raw_audio_format::B_AUDIO_CHAR;
- break;
-
- case AUDIO_U8:
- format.format = media_raw_audio_format::B_AUDIO_UCHAR;
- break;
-
- case AUDIO_S16LSB:
- format.format = media_raw_audio_format::B_AUDIO_SHORT;
- break;
-
- case AUDIO_S16MSB:
- format.format = media_raw_audio_format::B_AUDIO_SHORT;
- format.byte_order = B_MEDIA_BIG_ENDIAN;
- break;
-
- case AUDIO_S32LSB:
- format.format = media_raw_audio_format::B_AUDIO_INT;
- break;
-
- case AUDIO_S32MSB:
- format.format = media_raw_audio_format::B_AUDIO_INT;
- format.byte_order = B_MEDIA_BIG_ENDIAN;
- break;
-
- case AUDIO_F32LSB:
- format.format = media_raw_audio_format::B_AUDIO_FLOAT;
- break;
-
- case AUDIO_F32MSB:
- format.format = media_raw_audio_format::B_AUDIO_FLOAT;
- format.byte_order = B_MEDIA_BIG_ENDIAN;
- break;
-
- default:
- valid_datatype = 0;
- test_format = SDL_NextAudioFormat();
- break;
- }
- }
-
- if (!valid_datatype) { /* shouldn't happen, but just in case... */
- return SDL_SetError("Unsupported audio format");
- }
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&_this->spec);
-
- format.buffer_size = _this->spec.size;
-
- /* Subscribe to the audio stream (creates a new thread) */
- sigset_t omask;
- MaskSignals(&omask);
- _this->hidden->audio_obj = new BSoundPlayer(&format, "SDL Audio",
- FillSound, NULL, _this);
- UnmaskSignals(&omask);
-
- if (_this->hidden->audio_obj->Start() == B_NO_ERROR) {
- _this->hidden->audio_obj->SetHasData(true);
- } else {
- return SDL_SetError("Unable to start Be audio");
- }
-
- /* We're running! */
- return 0;
-}
-
-static void
-HAIKUAUDIO_Deinitialize(void)
-{
- SDL_QuitBeApp();
-}
-
-static int
-HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Initialize the Be Application, if it's not already started */
- if (SDL_InitBeApp() < 0) {
- return 0;
- }
-
- /* Set the function pointers */
- impl->OpenDevice = HAIKUAUDIO_OpenDevice;
- impl->CloseDevice = HAIKUAUDIO_CloseDevice;
- impl->Deinitialize = HAIKUAUDIO_Deinitialize;
- impl->ProvidesOwnCallbackThread = 1;
- impl->OnlyHasDefaultOutputDevice = 1;
-
- return 1; /* this audio target is available. */
-}
-
-extern "C"
-{
- extern AudioBootStrap HAIKUAUDIO_bootstrap;
-}
-AudioBootStrap HAIKUAUDIO_bootstrap = {
- "haiku", "Haiku BSoundPlayer", HAIKUAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_HAIKU */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.h b/3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.h
deleted file mode 100644
index 23e5a7655df..00000000000
--- a/3rdparty/SDL2/src/audio/haiku/SDL_haikuaudio.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_beaudio_h
-#define _SDL_beaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *_this
-
-struct SDL_PrivateAudioData
-{
- BSoundPlayer *audio_obj;
-};
-
-#endif /* _SDL_beaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.c b/3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.c
deleted file mode 100644
index 33cbe1c832b..00000000000
--- a/3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_NACL
-
-#include "SDL_naclaudio.h"
-
-#include "SDL_audio.h"
-#include "SDL_mutex.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_audiodev_c.h"
-
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi_simple/ps.h"
-#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_event.h"
-
-/* The tag name used by NACL audio */
-#define NACLAUDIO_DRIVER_NAME "nacl"
-
-#define SAMPLE_FRAME_COUNT 4096
-
-/* Audio driver functions */
-static void nacl_audio_callback(void* samples, uint32_t buffer_size, PP_TimeDelta latency, void* data);
-
-/* FIXME: Make use of latency if needed */
-static void nacl_audio_callback(void* samples, uint32_t buffer_size, PP_TimeDelta latency, void* data) {
- SDL_AudioDevice* _this = (SDL_AudioDevice*) data;
-
- SDL_LockMutex(private->mutex); /* !!! FIXME: is this mutex necessary? */
-
- if (SDL_AtomicGet(&_this->enabled) && !SDL_AtomicGet(&_this->paused)) {
- if (_this->convert.needed) {
- SDL_LockMutex(_this->mixer_lock);
- (*_this->spec.callback) (_this->spec.userdata,
- (Uint8 *) _this->convert.buf,
- _this->convert.len);
- SDL_UnlockMutex(_this->mixer_lock);
- SDL_ConvertAudio(&_this->convert);
- SDL_memcpy(samples, _this->convert.buf, _this->convert.len_cvt);
- } else {
- SDL_LockMutex(_this->mixer_lock);
- (*_this->spec.callback) (_this->spec.userdata, (Uint8 *) samples, buffer_size);
- SDL_UnlockMutex(_this->mixer_lock);
- }
- } else {
- SDL_memset(samples, _this->spec.silence, buffer_size);
- }
-
- SDL_UnlockMutex(private->mutex);
-}
-
-static void NACLAUDIO_CloseDevice(SDL_AudioDevice *device) {
- const PPB_Core *core = PSInterfaceCore();
- const PPB_Audio *ppb_audio = PSInterfaceAudio();
- SDL_PrivateAudioData *hidden = (SDL_PrivateAudioData *) device->hidden;
-
- ppb_audio->StopPlayback(hidden->audio);
- SDL_DestroyMutex(hidden->mutex);
- core->ReleaseResource(hidden->audio);
-}
-
-static int
-NACLAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) {
- PP_Instance instance = PSGetInstanceId();
- const PPB_Audio *ppb_audio = PSInterfaceAudio();
- const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig();
-
- private = (SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *private));
- if (private == NULL) {
- SDL_OutOfMemory();
- return 0;
- }
-
- private->mutex = SDL_CreateMutex();
- _this->spec.freq = 44100;
- _this->spec.format = AUDIO_S16LSB;
- _this->spec.channels = 2;
- _this->spec.samples = ppb_audiocfg->RecommendSampleFrameCount(
- instance,
- PP_AUDIOSAMPLERATE_44100,
- SAMPLE_FRAME_COUNT);
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&_this->spec);
-
- private->audio = ppb_audio->Create(
- instance,
- ppb_audiocfg->CreateStereo16Bit(instance, PP_AUDIOSAMPLERATE_44100, _this->spec.samples),
- nacl_audio_callback,
- _this);
-
- /* Start audio playback while we are still on the main thread. */
- ppb_audio->StartPlayback(private->audio);
-
- return 1;
-}
-
-static int
-NACLAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- if (PSGetInstanceId() == 0) {
- return 0;
- }
-
- /* Set the function pointers */
- impl->OpenDevice = NACLAUDIO_OpenDevice;
- impl->CloseDevice = NACLAUDIO_CloseDevice;
- impl->OnlyHasDefaultOutputDevice = 1;
- impl->ProvidesOwnCallbackThread = 1;
- /*
- * impl->WaitDevice = NACLAUDIO_WaitDevice;
- * impl->GetDeviceBuf = NACLAUDIO_GetDeviceBuf;
- * impl->PlayDevice = NACLAUDIO_PlayDevice;
- * impl->Deinitialize = NACLAUDIO_Deinitialize;
- */
-
- return 1;
-}
-
-AudioBootStrap NACLAUDIO_bootstrap = {
- NACLAUDIO_DRIVER_NAME, "SDL NaCl Audio Driver",
- NACLAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_NACL */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.h b/3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.h
deleted file mode 100644
index 90ff5448e14..00000000000
--- a/3rdparty/SDL2/src/audio/nacl/SDL_naclaudio.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_naclaudio_h
-#define _SDL_naclaudio_h
-
-#include "SDL_audio.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_mutex.h"
-
-#include "ppapi/c/ppb_audio.h"
-
-#define _THIS SDL_AudioDevice *_this
-#define private _this->hidden
-
-typedef struct SDL_PrivateAudioData {
- SDL_mutex* mutex;
- PP_Resource audio;
-} SDL_PrivateAudioData;
-
-#endif /* _SDL_naclaudio_h */
diff --git a/3rdparty/SDL2/src/audio/nas/SDL_nasaudio.c b/3rdparty/SDL2/src/audio/nas/SDL_nasaudio.c
deleted file mode 100644
index fe15cd6962e..00000000000
--- a/3rdparty/SDL2/src/audio/nas/SDL_nasaudio.c
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_NAS
-
-/* Allow access to a raw mixing buffer */
-
-#include <signal.h>
-#include <unistd.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "SDL_loadso.h"
-#include "../SDL_audio_c.h"
-#include "SDL_nasaudio.h"
-
-static void (*NAS_AuCloseServer) (AuServer *);
-static void (*NAS_AuNextEvent) (AuServer *, AuBool, AuEvent *);
-static AuBool(*NAS_AuDispatchEvent) (AuServer *, AuEvent *);
-static void (*NAS_AuHandleEvents) (AuServer *);
-static AuFlowID(*NAS_AuCreateFlow) (AuServer *, AuStatus *);
-static void (*NAS_AuStartFlow) (AuServer *, AuFlowID, AuStatus *);
-static void (*NAS_AuSetElements)
- (AuServer *, AuFlowID, AuBool, int, AuElement *, AuStatus *);
-static void (*NAS_AuWriteElement)
- (AuServer *, AuFlowID, int, AuUint32, AuPointer, AuBool, AuStatus *);
-static AuUint32 (*NAS_AuReadElement)
- (AuServer *, AuFlowID, int, AuUint32, AuPointer, AuStatus *);
-static AuServer *(*NAS_AuOpenServer)
- (_AuConst char *, int, _AuConst char *, int, _AuConst char *, char **);
-static AuEventHandlerRec *(*NAS_AuRegisterEventHandler)
- (AuServer *, AuMask, int, AuID, AuEventHandlerCallback, AuPointer);
-
-
-#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC
-
-static const char *nas_library = SDL_AUDIO_DRIVER_NAS_DYNAMIC;
-static void *nas_handle = NULL;
-
-static int
-load_nas_sym(const char *fn, void **addr)
-{
- *addr = SDL_LoadFunction(nas_handle, fn);
- if (*addr == NULL) {
- return 0;
- }
- return 1;
-}
-
-/* cast funcs to char* first, to please GCC's strict aliasing rules. */
-#define SDL_NAS_SYM(x) \
- if (!load_nas_sym(#x, (void **) (char *) &NAS_##x)) return -1
-#else
-#define SDL_NAS_SYM(x) NAS_##x = x
-#endif
-
-static int
-load_nas_syms(void)
-{
- SDL_NAS_SYM(AuCloseServer);
- SDL_NAS_SYM(AuNextEvent);
- SDL_NAS_SYM(AuDispatchEvent);
- SDL_NAS_SYM(AuHandleEvents);
- SDL_NAS_SYM(AuCreateFlow);
- SDL_NAS_SYM(AuStartFlow);
- SDL_NAS_SYM(AuSetElements);
- SDL_NAS_SYM(AuWriteElement);
- SDL_NAS_SYM(AuReadElement);
- SDL_NAS_SYM(AuOpenServer);
- SDL_NAS_SYM(AuRegisterEventHandler);
- return 0;
-}
-
-#undef SDL_NAS_SYM
-
-#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC
-
-static void
-UnloadNASLibrary(void)
-{
- if (nas_handle != NULL) {
- SDL_UnloadObject(nas_handle);
- nas_handle = NULL;
- }
-}
-
-static int
-LoadNASLibrary(void)
-{
- int retval = 0;
- if (nas_handle == NULL) {
- nas_handle = SDL_LoadObject(nas_library);
- if (nas_handle == NULL) {
- /* Copy error string so we can use it in a new SDL_SetError(). */
- const char *origerr = SDL_GetError();
- const size_t len = SDL_strlen(origerr) + 1;
- char *err = (char *) alloca(len);
- SDL_strlcpy(err, origerr, len);
- retval = -1;
- SDL_SetError("NAS: SDL_LoadObject('%s') failed: %s\n",
- nas_library, err);
- } else {
- retval = load_nas_syms();
- if (retval < 0) {
- UnloadNASLibrary();
- }
- }
- }
- return retval;
-}
-
-#else
-
-static void
-UnloadNASLibrary(void)
-{
-}
-
-static int
-LoadNASLibrary(void)
-{
- load_nas_syms();
- return 0;
-}
-
-#endif /* SDL_AUDIO_DRIVER_NAS_DYNAMIC */
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-NAS_WaitDevice(_THIS)
-{
- while (this->hidden->buf_free < this->hidden->mixlen) {
- AuEvent ev;
- NAS_AuNextEvent(this->hidden->aud, AuTrue, &ev);
- NAS_AuDispatchEvent(this->hidden->aud, &ev);
- }
-}
-
-static void
-NAS_PlayDevice(_THIS)
-{
- while (this->hidden->mixlen > this->hidden->buf_free) {
- /*
- * We think the buffer is full? Yikes! Ask the server for events,
- * in the hope that some of them is LowWater events telling us more
- * of the buffer is free now than what we think.
- */
- AuEvent ev;
- NAS_AuNextEvent(this->hidden->aud, AuTrue, &ev);
- NAS_AuDispatchEvent(this->hidden->aud, &ev);
- }
- this->hidden->buf_free -= this->hidden->mixlen;
-
- /* Write the audio data */
- NAS_AuWriteElement(this->hidden->aud, this->hidden->flow, 0,
- this->hidden->mixlen, this->hidden->mixbuf, AuFalse,
- NULL);
-
- this->hidden->written += this->hidden->mixlen;
-
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen);
-#endif
-}
-
-static Uint8 *
-NAS_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-static int
-NAS_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- int retval;
-
- while (SDL_TRUE) {
- /* just keep the event queue moving and the server chattering. */
- NAS_AuHandleEvents(h->aud);
-
- retval = (int) NAS_AuReadElement(h->aud, h->flow, 1, buflen, buffer, NULL);
- /*printf("read %d capture bytes\n", (int) retval);*/
- if (retval == 0) {
- SDL_Delay(10); /* don't burn the CPU if we're waiting for data. */
- } else {
- break;
- }
- }
-
- return retval;
-}
-
-static void
-NAS_FlushCapture(_THIS)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- AuUint32 total = 0;
- AuUint32 br;
- Uint8 buf[512];
-
- do {
- /* just keep the event queue moving and the server chattering. */
- NAS_AuHandleEvents(h->aud);
- br = NAS_AuReadElement(h->aud, h->flow, 1, sizeof (buf), buf, NULL);
- /*printf("flushed %d capture bytes\n", (int) br);*/
- total += br;
- } while ((br == sizeof (buf)) && (total < this->spec.size));
-}
-
-static void
-NAS_CloseDevice(_THIS)
-{
- if (this->hidden->aud) {
- NAS_AuCloseServer(this->hidden->aud);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static unsigned char
-sdlformat_to_auformat(unsigned int fmt)
-{
- switch (fmt) {
- case AUDIO_U8:
- return AuFormatLinearUnsigned8;
- case AUDIO_S8:
- return AuFormatLinearSigned8;
- case AUDIO_U16LSB:
- return AuFormatLinearUnsigned16LSB;
- case AUDIO_U16MSB:
- return AuFormatLinearUnsigned16MSB;
- case AUDIO_S16LSB:
- return AuFormatLinearSigned16LSB;
- case AUDIO_S16MSB:
- return AuFormatLinearSigned16MSB;
- }
- return AuNone;
-}
-
-static AuBool
-event_handler(AuServer * aud, AuEvent * ev, AuEventHandlerRec * hnd)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) hnd->data;
- struct SDL_PrivateAudioData *h = this->hidden;
- if (this->iscapture) {
- return AuTrue; /* we don't (currently) care about any of this for capture devices */
- }
-
- switch (ev->type) {
- case AuEventTypeElementNotify:
- {
- AuElementNotifyEvent *event = (AuElementNotifyEvent *) ev;
-
- switch (event->kind) {
- case AuElementNotifyKindLowWater:
- if (h->buf_free >= 0) {
- h->really += event->num_bytes;
- gettimeofday(&h->last_tv, 0);
- h->buf_free += event->num_bytes;
- } else {
- h->buf_free = event->num_bytes;
- }
- break;
- case AuElementNotifyKindState:
- switch (event->cur_state) {
- case AuStatePause:
- if (event->reason != AuReasonUser) {
- if (h->buf_free >= 0) {
- h->really += event->num_bytes;
- gettimeofday(&h->last_tv, 0);
- h->buf_free += event->num_bytes;
- } else {
- h->buf_free = event->num_bytes;
- }
- }
- break;
- }
- }
- }
- }
- return AuTrue;
-}
-
-static AuDeviceID
-find_device(_THIS)
-{
- /* These "Au" things are all macros, not functions... */
- struct SDL_PrivateAudioData *h = this->hidden;
- const unsigned int devicekind = this->iscapture ? AuComponentKindPhysicalInput : AuComponentKindPhysicalOutput;
- const int numdevs = AuServerNumDevices(h->aud);
- const int nch = this->spec.channels;
- int i;
-
- /* Try to find exact match on channels first... */
- for (i = 0; i < numdevs; i++) {
- const AuDeviceAttributes *dev = AuServerDevice(h->aud, i);
- if ((AuDeviceKind(dev) == devicekind) && (AuDeviceNumTracks(dev) == nch)) {
- return AuDeviceIdentifier(dev);
- }
- }
-
- /* Take anything, then... */
- for (i = 0; i < numdevs; i++) {
- const AuDeviceAttributes *dev = AuServerDevice(h->aud, i);
- if (AuDeviceKind(dev) == devicekind) {
- this->spec.channels = AuDeviceNumTracks(dev);
- return AuDeviceIdentifier(dev);
- }
- }
- return AuNone;
-}
-
-static int
-NAS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- AuElement elms[3];
- int buffer_size;
- SDL_AudioFormat test_format, format;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Try for a closest match on audio format */
- format = 0;
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- !format && test_format;) {
- format = sdlformat_to_auformat(test_format);
- if (format == AuNone) {
- test_format = SDL_NextAudioFormat();
- }
- }
- if (format == 0) {
- return SDL_SetError("NAS: Couldn't find any hardware audio formats");
- }
- this->spec.format = test_format;
-
- this->hidden->aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL);
- if (this->hidden->aud == 0) {
- return SDL_SetError("NAS: Couldn't open connection to NAS server");
- }
-
- this->hidden->dev = find_device(this);
- if ((this->hidden->dev == AuNone)
- || (!(this->hidden->flow = NAS_AuCreateFlow(this->hidden->aud, 0)))) {
- return SDL_SetError("NAS: Couldn't find a fitting device on NAS server");
- }
-
- buffer_size = this->spec.freq;
- if (buffer_size < 4096)
- buffer_size = 4096;
-
- if (buffer_size > 32768)
- buffer_size = 32768; /* So that the buffer won't get unmanageably big. */
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- if (iscapture) {
- AuMakeElementImportDevice(elms, this->spec.freq, this->hidden->dev,
- AuUnlimitedSamples, 0, NULL);
- AuMakeElementExportClient(elms + 1, 0, this->spec.freq, format,
- this->spec.channels, AuTrue, buffer_size,
- buffer_size, 0, NULL);
- } else {
- AuMakeElementImportClient(elms, this->spec.freq, format,
- this->spec.channels, AuTrue, buffer_size,
- buffer_size / 4, 0, NULL);
- AuMakeElementExportDevice(elms + 1, 0, this->hidden->dev, this->spec.freq,
- AuUnlimitedSamples, 0, NULL);
- }
-
- NAS_AuSetElements(this->hidden->aud, this->hidden->flow, AuTrue,
- 2, elms, NULL);
-
- NAS_AuRegisterEventHandler(this->hidden->aud, AuEventHandlerIDMask, 0,
- this->hidden->flow, event_handler,
- (AuPointer) this);
-
- NAS_AuStartFlow(this->hidden->aud, this->hidden->flow, NULL);
-
- /* Allocate mixing buffer */
- if (!iscapture) {
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
- }
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-static void
-NAS_Deinitialize(void)
-{
- UnloadNASLibrary();
-}
-
-static int
-NAS_Init(SDL_AudioDriverImpl * impl)
-{
- if (LoadNASLibrary() < 0) {
- return 0;
- } else {
- AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL);
- if (aud == NULL) {
- SDL_SetError("NAS: AuOpenServer() failed (no audio server?)");
- return 0;
- }
- NAS_AuCloseServer(aud);
- }
-
- /* Set the function pointers */
- impl->OpenDevice = NAS_OpenDevice;
- impl->PlayDevice = NAS_PlayDevice;
- impl->WaitDevice = NAS_WaitDevice;
- impl->GetDeviceBuf = NAS_GetDeviceBuf;
- impl->CaptureFromDevice = NAS_CaptureFromDevice;
- impl->FlushCapture = NAS_FlushCapture;
- impl->CloseDevice = NAS_CloseDevice;
- impl->Deinitialize = NAS_Deinitialize;
-
- impl->OnlyHasDefaultOutputDevice = 1;
- impl->OnlyHasDefaultCaptureDevice = 1;
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap NAS_bootstrap = {
- "nas", "Network Audio System", NAS_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_NAS */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/nas/SDL_nasaudio.h b/3rdparty/SDL2/src/audio/nas/SDL_nasaudio.h
deleted file mode 100644
index 2f46b0b6018..00000000000
--- a/3rdparty/SDL2/src/audio/nas/SDL_nasaudio.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_nasaudio_h
-#define _SDL_nasaudio_h
-
-#ifdef __sgi
-#include <nas/audiolib.h>
-#else
-#include <audio/audiolib.h>
-#endif
-#include <sys/time.h>
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- AuServer *aud;
- AuFlowID flow;
- AuDeviceID dev;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-
- int written;
- int really;
- int bps;
- struct timeval last_tv;
- int buf_free;
-};
-#endif /* _SDL_nasaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/paudio/SDL_paudio.c b/3rdparty/SDL2/src/audio/paudio/SDL_paudio.c
deleted file mode 100644
index 57202245f62..00000000000
--- a/3rdparty/SDL2/src/audio/paudio/SDL_paudio.c
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_PAUDIO
-
-/* Allow access to a raw mixing buffer */
-
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "SDL_stdinc.h"
-#include "../SDL_audio_c.h"
-#include "SDL_paudio.h"
-
-#define DEBUG_AUDIO 0
-
-/* A conflict within AIX 4.3.3 <sys/> headers and probably others as well.
- * I guess nobody ever uses audio... Shame over AIX header files. */
-#include <sys/machine.h>
-#undef BIG_ENDIAN
-#include <sys/audio.h>
-
-/* Open the audio device for playback, and don't block if busy */
-/* #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) */
-#define OPEN_FLAGS O_WRONLY
-
-/* Get the name of the audio device we use for output */
-
-#ifndef _PATH_DEV_DSP
-#define _PATH_DEV_DSP "/dev/%caud%c/%c"
-#endif
-
-static char devsettings[][3] = {
- {'p', '0', '1'}, {'p', '0', '2'}, {'p', '0', '3'}, {'p', '0', '4'},
- {'p', '1', '1'}, {'p', '1', '2'}, {'p', '1', '3'}, {'p', '1', '4'},
- {'p', '2', '1'}, {'p', '2', '2'}, {'p', '2', '3'}, {'p', '2', '4'},
- {'p', '3', '1'}, {'p', '3', '2'}, {'p', '3', '3'}, {'p', '3', '4'},
- {'b', '0', '1'}, {'b', '0', '2'}, {'b', '0', '3'}, {'b', '0', '4'},
- {'b', '1', '1'}, {'b', '1', '2'}, {'b', '1', '3'}, {'b', '1', '4'},
- {'b', '2', '1'}, {'b', '2', '2'}, {'b', '2', '3'}, {'b', '2', '4'},
- {'b', '3', '1'}, {'b', '3', '2'}, {'b', '3', '3'}, {'b', '3', '4'},
- {'\0', '\0', '\0'}
-};
-
-static int
-OpenUserDefinedDevice(char *path, int maxlen, int flags)
-{
- const char *audiodev;
- int fd;
-
- /* Figure out what our audio device is */
- if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) {
- audiodev = SDL_getenv("AUDIODEV");
- }
- if (audiodev == NULL) {
- return -1;
- }
- fd = open(audiodev, flags, 0);
- if (path != NULL) {
- SDL_strlcpy(path, audiodev, maxlen);
- path[maxlen - 1] = '\0';
- }
- return fd;
-}
-
-static int
-OpenAudioPath(char *path, int maxlen, int flags, int classic)
-{
- struct stat sb;
- int cycle = 0;
- int fd = OpenUserDefinedDevice(path, maxlen, flags);
-
- if (fd != -1) {
- return fd;
- }
-
- /* !!! FIXME: do we really need a table here? */
- while (devsettings[cycle][0] != '\0') {
- char audiopath[1024];
- SDL_snprintf(audiopath, SDL_arraysize(audiopath),
- _PATH_DEV_DSP,
- devsettings[cycle][0],
- devsettings[cycle][1], devsettings[cycle][2]);
-
- if (stat(audiopath, &sb) == 0) {
- fd = open(audiopath, flags, 0);
- if (fd >= 0) {
- if (path != NULL) {
- SDL_strlcpy(path, audiopath, maxlen);
- }
- return fd;
- }
- }
- }
- return -1;
-}
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-PAUDIO_WaitDevice(_THIS)
-{
- fd_set fdset;
-
- /* See if we need to use timed audio synchronization */
- if (this->hidden->frame_ticks) {
- /* Use timer for general audio synchronization */
- Sint32 ticks;
-
- ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
- if (ticks > 0) {
- SDL_Delay(ticks);
- }
- } else {
- audio_buffer paud_bufinfo;
-
- /* Use select() for audio synchronization */
- struct timeval timeout;
- FD_ZERO(&fdset);
- FD_SET(this->hidden->audio_fd, &fdset);
-
- if (ioctl(this->hidden->audio_fd, AUDIO_BUFFER, &paud_bufinfo) < 0) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Couldn't get audio buffer information\n");
-#endif
- timeout.tv_sec = 10;
- timeout.tv_usec = 0;
- } else {
- long ms_in_buf = paud_bufinfo.write_buf_time;
- timeout.tv_sec = ms_in_buf / 1000;
- ms_in_buf = ms_in_buf - timeout.tv_sec * 1000;
- timeout.tv_usec = ms_in_buf * 1000;
-#ifdef DEBUG_AUDIO
- fprintf(stderr,
- "Waiting for write_buf_time=%ld,%ld\n",
- timeout.tv_sec, timeout.tv_usec);
-#endif
- }
-
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Waiting for audio to get ready\n");
-#endif
- if (select(this->hidden->audio_fd + 1, NULL, &fdset, NULL, &timeout)
- <= 0) {
- const char *message =
- "Audio timeout - buggy audio driver? (disabled)";
- /*
- * In general we should never print to the screen,
- * but in this case we have no other way of letting
- * the user know what happened.
- */
- fprintf(stderr, "SDL: %s - %s\n", strerror(errno), message);
- SDL_OpenedAudioDeviceDisconnected(this);
- /* Don't try to close - may hang */
- this->hidden->audio_fd = -1;
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Done disabling audio\n");
-#endif
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Ready!\n");
-#endif
- }
-}
-
-static void
-PAUDIO_PlayDevice(_THIS)
-{
- int written = 0;
- const Uint8 *mixbuf = this->hidden->mixbuf;
- const size_t mixlen = this->hidden->mixlen;
-
- /* Write the audio data, checking for EAGAIN on broken audio drivers */
- do {
- written = write(this->hidden->audio_fd, mixbuf, mixlen);
- if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
- SDL_Delay(1); /* Let a little CPU time go by */
- }
- } while ((written < 0) &&
- ((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
-
- /* If timer synchronization is enabled, set the next write frame */
- if (this->hidden->frame_ticks) {
- this->hidden->next_frame += this->hidden->frame_ticks;
- }
-
- /* If we couldn't write, assume fatal error for now */
- if (written < 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", written);
-#endif
-}
-
-static Uint8 *
-PAUDIO_GetDeviceBuf(_THIS)
-{
- return this->hidden->mixbuf;
-}
-
-static void
-PAUDIO_CloseDevice(_THIS)
-{
- if (this->hidden->audio_fd >= 0) {
- close(this->hidden->audio_fd);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-PAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- const char *workaround = SDL_getenv("SDL_DSP_NOSELECT");
- char audiodev[1024];
- const char *err = NULL;
- int format;
- int bytes_per_sample;
- SDL_AudioFormat test_format;
- audio_init paud_init;
- audio_buffer paud_bufinfo;
- audio_status paud_status;
- audio_control paud_control;
- audio_change paud_change;
- int fd = -1;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Open the audio device */
- fd = OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
- this->hidden->audio_fd = fd;
- if (fd < 0) {
- return SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
- }
-
- /*
- * We can't set the buffer size - just ask the device for the maximum
- * that we can have.
- */
- if (ioctl(fd, AUDIO_BUFFER, &paud_bufinfo) < 0) {
- return SDL_SetError("Couldn't get audio buffer information");
- }
-
- if (this->spec.channels > 1)
- this->spec.channels = 2;
- else
- this->spec.channels = 1;
-
- /*
- * Fields in the audio_init structure:
- *
- * Ignored by us:
- *
- * paud.loadpath[LOAD_PATH]; * DSP code to load, MWave chip only?
- * paud.slot_number; * slot number of the adapter
- * paud.device_id; * adapter identification number
- *
- * Input:
- *
- * paud.srate; * the sampling rate in Hz
- * paud.bits_per_sample; * 8, 16, 32, ...
- * paud.bsize; * block size for this rate
- * paud.mode; * ADPCM, PCM, MU_LAW, A_LAW, SOURCE_MIX
- * paud.channels; * 1=mono, 2=stereo
- * paud.flags; * FIXED - fixed length data
- * * LEFT_ALIGNED, RIGHT_ALIGNED (var len only)
- * * TWOS_COMPLEMENT - 2's complement data
- * * SIGNED - signed? comment seems wrong in sys/audio.h
- * * BIG_ENDIAN
- * paud.operation; * PLAY, RECORD
- *
- * Output:
- *
- * paud.flags; * PITCH - pitch is supported
- * * INPUT - input is supported
- * * OUTPUT - output is supported
- * * MONITOR - monitor is supported
- * * VOLUME - volume is supported
- * * VOLUME_DELAY - volume delay is supported
- * * BALANCE - balance is supported
- * * BALANCE_DELAY - balance delay is supported
- * * TREBLE - treble control is supported
- * * BASS - bass control is supported
- * * BESTFIT_PROVIDED - best fit returned
- * * LOAD_CODE - DSP load needed
- * paud.rc; * NO_PLAY - DSP code can't do play requests
- * * NO_RECORD - DSP code can't do record requests
- * * INVALID_REQUEST - request was invalid
- * * CONFLICT - conflict with open's flags
- * * OVERLOADED - out of DSP MIPS or memory
- * paud.position_resolution; * smallest increment for position
- */
-
- paud_init.srate = this->spec.freq;
- paud_init.mode = PCM;
- paud_init.operation = PLAY;
- paud_init.channels = this->spec.channels;
-
- /* Try for a closest match on audio format */
- format = 0;
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- !format && test_format;) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
-#endif
- switch (test_format) {
- case AUDIO_U8:
- bytes_per_sample = 1;
- paud_init.bits_per_sample = 8;
- paud_init.flags = TWOS_COMPLEMENT | FIXED;
- format = 1;
- break;
- case AUDIO_S8:
- bytes_per_sample = 1;
- paud_init.bits_per_sample = 8;
- paud_init.flags = SIGNED | TWOS_COMPLEMENT | FIXED;
- format = 1;
- break;
- case AUDIO_S16LSB:
- bytes_per_sample = 2;
- paud_init.bits_per_sample = 16;
- paud_init.flags = SIGNED | TWOS_COMPLEMENT | FIXED;
- format = 1;
- break;
- case AUDIO_S16MSB:
- bytes_per_sample = 2;
- paud_init.bits_per_sample = 16;
- paud_init.flags = BIG_ENDIAN | SIGNED | TWOS_COMPLEMENT | FIXED;
- format = 1;
- break;
- case AUDIO_U16LSB:
- bytes_per_sample = 2;
- paud_init.bits_per_sample = 16;
- paud_init.flags = TWOS_COMPLEMENT | FIXED;
- format = 1;
- break;
- case AUDIO_U16MSB:
- bytes_per_sample = 2;
- paud_init.bits_per_sample = 16;
- paud_init.flags = BIG_ENDIAN | TWOS_COMPLEMENT | FIXED;
- format = 1;
- break;
- default:
- break;
- }
- if (!format) {
- test_format = SDL_NextAudioFormat();
- }
- }
- if (format == 0) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Couldn't find any hardware audio formats\n");
-#endif
- return SDL_SetError("Couldn't find any hardware audio formats");
- }
- this->spec.format = test_format;
-
- /*
- * We know the buffer size and the max number of subsequent writes
- * that can be pending. If more than one can pend, allow the application
- * to do something like double buffering between our write buffer and
- * the device's own buffer that we are filling with write() anyway.
- *
- * We calculate this->spec.samples like this because
- * SDL_CalculateAudioSpec() will give put paud_bufinfo.write_buf_cap
- * (or paud_bufinfo.write_buf_cap/2) into this->spec.size in return.
- */
- if (paud_bufinfo.request_buf_cap == 1) {
- this->spec.samples = paud_bufinfo.write_buf_cap
- / bytes_per_sample / this->spec.channels;
- } else {
- this->spec.samples = paud_bufinfo.write_buf_cap
- / bytes_per_sample / this->spec.channels / 2;
- }
- paud_init.bsize = bytes_per_sample * this->spec.channels;
-
- SDL_CalculateAudioSpec(&this->spec);
-
- /*
- * The AIX paud device init can't modify the values of the audio_init
- * structure that we pass to it. So we don't need any recalculation
- * of this stuff and no reinit call as in linux dsp code.
- *
- * /dev/paud supports all of the encoding formats, so we don't need
- * to do anything like reopening the device, either.
- */
- if (ioctl(fd, AUDIO_INIT, &paud_init) < 0) {
- switch (paud_init.rc) {
- case 1:
- err = "Couldn't set audio format: DSP can't do play requests";
- break;
- case 2:
- err = "Couldn't set audio format: DSP can't do record requests";
- break;
- case 4:
- err = "Couldn't set audio format: request was invalid";
- break;
- case 5:
- err = "Couldn't set audio format: conflict with open's flags";
- break;
- case 6:
- err = "Couldn't set audio format: out of DSP MIPS or memory";
- break;
- default:
- err = "Couldn't set audio format: not documented in sys/audio.h";
- break;
- }
- }
-
- if (err != NULL) {
- return SDL_SetError("Paudio: %s", err);
- }
-
- /* Allocate mixing buffer */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
-
- /*
- * Set some paramters: full volume, first speaker that we can find.
- * Ignore the other settings for now.
- */
- paud_change.input = AUDIO_IGNORE; /* the new input source */
- paud_change.output = OUTPUT_1; /* EXTERNAL_SPEAKER,INTERNAL_SPEAKER,OUTPUT_1 */
- paud_change.monitor = AUDIO_IGNORE; /* the new monitor state */
- paud_change.volume = 0x7fffffff; /* volume level [0-0x7fffffff] */
- paud_change.volume_delay = AUDIO_IGNORE; /* the new volume delay */
- paud_change.balance = 0x3fffffff; /* the new balance */
- paud_change.balance_delay = AUDIO_IGNORE; /* the new balance delay */
- paud_change.treble = AUDIO_IGNORE; /* the new treble state */
- paud_change.bass = AUDIO_IGNORE; /* the new bass state */
- paud_change.pitch = AUDIO_IGNORE; /* the new pitch state */
-
- paud_control.ioctl_request = AUDIO_CHANGE;
- paud_control.request_info = (char *) &paud_change;
- if (ioctl(fd, AUDIO_CONTROL, &paud_control) < 0) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Can't change audio display settings\n");
-#endif
- }
-
- /*
- * Tell the device to expect data. Actual start will wait for
- * the first write() call.
- */
- paud_control.ioctl_request = AUDIO_START;
- paud_control.position = 0;
- if (ioctl(fd, AUDIO_CONTROL, &paud_control) < 0) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Can't start audio play\n");
-#endif
- return SDL_SetError("Can't start audio play");
- }
-
- /* Check to see if we need to use select() workaround */
- if (workaround != NULL) {
- this->hidden->frame_ticks = (float) (this->spec.samples * 1000) /
- this->spec.freq;
- this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks;
- }
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-static int
-PAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* !!! FIXME: not right for device enum? */
- int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
- if (fd < 0) {
- SDL_SetError("PAUDIO: Couldn't open audio device");
- return 0;
- }
- close(fd);
-
- /* Set the function pointers */
- impl->OpenDevice = DSP_OpenDevice;
- impl->PlayDevice = DSP_PlayDevice;
- impl->PlayDevice = DSP_WaitDevice;
- impl->GetDeviceBuf = DSP_GetDeviceBuf;
- impl->CloseDevice = DSP_CloseDevice;
- impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap PAUDIO_bootstrap = {
- "paud", "AIX Paudio", PAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_PAUDIO */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/paudio/SDL_paudio.h b/3rdparty/SDL2/src/audio/paudio/SDL_paudio.h
deleted file mode 100644
index ebc8bb5b1bf..00000000000
--- a/3rdparty/SDL2/src/audio/paudio/SDL_paudio.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_paudaudio_h
-#define _SDL_paudaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The file descriptor for the audio device */
- int audio_fd;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-
- /* Support for audio timing using a timer, in addition to select() */
- float frame_ticks;
- float next_frame;
-};
-#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */
-
-#endif /* _SDL_paudaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/psp/SDL_pspaudio.c b/3rdparty/SDL2/src/audio/psp/SDL_pspaudio.c
deleted file mode 100644
index bd3456d3ff7..00000000000
--- a/3rdparty/SDL2/src/audio/psp/SDL_pspaudio.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_PSP
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <malloc.h>
-
-#include "SDL_audio.h"
-#include "SDL_error.h"
-#include "SDL_timer.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_audiodev_c.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_pspaudio.h"
-
-#include <pspaudio.h>
-#include <pspthreadman.h>
-
-/* The tag name used by PSP audio */
-#define PSPAUDIO_DRIVER_NAME "psp"
-
-static int
-PSPAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- int format, mixlen, i;
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc(sizeof(*this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
- switch (this->spec.format & 0xff) {
- case 8:
- case 16:
- this->spec.format = AUDIO_S16LSB;
- break;
- default:
- return SDL_SetError("Unsupported audio format");
- }
-
- /* The sample count must be a multiple of 64. */
- this->spec.samples = PSP_AUDIO_SAMPLE_ALIGN(this->spec.samples);
- this->spec.freq = 44100;
-
- /* Update the fragment size as size in bytes. */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate the mixing buffer. Its size and starting address must
- be a multiple of 64 bytes. Our sample count is already a multiple of
- 64, so spec->size should be a multiple of 64 as well. */
- mixlen = this->spec.size * NUM_BUFFERS;
- this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen);
- if (this->hidden->rawbuf == NULL) {
- return SDL_SetError("Couldn't allocate mixing buffer");
- }
-
- /* Setup the hardware channel. */
- if (this->spec.channels == 1) {
- format = PSP_AUDIO_FORMAT_MONO;
- } else {
- format = PSP_AUDIO_FORMAT_STEREO;
- }
- this->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, this->spec.samples, format);
- if (this->hidden->channel < 0) {
- free(this->hidden->rawbuf);
- this->hidden->rawbuf = NULL;
- return SDL_SetError("Couldn't reserve hardware channel");
- }
-
- memset(this->hidden->rawbuf, 0, mixlen);
- for (i = 0; i < NUM_BUFFERS; i++) {
- this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size];
- }
-
- this->hidden->next_buffer = 0;
- return 0;
-}
-
-static void PSPAUDIO_PlayDevice(_THIS)
-{
- Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer];
-
- if (this->spec.channels == 1) {
- sceAudioOutputBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, mixbuf);
- } else {
- sceAudioOutputPannedBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, mixbuf);
- }
-
- this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS;
-}
-
-/* This function waits until it is possible to write a full sound buffer */
-static void PSPAUDIO_WaitDevice(_THIS)
-{
- /* Because we block when sending audio, there's no need for this function to do anything. */
-}
-static Uint8 *PSPAUDIO_GetDeviceBuf(_THIS)
-{
- return this->hidden->mixbufs[this->hidden->next_buffer];
-}
-
-static void PSPAUDIO_CloseDevice(_THIS)
-{
- if (this->hidden->channel >= 0) {
- sceAudioChRelease(this->hidden->channel);
- }
- free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */
- SDL_free(this->hidden);
-}
-
-static void PSPAUDIO_ThreadInit(_THIS)
-{
- /* Increase the priority of this audio thread by 1 to put it
- ahead of other SDL threads. */
- SceUID thid;
- SceKernelThreadInfo status;
- thid = sceKernelGetThreadId();
- status.size = sizeof(SceKernelThreadInfo);
- if (sceKernelReferThreadStatus(thid, &status) == 0) {
- sceKernelChangeThreadPriority(thid, status.currentPriority - 1);
- }
-}
-
-
-static int
-PSPAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->OpenDevice = PSPAUDIO_OpenDevice;
- impl->PlayDevice = PSPAUDIO_PlayDevice;
- impl->WaitDevice = PSPAUDIO_WaitDevice;
- impl->GetDeviceBuf = PSPAUDIO_GetDeviceBuf;
- impl->CloseDevice = PSPAUDIO_CloseDevice;
- impl->ThreadInit = PSPAUDIO_ThreadInit;
-
- /* PSP audio device */
- impl->OnlyHasDefaultOutputDevice = 1;
-/*
- impl->HasCaptureSupport = 1;
-
- impl->OnlyHasDefaultCaptureDevice = 1;
-*/
- /*
- impl->DetectDevices = DSOUND_DetectDevices;
- impl->Deinitialize = DSOUND_Deinitialize;
- */
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap PSPAUDIO_bootstrap = {
- "psp", "PSP audio driver", PSPAUDIO_Init, 0
-};
-
- /* SDL_AUDI */
-
-#endif /* SDL_AUDIO_DRIVER_PSP */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/psp/SDL_pspaudio.h b/3rdparty/SDL2/src/audio/psp/SDL_pspaudio.h
deleted file mode 100644
index 6b266bd0cce..00000000000
--- a/3rdparty/SDL2/src/audio/psp/SDL_pspaudio.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#ifndef _SDL_pspaudio_h
-#define _SDL_pspaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-#define NUM_BUFFERS 2
-
-struct SDL_PrivateAudioData {
- /* The hardware output channel. */
- int channel;
- /* The raw allocated mixing buffer. */
- Uint8 *rawbuf;
- /* Individual mixing buffers. */
- Uint8 *mixbufs[NUM_BUFFERS];
- /* Index of the next available mixing buffer. */
- int next_buffer;
-};
-
-#endif /* _SDL_pspaudio_h */
-/* vim: ts=4 sw=4
- */
diff --git a/3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.c b/3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.c
deleted file mode 100644
index 9ced49d210f..00000000000
--- a/3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.c
+++ /dev/null
@@ -1,772 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-/*
- The PulseAudio target for SDL 1.3 is based on the 1.3 arts target, with
- the appropriate parts replaced with the 1.2 PulseAudio target code. This
- was the cleanest way to move it to 1.3. The 1.2 target was written by
- Stéphan Kochen: stephan .a.t. kochen.nl
-*/
-#include "../../SDL_internal.h"
-#include "SDL_assert.h"
-
-#if SDL_AUDIO_DRIVER_PULSEAUDIO
-
-/* Allow access to a raw mixing buffer */
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <pulse/pulseaudio.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_pulseaudio.h"
-#include "SDL_loadso.h"
-#include "../../thread/SDL_systhread.h"
-
-#if (PA_API_VERSION < 12)
-/** Return non-zero if the passed state is one of the connected states */
-static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
- return
- x == PA_CONTEXT_CONNECTING ||
- x == PA_CONTEXT_AUTHORIZING ||
- x == PA_CONTEXT_SETTING_NAME ||
- x == PA_CONTEXT_READY;
-}
-/** Return non-zero if the passed state is one of the connected states */
-static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
- return
- x == PA_STREAM_CREATING ||
- x == PA_STREAM_READY;
-}
-#endif /* pulseaudio <= 0.9.10 */
-
-
-static const char *(*PULSEAUDIO_pa_get_library_version) (void);
-static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto) (
- pa_channel_map *, unsigned, pa_channel_map_def_t);
-static const char * (*PULSEAUDIO_pa_strerror) (int);
-static pa_mainloop * (*PULSEAUDIO_pa_mainloop_new) (void);
-static pa_mainloop_api * (*PULSEAUDIO_pa_mainloop_get_api) (pa_mainloop *);
-static int (*PULSEAUDIO_pa_mainloop_iterate) (pa_mainloop *, int, int *);
-static int (*PULSEAUDIO_pa_mainloop_run) (pa_mainloop *, int *);
-static void (*PULSEAUDIO_pa_mainloop_quit) (pa_mainloop *, int);
-static void (*PULSEAUDIO_pa_mainloop_free) (pa_mainloop *);
-
-static pa_operation_state_t (*PULSEAUDIO_pa_operation_get_state) (
- pa_operation *);
-static void (*PULSEAUDIO_pa_operation_cancel) (pa_operation *);
-static void (*PULSEAUDIO_pa_operation_unref) (pa_operation *);
-
-static pa_context * (*PULSEAUDIO_pa_context_new) (pa_mainloop_api *,
- const char *);
-static int (*PULSEAUDIO_pa_context_connect) (pa_context *, const char *,
- pa_context_flags_t, const pa_spawn_api *);
-static pa_operation * (*PULSEAUDIO_pa_context_get_sink_info_list) (pa_context *, pa_sink_info_cb_t, void *);
-static pa_operation * (*PULSEAUDIO_pa_context_get_source_info_list) (pa_context *, pa_source_info_cb_t, void *);
-static pa_operation * (*PULSEAUDIO_pa_context_get_sink_info_by_index) (pa_context *, uint32_t, pa_sink_info_cb_t, void *);
-static pa_operation * (*PULSEAUDIO_pa_context_get_source_info_by_index) (pa_context *, uint32_t, pa_source_info_cb_t, void *);
-static pa_context_state_t (*PULSEAUDIO_pa_context_get_state) (pa_context *);
-static pa_operation * (*PULSEAUDIO_pa_context_subscribe) (pa_context *, pa_subscription_mask_t, pa_context_success_cb_t, void *);
-static void (*PULSEAUDIO_pa_context_set_subscribe_callback) (pa_context *, pa_context_subscribe_cb_t, void *);
-static void (*PULSEAUDIO_pa_context_disconnect) (pa_context *);
-static void (*PULSEAUDIO_pa_context_unref) (pa_context *);
-
-static pa_stream * (*PULSEAUDIO_pa_stream_new) (pa_context *, const char *,
- const pa_sample_spec *, const pa_channel_map *);
-static int (*PULSEAUDIO_pa_stream_connect_playback) (pa_stream *, const char *,
- const pa_buffer_attr *, pa_stream_flags_t, pa_cvolume *, pa_stream *);
-static int (*PULSEAUDIO_pa_stream_connect_record) (pa_stream *, const char *,
- const pa_buffer_attr *, pa_stream_flags_t);
-static pa_stream_state_t (*PULSEAUDIO_pa_stream_get_state) (pa_stream *);
-static size_t (*PULSEAUDIO_pa_stream_writable_size) (pa_stream *);
-static size_t (*PULSEAUDIO_pa_stream_readable_size) (pa_stream *);
-static int (*PULSEAUDIO_pa_stream_write) (pa_stream *, const void *, size_t,
- pa_free_cb_t, int64_t, pa_seek_mode_t);
-static pa_operation * (*PULSEAUDIO_pa_stream_drain) (pa_stream *,
- pa_stream_success_cb_t, void *);
-static int (*PULSEAUDIO_pa_stream_peek) (pa_stream *, const void **, size_t *);
-static int (*PULSEAUDIO_pa_stream_drop) (pa_stream *);
-static pa_operation * (*PULSEAUDIO_pa_stream_flush) (pa_stream *,
- pa_stream_success_cb_t, void *);
-static int (*PULSEAUDIO_pa_stream_disconnect) (pa_stream *);
-static void (*PULSEAUDIO_pa_stream_unref) (pa_stream *);
-
-static int load_pulseaudio_syms(void);
-
-
-#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
-
-static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC;
-static void *pulseaudio_handle = NULL;
-
-static int
-load_pulseaudio_sym(const char *fn, void **addr)
-{
- *addr = SDL_LoadFunction(pulseaudio_handle, fn);
- if (*addr == NULL) {
- /* Don't call SDL_SetError(): SDL_LoadFunction already did. */
- return 0;
- }
-
- return 1;
-}
-
-/* cast funcs to char* first, to please GCC's strict aliasing rules. */
-#define SDL_PULSEAUDIO_SYM(x) \
- if (!load_pulseaudio_sym(#x, (void **) (char *) &PULSEAUDIO_##x)) return -1
-
-static void
-UnloadPulseAudioLibrary(void)
-{
- if (pulseaudio_handle != NULL) {
- SDL_UnloadObject(pulseaudio_handle);
- pulseaudio_handle = NULL;
- }
-}
-
-static int
-LoadPulseAudioLibrary(void)
-{
- int retval = 0;
- if (pulseaudio_handle == NULL) {
- pulseaudio_handle = SDL_LoadObject(pulseaudio_library);
- if (pulseaudio_handle == NULL) {
- retval = -1;
- /* Don't call SDL_SetError(): SDL_LoadObject already did. */
- } else {
- retval = load_pulseaudio_syms();
- if (retval < 0) {
- UnloadPulseAudioLibrary();
- }
- }
- }
- return retval;
-}
-
-#else
-
-#define SDL_PULSEAUDIO_SYM(x) PULSEAUDIO_##x = x
-
-static void
-UnloadPulseAudioLibrary(void)
-{
-}
-
-static int
-LoadPulseAudioLibrary(void)
-{
- load_pulseaudio_syms();
- return 0;
-}
-
-#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
-
-
-static int
-load_pulseaudio_syms(void)
-{
- SDL_PULSEAUDIO_SYM(pa_get_library_version);
- SDL_PULSEAUDIO_SYM(pa_mainloop_new);
- SDL_PULSEAUDIO_SYM(pa_mainloop_get_api);
- SDL_PULSEAUDIO_SYM(pa_mainloop_iterate);
- SDL_PULSEAUDIO_SYM(pa_mainloop_run);
- SDL_PULSEAUDIO_SYM(pa_mainloop_quit);
- SDL_PULSEAUDIO_SYM(pa_mainloop_free);
- SDL_PULSEAUDIO_SYM(pa_operation_get_state);
- SDL_PULSEAUDIO_SYM(pa_operation_cancel);
- SDL_PULSEAUDIO_SYM(pa_operation_unref);
- SDL_PULSEAUDIO_SYM(pa_context_new);
- SDL_PULSEAUDIO_SYM(pa_context_connect);
- SDL_PULSEAUDIO_SYM(pa_context_get_sink_info_list);
- SDL_PULSEAUDIO_SYM(pa_context_get_source_info_list);
- SDL_PULSEAUDIO_SYM(pa_context_get_sink_info_by_index);
- SDL_PULSEAUDIO_SYM(pa_context_get_source_info_by_index);
- SDL_PULSEAUDIO_SYM(pa_context_get_state);
- SDL_PULSEAUDIO_SYM(pa_context_subscribe);
- SDL_PULSEAUDIO_SYM(pa_context_set_subscribe_callback);
- SDL_PULSEAUDIO_SYM(pa_context_disconnect);
- SDL_PULSEAUDIO_SYM(pa_context_unref);
- SDL_PULSEAUDIO_SYM(pa_stream_new);
- SDL_PULSEAUDIO_SYM(pa_stream_connect_playback);
- SDL_PULSEAUDIO_SYM(pa_stream_connect_record);
- SDL_PULSEAUDIO_SYM(pa_stream_get_state);
- SDL_PULSEAUDIO_SYM(pa_stream_writable_size);
- SDL_PULSEAUDIO_SYM(pa_stream_readable_size);
- SDL_PULSEAUDIO_SYM(pa_stream_write);
- SDL_PULSEAUDIO_SYM(pa_stream_drain);
- SDL_PULSEAUDIO_SYM(pa_stream_disconnect);
- SDL_PULSEAUDIO_SYM(pa_stream_peek);
- SDL_PULSEAUDIO_SYM(pa_stream_drop);
- SDL_PULSEAUDIO_SYM(pa_stream_flush);
- SDL_PULSEAUDIO_SYM(pa_stream_unref);
- SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto);
- SDL_PULSEAUDIO_SYM(pa_strerror);
- return 0;
-}
-
-static SDL_INLINE int
-squashVersion(const int major, const int minor, const int patch)
-{
- return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF);
-}
-
-/* Workaround for older pulse: pa_context_new() must have non-NULL appname */
-static const char *
-getAppName(void)
-{
- const char *verstr = PULSEAUDIO_pa_get_library_version();
- if (verstr != NULL) {
- int maj, min, patch;
- if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) {
- if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) {
- return NULL; /* 0.9.15+ handles NULL correctly. */
- }
- }
- }
- return "SDL Application"; /* oh well. */
-}
-
-static void
-stream_operation_complete_no_op(pa_stream *s, int success, void *userdata)
-{
- /* no-op for pa_stream_drain(), etc, to use for callback. */
-}
-
-static void
-WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
-{
- /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */
- if (mainloop && o) {
- SDL_bool okay = SDL_TRUE;
- while (okay && (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING)) {
- okay = (PULSEAUDIO_pa_mainloop_iterate(mainloop, 1, NULL) >= 0);
- }
- PULSEAUDIO_pa_operation_unref(o);
- }
-}
-
-static void
-DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
-{
- if (context) {
- PULSEAUDIO_pa_context_disconnect(context);
- PULSEAUDIO_pa_context_unref(context);
- }
- if (mainloop != NULL) {
- PULSEAUDIO_pa_mainloop_free(mainloop);
- }
-}
-
-static int
-ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
-{
- pa_mainloop *mainloop = NULL;
- pa_context *context = NULL;
- pa_mainloop_api *mainloop_api = NULL;
- int state = 0;
-
- *_mainloop = NULL;
- *_context = NULL;
-
- /* Set up a new main loop */
- if (!(mainloop = PULSEAUDIO_pa_mainloop_new())) {
- return SDL_SetError("pa_mainloop_new() failed");
- }
-
- *_mainloop = mainloop;
-
- mainloop_api = PULSEAUDIO_pa_mainloop_get_api(mainloop);
- SDL_assert(mainloop_api); /* this never fails, right? */
-
- context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName());
- if (!context) {
- return SDL_SetError("pa_context_new() failed");
- }
- *_context = context;
-
- /* Connect to the PulseAudio server */
- if (PULSEAUDIO_pa_context_connect(context, NULL, 0, NULL) < 0) {
- return SDL_SetError("Could not setup connection to PulseAudio");
- }
-
- do {
- if (PULSEAUDIO_pa_mainloop_iterate(mainloop, 1, NULL) < 0) {
- return SDL_SetError("pa_mainloop_iterate() failed");
- }
- state = PULSEAUDIO_pa_context_get_state(context);
- if (!PA_CONTEXT_IS_GOOD(state)) {
- return SDL_SetError("Could not connect to PulseAudio");
- }
- } while (state != PA_CONTEXT_READY);
-
- return 0; /* connected and ready! */
-}
-
-static int
-ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
-{
- const int retval = ConnectToPulseServer_Internal(_mainloop, _context);
- if (retval < 0) {
- DisconnectFromPulseServer(*_mainloop, *_context);
- }
- return retval;
-}
-
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-PULSEAUDIO_WaitDevice(_THIS)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
-
- while (SDL_AtomicGet(&this->enabled)) {
- if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY ||
- PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY ||
- PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- return;
- }
- if (PULSEAUDIO_pa_stream_writable_size(h->stream) >= h->mixlen) {
- return;
- }
- }
-}
-
-static void
-PULSEAUDIO_PlayDevice(_THIS)
-{
- /* Write the audio data */
- struct SDL_PrivateAudioData *h = this->hidden;
- if (SDL_AtomicGet(&this->enabled)) {
- if (PULSEAUDIO_pa_stream_write(h->stream, h->mixbuf, h->mixlen, NULL, 0LL, PA_SEEK_RELATIVE) < 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
- }
-}
-
-static Uint8 *
-PULSEAUDIO_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-
-static int
-PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
- const void *data = NULL;
- size_t nbytes = 0;
-
- while (SDL_AtomicGet(&this->enabled)) {
- if (h->capturebuf != NULL) {
- const int cpy = SDL_min(buflen, h->capturelen);
- SDL_memcpy(buffer, h->capturebuf, cpy);
- /*printf("PULSEAUDIO: fed %d captured bytes\n", cpy);*/
- h->capturebuf += cpy;
- h->capturelen -= cpy;
- if (h->capturelen == 0) {
- h->capturebuf = NULL;
- PULSEAUDIO_pa_stream_drop(h->stream); /* done with this fragment. */
- }
- return cpy; /* new data, return it. */
- }
-
- if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY ||
- PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY ||
- PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- return -1; /* uhoh, pulse failed! */
- }
-
- if (PULSEAUDIO_pa_stream_readable_size(h->stream) == 0) {
- continue; /* no data available yet. */
- }
-
- /* a new fragment is available! */
- PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
- SDL_assert(nbytes > 0);
- if (data == NULL) { /* NULL==buffer had a hole. Ignore that. */
- PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
- } else {
- /* store this fragment's data, start feeding it to SDL. */
- /*printf("PULSEAUDIO: captured %d new bytes\n", (int) nbytes);*/
- h->capturebuf = (const Uint8 *) data;
- h->capturelen = nbytes;
- }
- }
-
- return -1; /* not enabled? */
-}
-
-static void
-PULSEAUDIO_FlushCapture(_THIS)
-{
- struct SDL_PrivateAudioData *h = this->hidden;
-
- if (h->capturebuf != NULL) {
- PULSEAUDIO_pa_stream_drop(h->stream);
- h->capturebuf = NULL;
- h->capturelen = 0;
- }
-
- WaitForPulseOperation(h->mainloop, PULSEAUDIO_pa_stream_flush(h->stream, stream_operation_complete_no_op, NULL));
-}
-
-static void
-PULSEAUDIO_CloseDevice(_THIS)
-{
- if (this->hidden->stream) {
- if (this->hidden->capturebuf != NULL) {
- PULSEAUDIO_pa_stream_drop(this->hidden->stream);
- }
- PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
- PULSEAUDIO_pa_stream_unref(this->hidden->stream);
- }
-
- DisconnectFromPulseServer(this->hidden->mainloop, this->hidden->context);
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden->device_name);
- SDL_free(this->hidden);
-}
-
-static void
-SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
-{
- if (i) {
- char **devname = (char **) data;
- *devname = SDL_strdup(i->name);
- }
-}
-
-static void
-SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
-{
- if (i) {
- char **devname = (char **) data;
- *devname = SDL_strdup(i->name);
- }
-}
-
-static SDL_bool
-FindDeviceName(struct SDL_PrivateAudioData *h, const int iscapture, void *handle)
-{
- const uint32_t idx = ((uint32_t) ((size_t) handle)) - 1;
-
- if (handle == NULL) { /* NULL == default device. */
- return SDL_TRUE;
- }
-
- if (iscapture) {
- WaitForPulseOperation(h->mainloop,
- PULSEAUDIO_pa_context_get_source_info_by_index(h->context, idx,
- SourceDeviceNameCallback, &h->device_name));
- } else {
- WaitForPulseOperation(h->mainloop,
- PULSEAUDIO_pa_context_get_sink_info_by_index(h->context, idx,
- SinkDeviceNameCallback, &h->device_name));
- }
-
- return (h->device_name != NULL);
-}
-
-static int
-PULSEAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- struct SDL_PrivateAudioData *h = NULL;
- Uint16 test_format = 0;
- pa_sample_spec paspec;
- pa_buffer_attr paattr;
- pa_channel_map pacmap;
- pa_stream_flags_t flags = 0;
- int state = 0;
- int rc = 0;
-
- /* Initialize all variables that we clean on shutdown */
- h = this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- paspec.format = PA_SAMPLE_INVALID;
-
- /* Try for a closest match on audio format */
- for (test_format = SDL_FirstAudioFormat(this->spec.format);
- (paspec.format == PA_SAMPLE_INVALID) && test_format;) {
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
-#endif
- switch (test_format) {
- case AUDIO_U8:
- paspec.format = PA_SAMPLE_U8;
- break;
- case AUDIO_S16LSB:
- paspec.format = PA_SAMPLE_S16LE;
- break;
- case AUDIO_S16MSB:
- paspec.format = PA_SAMPLE_S16BE;
- break;
- case AUDIO_S32LSB:
- paspec.format = PA_SAMPLE_S32LE;
- break;
- case AUDIO_S32MSB:
- paspec.format = PA_SAMPLE_S32BE;
- break;
- case AUDIO_F32LSB:
- paspec.format = PA_SAMPLE_FLOAT32LE;
- break;
- case AUDIO_F32MSB:
- paspec.format = PA_SAMPLE_FLOAT32BE;
- break;
- default:
- paspec.format = PA_SAMPLE_INVALID;
- break;
- }
- if (paspec.format == PA_SAMPLE_INVALID) {
- test_format = SDL_NextAudioFormat();
- }
- }
- if (paspec.format == PA_SAMPLE_INVALID) {
- return SDL_SetError("Couldn't find any hardware audio formats");
- }
- this->spec.format = test_format;
-
- /* Calculate the final parameters for this audio specification */
-#ifdef PA_STREAM_ADJUST_LATENCY
- this->spec.samples /= 2; /* Mix in smaller chunck to avoid underruns */
-#endif
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate mixing buffer */
- if (!iscapture) {
- h->mixlen = this->spec.size;
- h->mixbuf = (Uint8 *) SDL_malloc(h->mixlen);
- if (h->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(h->mixbuf, this->spec.silence, this->spec.size);
- }
-
- paspec.channels = this->spec.channels;
- paspec.rate = this->spec.freq;
-
- /* Reduced prebuffering compared to the defaults. */
-#ifdef PA_STREAM_ADJUST_LATENCY
- /* 2x original requested bufsize */
- paattr.tlength = h->mixlen * 4;
- paattr.prebuf = -1;
- paattr.maxlength = -1;
- /* -1 can lead to pa_stream_writable_size() >= mixlen never being true */
- paattr.minreq = h->mixlen;
- flags = PA_STREAM_ADJUST_LATENCY;
-#else
- paattr.tlength = h->mixlen*2;
- paattr.prebuf = h->mixlen*2;
- paattr.maxlength = h->mixlen*2;
- paattr.minreq = h->mixlen;
-#endif
-
- if (ConnectToPulseServer(&h->mainloop, &h->context) < 0) {
- return SDL_SetError("Could not connect to PulseAudio server");
- }
-
- if (!FindDeviceName(h, iscapture, handle)) {
- return SDL_SetError("Requested PulseAudio sink/source missing?");
- }
-
- /* The SDL ALSA output hints us that we use Windows' channel mapping */
- /* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */
- PULSEAUDIO_pa_channel_map_init_auto(&pacmap, this->spec.channels,
- PA_CHANNEL_MAP_WAVEEX);
-
- h->stream = PULSEAUDIO_pa_stream_new(
- h->context,
- "Simple DirectMedia Layer", /* stream description */
- &paspec, /* sample format spec */
- &pacmap /* channel map */
- );
-
- if (h->stream == NULL) {
- return SDL_SetError("Could not set up PulseAudio stream");
- }
-
- /* now that we have multi-device support, don't move a stream from
- a device that was unplugged to something else, unless we're default. */
- if (h->device_name != NULL) {
- flags |= PA_STREAM_DONT_MOVE;
- }
-
- if (iscapture) {
- rc = PULSEAUDIO_pa_stream_connect_record(h->stream, h->device_name, &paattr, flags);
- } else {
- rc = PULSEAUDIO_pa_stream_connect_playback(h->stream, h->device_name, &paattr, flags, NULL, NULL);
- }
-
- if (rc < 0) {
- return SDL_SetError("Could not connect PulseAudio stream");
- }
-
- do {
- if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
- return SDL_SetError("pa_mainloop_iterate() failed");
- }
- state = PULSEAUDIO_pa_stream_get_state(h->stream);
- if (!PA_STREAM_IS_GOOD(state)) {
- return SDL_SetError("Could not connect PulseAudio stream");
- }
- } while (state != PA_STREAM_READY);
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-static pa_mainloop *hotplug_mainloop = NULL;
-static pa_context *hotplug_context = NULL;
-static SDL_Thread *hotplug_thread = NULL;
-
-/* device handles are device index + 1, cast to void*, so we never pass a NULL. */
-
-/* This is called when PulseAudio adds an output ("sink") device. */
-static void
-SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
-{
- if (i) {
- SDL_AddAudioDevice(SDL_FALSE, i->description, (void *) ((size_t) i->index+1));
- }
-}
-
-/* This is called when PulseAudio adds a capture ("source") device. */
-static void
-SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
-{
- if (i) {
- /* Skip "monitor" sources. These are just output from other sinks. */
- if (i->monitor_of_sink == PA_INVALID_INDEX) {
- SDL_AddAudioDevice(SDL_TRUE, i->description, (void *) ((size_t) i->index+1));
- }
- }
-}
-
-/* This is called when PulseAudio has a device connected/removed/changed. */
-static void
-HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data)
-{
- const SDL_bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW);
- const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE);
-
- if (added || removed) { /* we only care about add/remove events. */
- const SDL_bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK);
- const SDL_bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE);
-
- /* adds need sink details from the PulseAudio server. Another callback... */
- if (added && sink) {
- PULSEAUDIO_pa_context_get_sink_info_by_index(hotplug_context, idx, SinkInfoCallback, NULL);
- } else if (added && source) {
- PULSEAUDIO_pa_context_get_source_info_by_index(hotplug_context, idx, SourceInfoCallback, NULL);
- } else if (removed && (sink || source)) {
- /* removes we can handle just with the device index. */
- SDL_RemoveAudioDevice(source != 0, (void *) ((size_t) idx+1));
- }
- }
-}
-
-/* this runs as a thread while the Pulse target is initialized to catch hotplug events. */
-static int SDLCALL
-HotplugThread(void *data)
-{
- pa_operation *o;
- SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
- PULSEAUDIO_pa_context_set_subscribe_callback(hotplug_context, HotplugCallback, NULL);
- o = PULSEAUDIO_pa_context_subscribe(hotplug_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL);
- PULSEAUDIO_pa_operation_unref(o); /* don't wait for it, just do our thing. */
- PULSEAUDIO_pa_mainloop_run(hotplug_mainloop, NULL);
- return 0;
-}
-
-static void
-PULSEAUDIO_DetectDevices()
-{
- WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_sink_info_list(hotplug_context, SinkInfoCallback, NULL));
- WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_source_info_list(hotplug_context, SourceInfoCallback, NULL));
-
- /* ok, we have a sane list, let's set up hotplug notifications now... */
- hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, NULL);
-}
-
-static void
-PULSEAUDIO_Deinitialize(void)
-{
- if (hotplug_thread) {
- PULSEAUDIO_pa_mainloop_quit(hotplug_mainloop, 0);
- SDL_WaitThread(hotplug_thread, NULL);
- hotplug_thread = NULL;
- }
-
- DisconnectFromPulseServer(hotplug_mainloop, hotplug_context);
- hotplug_mainloop = NULL;
- hotplug_context = NULL;
-
- UnloadPulseAudioLibrary();
-}
-
-static int
-PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- if (LoadPulseAudioLibrary() < 0) {
- return 0;
- }
-
- if (ConnectToPulseServer(&hotplug_mainloop, &hotplug_context) < 0) {
- UnloadPulseAudioLibrary();
- return 0;
- }
-
- /* Set the function pointers */
- impl->DetectDevices = PULSEAUDIO_DetectDevices;
- impl->OpenDevice = PULSEAUDIO_OpenDevice;
- impl->PlayDevice = PULSEAUDIO_PlayDevice;
- impl->WaitDevice = PULSEAUDIO_WaitDevice;
- impl->GetDeviceBuf = PULSEAUDIO_GetDeviceBuf;
- impl->CloseDevice = PULSEAUDIO_CloseDevice;
- impl->Deinitialize = PULSEAUDIO_Deinitialize;
- impl->CaptureFromDevice = PULSEAUDIO_CaptureFromDevice;
- impl->FlushCapture = PULSEAUDIO_FlushCapture;
-
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap PULSEAUDIO_bootstrap = {
- "pulseaudio", "PulseAudio", PULSEAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.h b/3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.h
deleted file mode 100644
index e12000f2a04..00000000000
--- a/3rdparty/SDL2/src/audio/pulseaudio/SDL_pulseaudio.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_pulseaudio_h
-#define _SDL_pulseaudio_h
-
-#include <pulse/simple.h>
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- char *device_name;
-
- /* pulseaudio structures */
- pa_mainloop *mainloop;
- pa_context *context;
- pa_stream *stream;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-
- const Uint8 *capturebuf;
- int capturelen;
-};
-
-#endif /* _SDL_pulseaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.c b/3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.c
deleted file mode 100644
index 149cad90adc..00000000000
--- a/3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.c
+++ /dev/null
@@ -1,771 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-/*
- * !!! FIXME: streamline this a little by removing all the
- * !!! FIXME: if (capture) {} else {} sections that are identical
- * !!! FIXME: except for one flag.
- */
-
-/* !!! FIXME: can this target support hotplugging? */
-/* !!! FIXME: ...does SDL2 even support QNX? */
-
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_QSA
-
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sched.h>
-#include <sys/select.h>
-#include <sys/neutrino.h>
-#include <sys/asoundlib.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_qsa_audio.h"
-
-/* default channel communication parameters */
-#define DEFAULT_CPARAMS_RATE 44100
-#define DEFAULT_CPARAMS_VOICES 1
-
-#define DEFAULT_CPARAMS_FRAG_SIZE 4096
-#define DEFAULT_CPARAMS_FRAGS_MIN 1
-#define DEFAULT_CPARAMS_FRAGS_MAX 1
-
-#define QSA_NO_WORKAROUNDS 0x00000000
-#define QSA_MMAP_WORKAROUND 0x00000001
-
-struct BuggyCards
-{
- char *cardname;
- unsigned long bugtype;
-};
-
-#define QSA_WA_CARDS 3
-#define QSA_MAX_CARD_NAME_LENGTH 33
-
-struct BuggyCards buggycards[QSA_WA_CARDS] = {
- {"Sound Blaster Live!", QSA_MMAP_WORKAROUND},
- {"Vortex 8820", QSA_MMAP_WORKAROUND},
- {"Vortex 8830", QSA_MMAP_WORKAROUND},
-};
-
-/* List of found devices */
-#define QSA_MAX_DEVICES 32
-#define QSA_MAX_NAME_LENGTH 81+16 /* Hardcoded in QSA, can't be changed */
-
-typedef struct _QSA_Device
-{
- char name[QSA_MAX_NAME_LENGTH]; /* Long audio device name for SDL */
- int cardno;
- int deviceno;
-} QSA_Device;
-
-QSA_Device qsa_playback_device[QSA_MAX_DEVICES];
-uint32_t qsa_playback_devices;
-
-QSA_Device qsa_capture_device[QSA_MAX_DEVICES];
-uint32_t qsa_capture_devices;
-
-static SDL_INLINE int
-QSA_SetError(const char *fn, int status)
-{
- return SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status));
-}
-
-/* card names check to apply the workarounds */
-static int
-QSA_CheckBuggyCards(_THIS, unsigned long checkfor)
-{
- char scardname[QSA_MAX_CARD_NAME_LENGTH];
- int it;
-
- if (snd_card_get_name
- (this->hidden->cardno, scardname, QSA_MAX_CARD_NAME_LENGTH - 1) < 0) {
- return 0;
- }
-
- for (it = 0; it < QSA_WA_CARDS; it++) {
- if (SDL_strcmp(buggycards[it].cardname, scardname) == 0) {
- if (buggycards[it].bugtype == checkfor) {
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-/* !!! FIXME: does this need to be here? Does the SDL version not work? */
-static void
-QSA_ThreadInit(_THIS)
-{
- struct sched_param param;
- int status;
-
- /* Increase default 10 priority to 25 to avoid jerky sound */
- status = SchedGet(0, 0, &param);
- param.sched_priority = param.sched_curpriority + 15;
- status = SchedSet(0, 0, SCHED_NOCHANGE, &param);
-}
-
-/* PCM channel parameters initialize function */
-static void
-QSA_InitAudioParams(snd_pcm_channel_params_t * cpars)
-{
- SDL_zerop(cpars);
- cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
- cpars->mode = SND_PCM_MODE_BLOCK;
- cpars->start_mode = SND_PCM_START_DATA;
- cpars->stop_mode = SND_PCM_STOP_STOP;
- cpars->format.format = SND_PCM_SFMT_S16_LE;
- cpars->format.interleave = 1;
- cpars->format.rate = DEFAULT_CPARAMS_RATE;
- cpars->format.voices = DEFAULT_CPARAMS_VOICES;
- cpars->buf.block.frag_size = DEFAULT_CPARAMS_FRAG_SIZE;
- cpars->buf.block.frags_min = DEFAULT_CPARAMS_FRAGS_MIN;
- cpars->buf.block.frags_max = DEFAULT_CPARAMS_FRAGS_MAX;
-}
-
-/* This function waits until it is possible to write a full sound buffer */
-static void
-QSA_WaitDevice(_THIS)
-{
- fd_set wfds;
- fd_set rfds;
- int selectret;
- struct timeval timeout;
-
- if (!this->hidden->iscapture) {
- FD_ZERO(&wfds);
- FD_SET(this->hidden->audio_fd, &wfds);
- } else {
- FD_ZERO(&rfds);
- FD_SET(this->hidden->audio_fd, &rfds);
- }
-
- do {
- /* Setup timeout for playing one fragment equal to 2 seconds */
- /* If timeout occured than something wrong with hardware or driver */
- /* For example, Vortex 8820 audio driver stucks on second DAC because */
- /* it doesn't exist ! */
- timeout.tv_sec = 2;
- timeout.tv_usec = 0;
- this->hidden->timeout_on_wait = 0;
-
- if (!this->hidden->iscapture) {
- selectret =
- select(this->hidden->audio_fd + 1, NULL, &wfds, NULL,
- &timeout);
- } else {
- selectret =
- select(this->hidden->audio_fd + 1, &rfds, NULL, NULL,
- &timeout);
- }
-
- switch (selectret) {
- case -1:
- {
- SDL_SetError("QSA: select() failed: %s", strerror(errno));
- return;
- }
- break;
- case 0:
- {
- SDL_SetError("QSA: timeout on buffer waiting occured");
- this->hidden->timeout_on_wait = 1;
- return;
- }
- break;
- default:
- {
- if (!this->hidden->iscapture) {
- if (FD_ISSET(this->hidden->audio_fd, &wfds)) {
- return;
- }
- } else {
- if (FD_ISSET(this->hidden->audio_fd, &rfds)) {
- return;
- }
- }
- }
- break;
- }
- } while (1);
-}
-
-static void
-QSA_PlayDevice(_THIS)
-{
- snd_pcm_channel_status_t cstatus;
- int written;
- int status;
- int towrite;
- void *pcmbuffer;
-
- if (!SDL_AtomicGet(&this->enabled) || !this->hidden) {
- return;
- }
-
- towrite = this->spec.size;
- pcmbuffer = this->hidden->pcm_buf;
-
- /* Write the audio data, checking for EAGAIN (buffer full) and underrun */
- do {
- written =
- snd_pcm_plugin_write(this->hidden->audio_handle, pcmbuffer,
- towrite);
- if (written != towrite) {
- /* Check if samples playback got stuck somewhere in hardware or in */
- /* the audio device driver */
- if ((errno == EAGAIN) && (written == 0)) {
- if (this->hidden->timeout_on_wait != 0) {
- SDL_SetError("QSA: buffer playback timeout");
- return;
- }
- }
-
- /* Check for errors or conditions */
- if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
- /* Let a little CPU time go by and try to write again */
- SDL_Delay(1);
-
- /* if we wrote some data */
- towrite -= written;
- pcmbuffer += written * this->spec.channels;
- continue;
- } else {
- if ((errno == EINVAL) || (errno == EIO)) {
- SDL_zero(cstatus);
- if (!this->hidden->iscapture) {
- cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
- } else {
- cstatus.channel = SND_PCM_CHANNEL_CAPTURE;
- }
-
- status =
- snd_pcm_plugin_status(this->hidden->audio_handle,
- &cstatus);
- if (status < 0) {
- QSA_SetError("snd_pcm_plugin_status", status);
- return;
- }
-
- if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
- (cstatus.status == SND_PCM_STATUS_READY)) {
- if (!this->hidden->iscapture) {
- status =
- snd_pcm_plugin_prepare(this->hidden->
- audio_handle,
- SND_PCM_CHANNEL_PLAYBACK);
- } else {
- status =
- snd_pcm_plugin_prepare(this->hidden->
- audio_handle,
- SND_PCM_CHANNEL_CAPTURE);
- }
- if (status < 0) {
- QSA_SetError("snd_pcm_plugin_prepare", status);
- return;
- }
- }
- continue;
- } else {
- return;
- }
- }
- } else {
- /* we wrote all remaining data */
- towrite -= written;
- pcmbuffer += written * this->spec.channels;
- }
- } while ((towrite > 0) && SDL_AtomicGet(&this->enabled));
-
- /* If we couldn't write, assume fatal error for now */
- if (towrite != 0) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-}
-
-static Uint8 *
-QSA_GetDeviceBuf(_THIS)
-{
- return this->hidden->pcm_buf;
-}
-
-static void
-QSA_CloseDevice(_THIS)
-{
- if (this->hidden->audio_handle != NULL) {
- if (!this->hidden->iscapture) {
- /* Finish playing available samples */
- snd_pcm_plugin_flush(this->hidden->audio_handle,
- SND_PCM_CHANNEL_PLAYBACK);
- } else {
- /* Cancel unread samples during capture */
- snd_pcm_plugin_flush(this->hidden->audio_handle,
- SND_PCM_CHANNEL_CAPTURE);
- }
- snd_pcm_close(this->hidden->audio_handle);
- }
-
- SDL_free(this->hidden->pcm_buf);
- SDL_free(this->hidden);
-}
-
-static int
-QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- const QSA_Device *device = (const QSA_Device *) handle;
- int status = 0;
- int format = 0;
- SDL_AudioFormat test_format = 0;
- int found = 0;
- snd_pcm_channel_setup_t csetup;
- snd_pcm_channel_params_t cparams;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden =
- (struct SDL_PrivateAudioData *) SDL_calloc(1,
- (sizeof
- (struct
- SDL_PrivateAudioData)));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Initialize channel transfer parameters to default */
- QSA_InitAudioParams(&cparams);
-
- /* Initialize channel direction: capture or playback */
- this->hidden->iscapture = iscapture ? SDL_TRUE : SDL_FALSE;
-
- if (device != NULL) {
- /* Open requested audio device */
- this->hidden->deviceno = device->deviceno;
- this->hidden->cardno = device->cardno;
- status = snd_pcm_open(&this->hidden->audio_handle,
- device->cardno, device->deviceno,
- iscapture ? SND_PCM_OPEN_PLAYBACK : SND_PCM_OPEN_CAPTURE);
- } else {
- /* Open system default audio device */
- status = snd_pcm_open_preferred(&this->hidden->audio_handle,
- &this->hidden->cardno,
- &this->hidden->deviceno,
- iscapture ? SND_PCM_OPEN_PLAYBACK : SND_PCM_OPEN_CAPTURE);
- }
-
- /* Check if requested device is opened */
- if (status < 0) {
- this->hidden->audio_handle = NULL;
- return QSA_SetError("snd_pcm_open", status);
- }
-
- if (!QSA_CheckBuggyCards(this, QSA_MMAP_WORKAROUND)) {
- /* Disable QSA MMAP plugin for buggy audio drivers */
- status =
- snd_pcm_plugin_set_disable(this->hidden->audio_handle,
- PLUGIN_DISABLE_MMAP);
- if (status < 0) {
- return QSA_SetError("snd_pcm_plugin_set_disable", status);
- }
- }
-
- /* Try for a closest match on audio format */
- format = 0;
- /* can't use format as SND_PCM_SFMT_U8 = 0 in qsa */
- found = 0;
-
- for (test_format = SDL_FirstAudioFormat(this->spec.format); !found;) {
- /* if match found set format to equivalent QSA format */
- switch (test_format) {
- case AUDIO_U8:
- {
- format = SND_PCM_SFMT_U8;
- found = 1;
- }
- break;
- case AUDIO_S8:
- {
- format = SND_PCM_SFMT_S8;
- found = 1;
- }
- break;
- case AUDIO_S16LSB:
- {
- format = SND_PCM_SFMT_S16_LE;
- found = 1;
- }
- break;
- case AUDIO_S16MSB:
- {
- format = SND_PCM_SFMT_S16_BE;
- found = 1;
- }
- break;
- case AUDIO_U16LSB:
- {
- format = SND_PCM_SFMT_U16_LE;
- found = 1;
- }
- break;
- case AUDIO_U16MSB:
- {
- format = SND_PCM_SFMT_U16_BE;
- found = 1;
- }
- break;
- case AUDIO_S32LSB:
- {
- format = SND_PCM_SFMT_S32_LE;
- found = 1;
- }
- break;
- case AUDIO_S32MSB:
- {
- format = SND_PCM_SFMT_S32_BE;
- found = 1;
- }
- break;
- case AUDIO_F32LSB:
- {
- format = SND_PCM_SFMT_FLOAT_LE;
- found = 1;
- }
- break;
- case AUDIO_F32MSB:
- {
- format = SND_PCM_SFMT_FLOAT_BE;
- found = 1;
- }
- break;
- default:
- {
- break;
- }
- }
-
- if (!found) {
- test_format = SDL_NextAudioFormat();
- }
- }
-
- /* assumes test_format not 0 on success */
- if (test_format == 0) {
- return SDL_SetError("QSA: Couldn't find any hardware audio formats");
- }
-
- this->spec.format = test_format;
-
- /* Set the audio format */
- cparams.format.format = format;
-
- /* Set mono/stereo/4ch/6ch/8ch audio */
- cparams.format.voices = this->spec.channels;
-
- /* Set rate */
- cparams.format.rate = this->spec.freq;
-
- /* Setup the transfer parameters according to cparams */
- status = snd_pcm_plugin_params(this->hidden->audio_handle, &cparams);
- if (status < 0) {
- return QSA_SetError("snd_pcm_channel_params", status);
- }
-
- /* Make sure channel is setup right one last time */
- SDL_zero(csetup);
- if (!this->hidden->iscapture) {
- csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
- } else {
- csetup.channel = SND_PCM_CHANNEL_CAPTURE;
- }
-
- /* Setup an audio channel */
- if (snd_pcm_plugin_setup(this->hidden->audio_handle, &csetup) < 0) {
- return SDL_SetError("QSA: Unable to setup channel");
- }
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- this->hidden->pcm_len = this->spec.size;
-
- if (this->hidden->pcm_len == 0) {
- this->hidden->pcm_len =
- csetup.buf.block.frag_size * this->spec.channels *
- (snd_pcm_format_width(format) / 8);
- }
-
- /*
- * Allocate memory to the audio buffer and initialize with silence
- * (Note that buffer size must be a multiple of fragment size, so find
- * closest multiple)
- */
- this->hidden->pcm_buf =
- (Uint8 *) SDL_malloc(this->hidden->pcm_len);
- if (this->hidden->pcm_buf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->pcm_buf, this->spec.silence,
- this->hidden->pcm_len);
-
- /* get the file descriptor */
- if (!this->hidden->iscapture) {
- this->hidden->audio_fd =
- snd_pcm_file_descriptor(this->hidden->audio_handle,
- SND_PCM_CHANNEL_PLAYBACK);
- } else {
- this->hidden->audio_fd =
- snd_pcm_file_descriptor(this->hidden->audio_handle,
- SND_PCM_CHANNEL_CAPTURE);
- }
-
- if (this->hidden->audio_fd < 0) {
- return QSA_SetError("snd_pcm_file_descriptor", status);
- }
-
- /* Prepare an audio channel */
- if (!this->hidden->iscapture) {
- /* Prepare audio playback */
- status =
- snd_pcm_plugin_prepare(this->hidden->audio_handle,
- SND_PCM_CHANNEL_PLAYBACK);
- } else {
- /* Prepare audio capture */
- status =
- snd_pcm_plugin_prepare(this->hidden->audio_handle,
- SND_PCM_CHANNEL_CAPTURE);
- }
-
- if (status < 0) {
- return QSA_SetError("snd_pcm_plugin_prepare", status);
- }
-
- /* We're really ready to rock and roll. :-) */
- return 0;
-}
-
-static void
-QSA_DetectDevices(void)
-{
- uint32_t it;
- uint32_t cards;
- uint32_t devices;
- int32_t status;
-
- /* Detect amount of available devices */
- /* this value can be changed in the runtime */
- cards = snd_cards();
-
- /* If io-audio manager is not running we will get 0 as number */
- /* of available audio devices */
- if (cards == 0) {
- /* We have no any available audio devices */
- return;
- }
-
- /* !!! FIXME: code duplication */
- /* Find requested devices by type */
- { /* output devices */
- /* Playback devices enumeration requested */
- for (it = 0; it < cards; it++) {
- devices = 0;
- do {
- status =
- snd_card_get_longname(it,
- qsa_playback_device
- [qsa_playback_devices].name,
- QSA_MAX_NAME_LENGTH);
- if (status == EOK) {
- snd_pcm_t *handle;
-
- /* Add device number to device name */
- sprintf(qsa_playback_device[qsa_playback_devices].name +
- SDL_strlen(qsa_playback_device
- [qsa_playback_devices].name), " d%d",
- devices);
-
- /* Store associated card number id */
- qsa_playback_device[qsa_playback_devices].cardno = it;
-
- /* Check if this device id could play anything */
- status =
- snd_pcm_open(&handle, it, devices,
- SND_PCM_OPEN_PLAYBACK);
- if (status == EOK) {
- qsa_playback_device[qsa_playback_devices].deviceno =
- devices;
- status = snd_pcm_close(handle);
- if (status == EOK) {
- SDL_AddAudioDevice(SDL_FALSE, qsa_playback_device[qsa_playback_devices].name, &qsa_playback_device[qsa_playback_devices]);
- qsa_playback_devices++;
- }
- } else {
- /* Check if we got end of devices list */
- if (status == -ENOENT) {
- break;
- }
- }
- } else {
- break;
- }
-
- /* Check if we reached maximum devices count */
- if (qsa_playback_devices >= QSA_MAX_DEVICES) {
- break;
- }
- devices++;
- } while (1);
-
- /* Check if we reached maximum devices count */
- if (qsa_playback_devices >= QSA_MAX_DEVICES) {
- break;
- }
- }
- }
-
- { /* capture devices */
- /* Capture devices enumeration requested */
- for (it = 0; it < cards; it++) {
- devices = 0;
- do {
- status =
- snd_card_get_longname(it,
- qsa_capture_device
- [qsa_capture_devices].name,
- QSA_MAX_NAME_LENGTH);
- if (status == EOK) {
- snd_pcm_t *handle;
-
- /* Add device number to device name */
- sprintf(qsa_capture_device[qsa_capture_devices].name +
- SDL_strlen(qsa_capture_device
- [qsa_capture_devices].name), " d%d",
- devices);
-
- /* Store associated card number id */
- qsa_capture_device[qsa_capture_devices].cardno = it;
-
- /* Check if this device id could play anything */
- status =
- snd_pcm_open(&handle, it, devices,
- SND_PCM_OPEN_CAPTURE);
- if (status == EOK) {
- qsa_capture_device[qsa_capture_devices].deviceno =
- devices;
- status = snd_pcm_close(handle);
- if (status == EOK) {
- SDL_AddAudioDevice(SDL_TRUE, qsa_capture_device[qsa_capture_devices].name, &qsa_capture_device[qsa_capture_devices]);
- qsa_capture_devices++;
- }
- } else {
- /* Check if we got end of devices list */
- if (status == -ENOENT) {
- break;
- }
- }
-
- /* Check if we reached maximum devices count */
- if (qsa_capture_devices >= QSA_MAX_DEVICES) {
- break;
- }
- } else {
- break;
- }
- devices++;
- } while (1);
-
- /* Check if we reached maximum devices count */
- if (qsa_capture_devices >= QSA_MAX_DEVICES) {
- break;
- }
- }
- }
-}
-
-static void
-QSA_Deinitialize(void)
-{
- /* Clear devices array on shutdown */
- /* !!! FIXME: we zero these on init...any reason to do it here? */
- SDL_zero(qsa_playback_device);
- SDL_zero(qsa_capture_device);
- qsa_playback_devices = 0;
- qsa_capture_devices = 0;
-}
-
-static int
-QSA_Init(SDL_AudioDriverImpl * impl)
-{
- snd_pcm_t *handle = NULL;
- int32_t status = 0;
-
- /* Clear devices array */
- SDL_zero(qsa_playback_device);
- SDL_zero(qsa_capture_device);
- qsa_playback_devices = 0;
- qsa_capture_devices = 0;
-
- /* Set function pointers */
- /* DeviceLock and DeviceUnlock functions are used default, */
- /* provided by SDL, which uses pthread_mutex for lock/unlock */
- impl->DetectDevices = QSA_DetectDevices;
- impl->OpenDevice = QSA_OpenDevice;
- impl->ThreadInit = QSA_ThreadInit;
- impl->WaitDevice = QSA_WaitDevice;
- impl->PlayDevice = QSA_PlayDevice;
- impl->GetDeviceBuf = QSA_GetDeviceBuf;
- impl->CloseDevice = QSA_CloseDevice;
- impl->Deinitialize = QSA_Deinitialize;
- impl->LockDevice = NULL;
- impl->UnlockDevice = NULL;
-
- impl->OnlyHasDefaultOutputDevice = 0;
- impl->ProvidesOwnCallbackThread = 0;
- impl->SkipMixerLock = 0;
- impl->HasCaptureSupport = 1;
- impl->OnlyHasDefaultOutputDevice = 0;
- impl->OnlyHasDefaultCaptureDevice = 0;
-
- /* Check if io-audio manager is running or not */
- status = snd_cards();
- if (status == 0) {
- /* if no, return immediately */
- return 1;
- }
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap QSAAUDIO_bootstrap = {
- "qsa", "QNX QSA Audio", QSA_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_QSA */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.h b/3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.h
deleted file mode 100644
index 19a2215aada..00000000000
--- a/3rdparty/SDL2/src/audio/qsa/SDL_qsa_audio.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../../SDL_internal.h"
-
-#ifndef __SDL_QSA_AUDIO_H__
-#define __SDL_QSA_AUDIO_H__
-
-#include <sys/asoundlib.h>
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice* this
-
-struct SDL_PrivateAudioData
-{
- /* SDL capture state */
- SDL_bool iscapture;
-
- /* The audio device handle */
- int cardno;
- int deviceno;
- snd_pcm_t *audio_handle;
-
- /* The audio file descriptor */
- int audio_fd;
-
- /* Select timeout status */
- uint32_t timeout_on_wait;
-
- /* Raw mixing buffer */
- Uint8 *pcm_buf;
- Uint32 pcm_len;
-};
-
-#endif /* __SDL_QSA_AUDIO_H__ */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/sdlgenaudiocvt.pl b/3rdparty/SDL2/src/audio/sdlgenaudiocvt.pl
deleted file mode 100644
index c53f1c35593..00000000000
--- a/3rdparty/SDL2/src/audio/sdlgenaudiocvt.pl
+++ /dev/null
@@ -1,761 +0,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-
-my @audiotypes = qw(
- U8
- S8
- U16LSB
- S16LSB
- U16MSB
- S16MSB
- S32LSB
- S32MSB
- F32LSB
- F32MSB
-);
-
-my @channels = ( 1, 2, 4, 6, 8 );
-my %funcs;
-my $custom_converters = 0;
-
-
-sub getTypeConvertHashId {
- my ($from, $to) = @_;
- return "TYPECONVERTER $from/$to";
-}
-
-
-sub getResamplerHashId {
- my ($from, $channels, $upsample, $multiple) = @_;
- return "RESAMPLER $from/$channels/$upsample/$multiple";
-}
-
-
-sub outputHeader {
- print <<EOF;
-/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken\@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../SDL_internal.h"
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-
-#ifndef DEBUG_CONVERT
-#define DEBUG_CONVERT 0
-#endif
-
-
-/* If you can guarantee your data and need space, you can eliminate code... */
-
-/* Just build the arbitrary resamplers if you're saving code space. */
-#ifndef LESS_RESAMPLERS
-#define LESS_RESAMPLERS 0
-#endif
-
-/* Don't build any resamplers if you're REALLY saving code space. */
-#ifndef NO_RESAMPLERS
-#define NO_RESAMPLERS 0
-#endif
-
-/* Don't build any type converters if you're saving code space. */
-#ifndef NO_CONVERTERS
-#define NO_CONVERTERS 0
-#endif
-
-
-/* *INDENT-OFF* */
-
-EOF
-
- my @vals = ( 127, 32767, 2147483647 );
- foreach (@vals) {
- my $val = $_;
- my $fval = 1.0 / $val;
- print("#define DIVBY${val} ${fval}f\n");
- }
-
- print("\n");
-}
-
-sub outputFooter {
- print <<EOF;
-/* $custom_converters converters generated. */
-
-/* *INDENT-ON* */
-
-/* vi: set ts=4 sw=4 expandtab: */
-EOF
-}
-
-sub splittype {
- my $t = shift;
- my ($signed, $size, $endian) = $t =~ /([USF])(\d+)([LM]SB|)/;
- my $float = ($signed eq 'F') ? 1 : 0;
- $signed = (($float) or ($signed eq 'S')) ? 1 : 0;
- $endian = 'NONE' if ($endian eq '');
-
- my $ctype = '';
- if ($float) {
- $ctype = (($size == 32) ? 'float' : 'double');
- } else {
- $ctype = (($signed) ? 'S' : 'U') . "int${size}";
- }
-
- return ($signed, $float, $size, $endian, $ctype);
-}
-
-sub getSwapFunc {
- my ($size, $signed, $float, $endian, $val) = @_;
- my $BEorLE = (($endian eq 'MSB') ? 'BE' : 'LE');
- my $code = '';
-
- if ($float) {
- $code = "SDL_SwapFloat${BEorLE}($val)";
- } else {
- if ($size > 8) {
- $code = "SDL_Swap${BEorLE}${size}($val)";
- } else {
- $code = $val;
- }
-
- if (($signed) and (!$float)) {
- $code = "((Sint${size}) $code)";
- }
- }
-
- return "${code}";
-}
-
-
-sub maxIntVal {
- my $size = shift;
- if ($size == 8) {
- return 0x7F;
- } elsif ($size == 16) {
- return 0x7FFF;
- } elsif ($size == 32) {
- return 0x7FFFFFFF;
- }
-
- die("bug in script.\n");
-}
-
-sub getFloatToIntMult {
- my $size = shift;
- my $val = maxIntVal($size) . '.0';
- $val .= 'f' if ($size < 32);
- return $val;
-}
-
-sub getIntToFloatDivBy {
- my $size = shift;
- return 'DIVBY' . maxIntVal($size);
-}
-
-sub getSignFlipVal {
- my $size = shift;
- if ($size == 8) {
- return '0x80';
- } elsif ($size == 16) {
- return '0x8000';
- } elsif ($size == 32) {
- return '0x80000000';
- }
-
- die("bug in script.\n");
-}
-
-sub buildCvtFunc {
- my ($from, $to) = @_;
- my ($fsigned, $ffloat, $fsize, $fendian, $fctype) = splittype($from);
- my ($tsigned, $tfloat, $tsize, $tendian, $tctype) = splittype($to);
- my $diffs = 0;
- $diffs++ if ($fsize != $tsize);
- $diffs++ if ($fsigned != $tsigned);
- $diffs++ if ($ffloat != $tfloat);
- $diffs++ if ($fendian ne $tendian);
-
- return if ($diffs == 0);
-
- my $hashid = getTypeConvertHashId($from, $to);
- if (1) { # !!! FIXME: if ($diffs > 1) {
- my $sym = "SDL_Convert_${from}_to_${to}";
- $funcs{$hashid} = $sym;
- $custom_converters++;
-
- # Always unsigned for ints, for possible byteswaps.
- my $srctype = (($ffloat) ? 'float' : "Uint${fsize}");
-
- print <<EOF;
-static void SDLCALL
-${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const $srctype *src;
- $tctype *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_${from} to AUDIO_${to}.\\n");
-#endif
-
-EOF
-
- if ($fsize < $tsize) {
- my $mult = $tsize / $fsize;
- print <<EOF;
- src = ((const $srctype *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = (($tctype *) (cvt->buf + cvt->len_cvt * $mult)) - 1;
- for (i = cvt->len_cvt / sizeof ($srctype); i; --i, --src, --dst) {
-EOF
- } else {
- print <<EOF;
- src = (const $srctype *) cvt->buf;
- dst = ($tctype *) cvt->buf;
- for (i = cvt->len_cvt / sizeof ($srctype); i; --i, ++src, ++dst) {
-EOF
- }
-
- # Have to convert to/from float/int.
- # !!! FIXME: cast through double for int32<->float?
- my $code = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, '*src');
- if ($ffloat != $tfloat) {
- if ($ffloat) {
- my $mult = getFloatToIntMult($tsize);
- if (!$tsigned) { # bump from -1.0f/1.0f to 0.0f/2.0f
- $code = "($code + 1.0f)";
- }
- $code = "(($tctype) ($code * $mult))";
- } else {
- # $divby will be the reciprocal, to avoid pipeline stalls
- # from floating point division...so multiply it.
- my $divby = getIntToFloatDivBy($fsize);
- $code = "(((float) $code) * $divby)";
- if (!$fsigned) { # bump from 0.0f/2.0f to -1.0f/1.0f.
- $code = "($code - 1.0f)";
- }
- }
- } else {
- # All integer conversions here.
- if ($fsigned != $tsigned) {
- my $signflipval = getSignFlipVal($fsize);
- $code = "(($code) ^ $signflipval)";
- }
-
- my $shiftval = abs($fsize - $tsize);
- if ($fsize < $tsize) {
- $code = "((($tctype) $code) << $shiftval)";
- } elsif ($fsize > $tsize) {
- $code = "(($tctype) ($code >> $shiftval))";
- }
- }
-
- my $swap = getSwapFunc($tsize, $tsigned, $tfloat, $tendian, 'val');
-
- print <<EOF;
- const $tctype val = $code;
- *dst = ${swap};
- }
-
-EOF
-
- if ($fsize > $tsize) {
- my $divby = $fsize / $tsize;
- print(" cvt->len_cvt /= $divby;\n");
- } elsif ($fsize < $tsize) {
- my $mult = $tsize / $fsize;
- print(" cvt->len_cvt *= $mult;\n");
- }
-
- print <<EOF;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_$to);
- }
-}
-
-EOF
-
- } else {
- if ($fsigned != $tsigned) {
- $funcs{$hashid} = 'SDL_ConvertSigned';
- } elsif ($ffloat != $tfloat) {
- $funcs{$hashid} = 'SDL_ConvertFloat';
- } elsif ($fsize != $tsize) {
- $funcs{$hashid} = 'SDL_ConvertSize';
- } elsif ($fendian ne $tendian) {
- $funcs{$hashid} = 'SDL_ConvertEndian';
- } else {
- die("error in script.\n");
- }
- }
-}
-
-
-sub buildTypeConverters {
- print "#if !NO_CONVERTERS\n\n";
- foreach (@audiotypes) {
- my $from = $_;
- foreach (@audiotypes) {
- my $to = $_;
- buildCvtFunc($from, $to);
- }
- }
- print "#endif /* !NO_CONVERTERS */\n\n\n";
-
- print "const SDL_AudioTypeFilters sdl_audio_type_filters[] =\n{\n";
- print "#if !NO_CONVERTERS\n";
- foreach (@audiotypes) {
- my $from = $_;
- foreach (@audiotypes) {
- my $to = $_;
- if ($from ne $to) {
- my $hashid = getTypeConvertHashId($from, $to);
- my $sym = $funcs{$hashid};
- print(" { AUDIO_$from, AUDIO_$to, $sym },\n");
- }
- }
- }
- print "#endif /* !NO_CONVERTERS */\n";
-
- print(" { 0, 0, NULL }\n");
- print "};\n\n\n";
-}
-
-sub getBiggerCtype {
- my ($isfloat, $size) = @_;
-
- if ($isfloat) {
- if ($size == 32) {
- return 'double';
- }
- die("bug in script.\n");
- }
-
- if ($size == 8) {
- return 'Sint16';
- } elsif ($size == 16) {
- return 'Sint32'
- } elsif ($size == 32) {
- return 'Sint64'
- }
-
- die("bug in script.\n");
-}
-
-
-# These handle arbitrary resamples...44100Hz to 48000Hz, for example.
-# Man, this code is skanky.
-sub buildArbitraryResampleFunc {
- # !!! FIXME: we do a lot of unnecessary and ugly casting in here, due to getSwapFunc().
- my ($from, $channels, $upsample) = @_;
- my ($fsigned, $ffloat, $fsize, $fendian, $fctype) = splittype($from);
-
- my $bigger = getBiggerCtype($ffloat, $fsize);
- my $interp = ($ffloat) ? '* 0.5' : '>> 1';
-
- my $resample = ($upsample) ? 'Upsample' : 'Downsample';
- my $hashid = getResamplerHashId($from, $channels, $upsample, 0);
- my $sym = "SDL_${resample}_${from}_${channels}c";
- $funcs{$hashid} = $sym;
- $custom_converters++;
-
- my $fudge = $fsize * $channels * 2; # !!! FIXME
- my $eps_adjust = ($upsample) ? 'dstsize' : 'srcsize';
- my $incr = '';
- my $incr2 = '';
- my $block_align = $channels * $fsize/8;
-
-
- # !!! FIXME: DEBUG_CONVERT should report frequencies.
- print <<EOF;
-static void SDLCALL
-${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "$resample arbitrary (x%f) AUDIO_${from}, ${channels} channels.\\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - $fudge;
- const int dstsize = (int) (((double)(cvt->len_cvt/${block_align})) * cvt->rate_incr) * ${block_align};
- register int eps = 0;
-EOF
-
- my $endcomparison = '!=';
-
- # Upsampling (growing the buffer) needs to work backwards, since we
- # overwrite the buffer as we go.
- if ($upsample) {
- $endcomparison = '>='; # dst > target
- print <<EOF;
- $fctype *dst = (($fctype *) (cvt->buf + dstsize)) - $channels;
- const $fctype *src = (($fctype *) (cvt->buf + cvt->len_cvt)) - $channels;
- const $fctype *target = ((const $fctype *) cvt->buf);
-EOF
- } else {
- $endcomparison = '<'; # dst < target
- print <<EOF;
- $fctype *dst = ($fctype *) cvt->buf;
- const $fctype *src = ($fctype *) cvt->buf;
- const $fctype *target = (const $fctype *) (cvt->buf + dstsize);
-EOF
- }
-
- for (my $i = 0; $i < $channels; $i++) {
- my $idx = ($upsample) ? (($channels - $i) - 1) : $i;
- my $val = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, "src[$idx]");
- print <<EOF;
- $fctype sample${idx} = $val;
-EOF
- }
-
- for (my $i = 0; $i < $channels; $i++) {
- my $idx = ($upsample) ? (($channels - $i) - 1) : $i;
- print <<EOF;
- $fctype last_sample${idx} = sample${idx};
-EOF
- }
-
- print <<EOF;
- while (dst $endcomparison target) {
-EOF
-
- if ($upsample) {
- for (my $i = 0; $i < $channels; $i++) {
- # !!! FIXME: don't do this swap every write, just when the samples change.
- my $idx = (($channels - $i) - 1);
- my $val = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, "sample${idx}");
- print <<EOF;
- dst[$idx] = $val;
-EOF
- }
-
- $incr = ($channels == 1) ? 'dst--' : "dst -= $channels";
- $incr2 = ($channels == 1) ? 'src--' : "src -= $channels";
-
- print <<EOF;
- $incr;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- $incr2;
-EOF
- } else { # downsample.
- $incr = ($channels == 1) ? 'src++' : "src += $channels";
- print <<EOF;
- $incr;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
-EOF
- for (my $i = 0; $i < $channels; $i++) {
- my $val = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, "sample${i}");
- print <<EOF;
- dst[$i] = $val;
-EOF
- }
-
- $incr = ($channels == 1) ? 'dst++' : "dst += $channels";
- print <<EOF;
- $incr;
-EOF
- }
-
- for (my $i = 0; $i < $channels; $i++) {
- my $idx = ($upsample) ? (($channels - $i) - 1) : $i;
- my $swapped = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, "src[$idx]");
- print <<EOF;
- sample${idx} = ($fctype) (((($bigger) $swapped) + (($bigger) last_sample${idx})) $interp);
-EOF
- }
-
- for (my $i = 0; $i < $channels; $i++) {
- my $idx = ($upsample) ? (($channels - $i) - 1) : $i;
- print <<EOF;
- last_sample${idx} = sample${idx};
-EOF
- }
-
- print <<EOF;
- eps -= $eps_adjust;
- }
- }
-EOF
-
- print <<EOF;
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-EOF
-
-}
-
-# These handle clean resamples...doubling and quadrupling the sample rate, etc.
-sub buildMultipleResampleFunc {
- # !!! FIXME: we do a lot of unnecessary and ugly casting in here, due to getSwapFunc().
- my ($from, $channels, $upsample, $multiple) = @_;
- my ($fsigned, $ffloat, $fsize, $fendian, $fctype) = splittype($from);
-
- my $bigger = getBiggerCtype($ffloat, $fsize);
- my $interp = ($ffloat) ? '* 0.5' : '>> 1';
- my $interp2 = ($ffloat) ? '* 0.25' : '>> 2';
- my $mult3 = ($ffloat) ? '3.0' : '3';
- my $lencvtop = ($upsample) ? '*' : '/';
-
- my $resample = ($upsample) ? 'Upsample' : 'Downsample';
- my $hashid = getResamplerHashId($from, $channels, $upsample, $multiple);
- my $sym = "SDL_${resample}_${from}_${channels}c_x${multiple}";
- $funcs{$hashid} = $sym;
- $custom_converters++;
-
- # !!! FIXME: DEBUG_CONVERT should report frequencies.
- print <<EOF;
-static void SDLCALL
-${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "$resample (x${multiple}) AUDIO_${from}, ${channels} channels.\\n");
-#endif
-
- const int dstsize = cvt->len_cvt $lencvtop $multiple;
-EOF
-
- my $endcomparison = '!=';
-
- # Upsampling (growing the buffer) needs to work backwards, since we
- # overwrite the buffer as we go.
- if ($upsample) {
- $endcomparison = '>='; # dst > target
- print <<EOF;
- $fctype *dst = (($fctype *) (cvt->buf + dstsize)) - $channels * $multiple;
- const $fctype *src = (($fctype *) (cvt->buf + cvt->len_cvt)) - $channels;
- const $fctype *target = ((const $fctype *) cvt->buf);
-EOF
- } else {
- $endcomparison = '<'; # dst < target
- print <<EOF;
- $fctype *dst = ($fctype *) cvt->buf;
- const $fctype *src = ($fctype *) cvt->buf;
- const $fctype *target = (const $fctype *) (cvt->buf + dstsize);
-EOF
- }
-
- for (my $i = 0; $i < $channels; $i++) {
- my $idx = ($upsample) ? (($channels - $i) - 1) : $i;
- my $val = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, "src[$idx]");
- print <<EOF;
- $bigger last_sample${idx} = ($bigger) $val;
-EOF
- }
-
- print <<EOF;
- while (dst $endcomparison target) {
-EOF
-
- for (my $i = 0; $i < $channels; $i++) {
- my $idx = ($upsample) ? (($channels - $i) - 1) : $i;
- my $val = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, "src[$idx]");
- print <<EOF;
- const $bigger sample${idx} = ($bigger) $val;
-EOF
- }
-
- my $incr = '';
- if ($upsample) {
- $incr = ($channels == 1) ? 'src--' : "src -= $channels";
- } else {
- my $amount = $channels * $multiple;
- $incr = "src += $amount"; # can't ever be 1, so no "++" version.
- }
-
-
- print <<EOF;
- $incr;
-EOF
-
- # !!! FIXME: This really begs for some Altivec or SSE, etc.
- if ($upsample) {
- if ($multiple == 2) {
- for (my $i = $channels-1; $i >= 0; $i--) {
- my $dsti = $i + $channels;
- print <<EOF;
- dst[$dsti] = ($fctype) ((sample${i} + last_sample${i}) $interp);
-EOF
- }
- for (my $i = $channels-1; $i >= 0; $i--) {
- my $dsti = $i;
- print <<EOF;
- dst[$dsti] = ($fctype) sample${i};
-EOF
- }
- } elsif ($multiple == 4) {
- for (my $i = $channels-1; $i >= 0; $i--) {
- my $dsti = $i + ($channels * 3);
- print <<EOF;
- dst[$dsti] = ($fctype) ((sample${i} + ($mult3 * last_sample${i})) $interp2);
-EOF
- }
-
- for (my $i = $channels-1; $i >= 0; $i--) {
- my $dsti = $i + ($channels * 2);
- print <<EOF;
- dst[$dsti] = ($fctype) ((sample${i} + last_sample${i}) $interp);
-EOF
- }
-
- for (my $i = $channels-1; $i >= 0; $i--) {
- my $dsti = $i + ($channels * 1);
- print <<EOF;
- dst[$dsti] = ($fctype) ((($mult3 * sample${i}) + last_sample${i}) $interp2);
-EOF
- }
-
- for (my $i = $channels-1; $i >= 0; $i--) {
- my $dsti = $i + ($channels * 0);
- print <<EOF;
- dst[$dsti] = ($fctype) sample${i};
-EOF
- }
- } else {
- die('bug in program.'); # we only handle x2 and x4.
- }
- } else { # downsample.
- if ($multiple == 2) {
- for (my $i = 0; $i < $channels; $i++) {
- print <<EOF;
- dst[$i] = ($fctype) ((sample${i} + last_sample${i}) $interp);
-EOF
- }
- } elsif ($multiple == 4) {
- # !!! FIXME: interpolate all 4 samples?
- for (my $i = 0; $i < $channels; $i++) {
- print <<EOF;
- dst[$i] = ($fctype) ((sample${i} + last_sample${i}) $interp);
-EOF
- }
- } else {
- die('bug in program.'); # we only handle x2 and x4.
- }
- }
-
- for (my $i = 0; $i < $channels; $i++) {
- my $idx = ($upsample) ? (($channels - $i) - 1) : $i;
- print <<EOF;
- last_sample${idx} = sample${idx};
-EOF
- }
-
- if ($upsample) {
- my $amount = $channels * $multiple;
- $incr = "dst -= $amount"; # can't ever be 1, so no "--" version.
- } else {
- $incr = ($channels == 1) ? 'dst++' : "dst += $channels";
- }
-
- print <<EOF;
- $incr;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-EOF
-
-}
-
-sub buildResamplers {
- print "#if !NO_RESAMPLERS\n\n";
- foreach (@audiotypes) {
- my $from = $_;
- foreach (@channels) {
- my $channel = $_;
- buildArbitraryResampleFunc($from, $channel, 1);
- buildArbitraryResampleFunc($from, $channel, 0);
- }
- }
-
- print "\n#if !LESS_RESAMPLERS\n\n";
- foreach (@audiotypes) {
- my $from = $_;
- foreach (@channels) {
- my $channel = $_;
- for (my $multiple = 2; $multiple <= 4; $multiple += 2) {
- buildMultipleResampleFunc($from, $channel, 1, $multiple);
- buildMultipleResampleFunc($from, $channel, 0, $multiple);
- }
- }
- }
-
- print "#endif /* !LESS_RESAMPLERS */\n";
- print "#endif /* !NO_RESAMPLERS */\n\n\n";
-
- print "const SDL_AudioRateFilters sdl_audio_rate_filters[] =\n{\n";
- print "#if !NO_RESAMPLERS\n";
- foreach (@audiotypes) {
- my $from = $_;
- foreach (@channels) {
- my $channel = $_;
- for (my $upsample = 0; $upsample <= 1; $upsample++) {
- my $hashid = getResamplerHashId($from, $channel, $upsample, 0);
- my $sym = $funcs{$hashid};
- print(" { AUDIO_$from, $channel, $upsample, 0, $sym },\n");
- }
- }
- }
-
- print "#if !LESS_RESAMPLERS\n";
- foreach (@audiotypes) {
- my $from = $_;
- foreach (@channels) {
- my $channel = $_;
- for (my $multiple = 2; $multiple <= 4; $multiple += 2) {
- for (my $upsample = 0; $upsample <= 1; $upsample++) {
- my $hashid = getResamplerHashId($from, $channel, $upsample, $multiple);
- my $sym = $funcs{$hashid};
- print(" { AUDIO_$from, $channel, $upsample, $multiple, $sym },\n");
- }
- }
- }
- }
-
- print "#endif /* !LESS_RESAMPLERS */\n";
- print "#endif /* !NO_RESAMPLERS */\n";
- print(" { 0, 0, 0, 0, NULL }\n");
- print "};\n\n";
-}
-
-
-# mainline ...
-
-outputHeader();
-buildTypeConverters();
-buildResamplers();
-outputFooter();
-
-exit 0;
-
-# end of sdlgenaudiocvt.pl ...
-
diff --git a/3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.c b/3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.c
deleted file mode 100644
index fb7d78ff17f..00000000000
--- a/3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_SNDIO
-
-/* OpenBSD sndio target */
-
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#include <unistd.h>
-
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_sndioaudio.h"
-
-#ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC
-#include "SDL_loadso.h"
-#endif
-
-static struct sio_hdl * (*SNDIO_sio_open)(const char *, unsigned int, int);
-static void (*SNDIO_sio_close)(struct sio_hdl *);
-static int (*SNDIO_sio_setpar)(struct sio_hdl *, struct sio_par *);
-static int (*SNDIO_sio_getpar)(struct sio_hdl *, struct sio_par *);
-static int (*SNDIO_sio_start)(struct sio_hdl *);
-static int (*SNDIO_sio_stop)(struct sio_hdl *);
-static size_t (*SNDIO_sio_read)(struct sio_hdl *, void *, size_t);
-static size_t (*SNDIO_sio_write)(struct sio_hdl *, const void *, size_t);
-static void (*SNDIO_sio_initpar)(struct sio_par *);
-
-#ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC
-static const char *sndio_library = SDL_AUDIO_DRIVER_SNDIO_DYNAMIC;
-static void *sndio_handle = NULL;
-
-static int
-load_sndio_sym(const char *fn, void **addr)
-{
- *addr = SDL_LoadFunction(sndio_handle, fn);
- if (*addr == NULL) {
- /* Don't call SDL_SetError(): SDL_LoadFunction already did. */
- return 0;
- }
-
- return 1;
-}
-
-/* cast funcs to char* first, to please GCC's strict aliasing rules. */
-#define SDL_SNDIO_SYM(x) \
- if (!load_sndio_sym(#x, (void **) (char *) &SNDIO_##x)) return -1
-#else
-#define SDL_SNDIO_SYM(x) SNDIO_##x = x
-#endif
-
-static int
-load_sndio_syms(void)
-{
- SDL_SNDIO_SYM(sio_open);
- SDL_SNDIO_SYM(sio_close);
- SDL_SNDIO_SYM(sio_setpar);
- SDL_SNDIO_SYM(sio_getpar);
- SDL_SNDIO_SYM(sio_start);
- SDL_SNDIO_SYM(sio_stop);
- SDL_SNDIO_SYM(sio_read);
- SDL_SNDIO_SYM(sio_write);
- SDL_SNDIO_SYM(sio_initpar);
- return 0;
-}
-
-#undef SDL_SNDIO_SYM
-
-#ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC
-
-static void
-UnloadSNDIOLibrary(void)
-{
- if (sndio_handle != NULL) {
- SDL_UnloadObject(sndio_handle);
- sndio_handle = NULL;
- }
-}
-
-static int
-LoadSNDIOLibrary(void)
-{
- int retval = 0;
- if (sndio_handle == NULL) {
- sndio_handle = SDL_LoadObject(sndio_library);
- if (sndio_handle == NULL) {
- retval = -1;
- /* Don't call SDL_SetError(): SDL_LoadObject already did. */
- } else {
- retval = load_sndio_syms();
- if (retval < 0) {
- UnloadSNDIOLibrary();
- }
- }
- }
- return retval;
-}
-
-#else
-
-static void
-UnloadSNDIOLibrary(void)
-{
-}
-
-static int
-LoadSNDIOLibrary(void)
-{
- load_sndio_syms();
- return 0;
-}
-
-#endif /* SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
-
-
-
-
-static void
-SNDIO_WaitDevice(_THIS)
-{
- /* no-op; SNDIO_sio_write() blocks if necessary. */
-}
-
-static void
-SNDIO_PlayDevice(_THIS)
-{
- const int written = SNDIO_sio_write(this->hidden->dev,
- this->hidden->mixbuf,
- this->hidden->mixlen);
-
- /* If we couldn't write, assume fatal error for now */
- if ( written == 0 ) {
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Wrote %d bytes of audio data\n", written);
-#endif
-}
-
-static Uint8 *
-SNDIO_GetDeviceBuf(_THIS)
-{
- return this->hidden->mixbuf;
-}
-
-static void
-SNDIO_CloseDevice(_THIS)
-{
- if ( this->hidden->dev != NULL ) {
- SNDIO_sio_stop(this->hidden->dev);
- SNDIO_sio_close(this->hidden->dev);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-SNDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
- struct sio_par par;
- int status;
-
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc(sizeof(*this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- this->hidden->mixlen = this->spec.size;
-
- /* !!! FIXME: SIO_DEVANY can be a specific device... */
- if ((this->hidden->dev = SNDIO_sio_open(SIO_DEVANY, SIO_PLAY, 0)) == NULL) {
- return SDL_SetError("sio_open() failed");
- }
-
- SNDIO_sio_initpar(&par);
-
- par.rate = this->spec.freq;
- par.pchan = this->spec.channels;
- par.round = this->spec.samples;
- par.appbufsz = par.round * 2;
-
- /* Try for a closest match on audio format */
- status = -1;
- while (test_format && (status < 0)) {
- if (!SDL_AUDIO_ISFLOAT(test_format)) {
- par.le = SDL_AUDIO_ISLITTLEENDIAN(test_format) ? 1 : 0;
- par.sig = SDL_AUDIO_ISSIGNED(test_format) ? 1 : 0;
- par.bits = SDL_AUDIO_BITSIZE(test_format);
-
- if (SNDIO_sio_setpar(this->hidden->dev, &par) == 0) {
- continue;
- }
- if (SNDIO_sio_getpar(this->hidden->dev, &par) == 0) {
- return SDL_SetError("sio_getpar() failed");
- }
- if (par.bps != SIO_BPS(par.bits)) {
- continue;
- }
- if ((par.bits == 8 * par.bps) || (par.msb)) {
- status = 0;
- break;
- }
- }
- test_format = SDL_NextAudioFormat();
- }
-
- if (status < 0) {
- return SDL_SetError("sndio: Couldn't find any hardware audio formats");
- }
-
- if ((par.bps == 4) && (par.sig) && (par.le))
- this->spec.format = AUDIO_S32LSB;
- else if ((par.bps == 4) && (par.sig) && (!par.le))
- this->spec.format = AUDIO_S32MSB;
- else if ((par.bps == 2) && (par.sig) && (par.le))
- this->spec.format = AUDIO_S16LSB;
- else if ((par.bps == 2) && (par.sig) && (!par.le))
- this->spec.format = AUDIO_S16MSB;
- else if ((par.bps == 2) && (!par.sig) && (par.le))
- this->spec.format = AUDIO_U16LSB;
- else if ((par.bps == 2) && (!par.sig) && (!par.le))
- this->spec.format = AUDIO_U16MSB;
- else if ((par.bps == 1) && (par.sig))
- this->spec.format = AUDIO_S8;
- else if ((par.bps == 1) && (!par.sig))
- this->spec.format = AUDIO_U8;
- else {
- return SDL_SetError("sndio: Got unsupported hardware audio format.");
- }
-
- this->spec.freq = par.rate;
- this->spec.channels = par.pchan;
- this->spec.samples = par.round;
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate mixing buffer */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen);
-
- if (!SNDIO_sio_start(this->hidden->dev)) {
- return SDL_SetError("sio_start() failed");
- }
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-static void
-SNDIO_Deinitialize(void)
-{
- UnloadSNDIOLibrary();
-}
-
-static int
-SNDIO_Init(SDL_AudioDriverImpl * impl)
-{
- if (LoadSNDIOLibrary() < 0) {
- return 0;
- }
-
- /* Set the function pointers */
- impl->OpenDevice = SNDIO_OpenDevice;
- impl->WaitDevice = SNDIO_WaitDevice;
- impl->PlayDevice = SNDIO_PlayDevice;
- impl->GetDeviceBuf = SNDIO_GetDeviceBuf;
- impl->CloseDevice = SNDIO_CloseDevice;
- impl->Deinitialize = SNDIO_Deinitialize;
- impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: sndio can handle multiple devices. */
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap SNDIO_bootstrap = {
- "sndio", "OpenBSD sndio", SNDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_SNDIO */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.h b/3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.h
deleted file mode 100644
index 1e748ac93ff..00000000000
--- a/3rdparty/SDL2/src/audio/sndio/SDL_sndioaudio.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_sndioaudio_h
-#define _SDL_sndioaudio_h
-
-#include <sndio.h>
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The audio device handle */
- struct sio_hdl *dev;
-
- /* Raw mixing buffer */
- Uint8 *mixbuf;
- int mixlen;
-};
-
-#endif /* _SDL_sndioaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/sun/SDL_sunaudio.c b/3rdparty/SDL2/src/audio/sun/SDL_sunaudio.c
deleted file mode 100644
index b994c12c361..00000000000
--- a/3rdparty/SDL2/src/audio/sun/SDL_sunaudio.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_SUNAUDIO
-
-/* Allow access to a raw mixing buffer */
-
-#include <fcntl.h>
-#include <errno.h>
-#ifdef __NETBSD__
-#include <sys/ioctl.h>
-#include <sys/audioio.h>
-#endif
-#ifdef __SVR4
-#include <sys/audioio.h>
-#else
-#include <sys/time.h>
-#include <sys/types.h>
-#endif
-#include <unistd.h>
-
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_audiodev_c.h"
-#include "SDL_sunaudio.h"
-
-/* Open the audio device for playback, and don't block if busy */
-
-#if defined(AUDIO_GETINFO) && !defined(AUDIO_GETBUFINFO)
-#define AUDIO_GETBUFINFO AUDIO_GETINFO
-#endif
-
-/* Audio driver functions */
-static Uint8 snd2au(int sample);
-
-/* Audio driver bootstrap functions */
-static void
-SUNAUDIO_DetectDevices(void)
-{
- SDL_EnumUnixAudioDevices(1, (int (*)(int)) NULL);
-}
-
-#ifdef DEBUG_AUDIO
-void
-CheckUnderflow(_THIS)
-{
-#ifdef AUDIO_GETBUFINFO
- audio_info_t info;
- int left;
-
- ioctl(this->hidden->audio_fd, AUDIO_GETBUFINFO, &info);
- left = (this->hidden->written - info.play.samples);
- if (this->hidden->written && (left == 0)) {
- fprintf(stderr, "audio underflow!\n");
- }
-#endif
-}
-#endif
-
-static void
-SUNAUDIO_WaitDevice(_THIS)
-{
-#ifdef AUDIO_GETBUFINFO
-#define SLEEP_FUDGE 10 /* 10 ms scheduling fudge factor */
- audio_info_t info;
- Sint32 left;
-
- ioctl(this->hidden->audio_fd, AUDIO_GETBUFINFO, &info);
- left = (this->hidden->written - info.play.samples);
- if (left > this->hidden->fragsize) {
- Sint32 sleepy;
-
- sleepy = ((left - this->hidden->fragsize) / this->hidden->frequency);
- sleepy -= SLEEP_FUDGE;
- if (sleepy > 0) {
- SDL_Delay(sleepy);
- }
- }
-#else
- fd_set fdset;
-
- FD_ZERO(&fdset);
- FD_SET(this->hidden->audio_fd, &fdset);
- select(this->hidden->audio_fd + 1, NULL, &fdset, NULL, NULL);
-#endif
-}
-
-static void
-SUNAUDIO_PlayDevice(_THIS)
-{
- /* Write the audio data */
- if (this->hidden->ulaw_only) {
- /* Assuming that this->spec.freq >= 8000 Hz */
- int accum, incr, pos;
- Uint8 *aubuf;
-
- accum = 0;
- incr = this->spec.freq / 8;
- aubuf = this->hidden->ulaw_buf;
- switch (this->hidden->audio_fmt & 0xFF) {
- case 8:
- {
- Uint8 *sndbuf;
-
- sndbuf = this->hidden->mixbuf;
- for (pos = 0; pos < this->hidden->fragsize; ++pos) {
- *aubuf = snd2au((0x80 - *sndbuf) * 64);
- accum += incr;
- while (accum > 0) {
- accum -= 1000;
- sndbuf += 1;
- }
- aubuf += 1;
- }
- }
- break;
- case 16:
- {
- Sint16 *sndbuf;
-
- sndbuf = (Sint16 *) this->hidden->mixbuf;
- for (pos = 0; pos < this->hidden->fragsize; ++pos) {
- *aubuf = snd2au(*sndbuf / 4);
- accum += incr;
- while (accum > 0) {
- accum -= 1000;
- sndbuf += 1;
- }
- aubuf += 1;
- }
- }
- break;
- }
-#ifdef DEBUG_AUDIO
- CheckUnderflow(this);
-#endif
- if (write(this->hidden->audio_fd, this->hidden->ulaw_buf,
- this->hidden->fragsize) < 0) {
- /* Assume fatal error, for now */
- SDL_OpenedAudioDeviceDisconnected(this);
- }
- this->hidden->written += this->hidden->fragsize;
- } else {
-#ifdef DEBUG_AUDIO
- CheckUnderflow(this);
-#endif
- if (write(this->hidden->audio_fd, this->hidden->mixbuf,
- this->spec.size) < 0) {
- /* Assume fatal error, for now */
- SDL_OpenedAudioDeviceDisconnected(this);
- }
- this->hidden->written += this->hidden->fragsize;
- }
-}
-
-static Uint8 *
-SUNAUDIO_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-static void
-SUNAUDIO_CloseDevice(_THIS)
-{
- SDL_free(this->hidden->ulaw_buf);
- if (this->hidden->audio_fd >= 0) {
- close(this->hidden->audio_fd);
- }
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-SUNAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
- SDL_AudioFormat format = 0;
- audio_info_t info;
-
- /* We don't care what the devname is...we'll try to open anything. */
- /* ...but default to first name in the list... */
- if (devname == NULL) {
- devname = SDL_GetAudioDeviceName(0, iscapture);
- if (devname == NULL) {
- return SDL_SetError("No such audio device");
- }
- }
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Open the audio device */
- this->hidden->audio_fd = open(devname, flags, 0);
- if (this->hidden->audio_fd < 0) {
- return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
- }
-
-#ifdef AUDIO_SETINFO
- int enc;
-#endif
- int desired_freq = this->spec.freq;
-
- /* Determine the audio parameters from the AudioSpec */
- switch (SDL_AUDIO_BITSIZE(this->spec.format)) {
-
- case 8:
- { /* Unsigned 8 bit audio data */
- this->spec.format = AUDIO_U8;
-#ifdef AUDIO_SETINFO
- enc = AUDIO_ENCODING_LINEAR8;
-#endif
- }
- break;
-
- case 16:
- { /* Signed 16 bit audio data */
- this->spec.format = AUDIO_S16SYS;
-#ifdef AUDIO_SETINFO
- enc = AUDIO_ENCODING_LINEAR;
-#endif
- }
- break;
-
- default:
- {
- /* !!! FIXME: fallback to conversion on unsupported types! */
- return SDL_SetError("Unsupported audio format");
- }
- }
- this->hidden->audio_fmt = this->spec.format;
-
- this->hidden->ulaw_only = 0; /* modern Suns do support linear audio */
-#ifdef AUDIO_SETINFO
- for (;;) {
- audio_info_t info;
- AUDIO_INITINFO(&info); /* init all fields to "no change" */
-
- /* Try to set the requested settings */
- info.play.sample_rate = this->spec.freq;
- info.play.channels = this->spec.channels;
- info.play.precision = (enc == AUDIO_ENCODING_ULAW)
- ? 8 : this->spec.format & 0xff;
- info.play.encoding = enc;
- if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) == 0) {
-
- /* Check to be sure we got what we wanted */
- if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) {
- return SDL_SetError("Error getting audio parameters: %s",
- strerror(errno));
- }
- if (info.play.encoding == enc
- && info.play.precision == (this->spec.format & 0xff)
- && info.play.channels == this->spec.channels) {
- /* Yow! All seems to be well! */
- this->spec.freq = info.play.sample_rate;
- break;
- }
- }
-
- switch (enc) {
- case AUDIO_ENCODING_LINEAR8:
- /* unsigned 8bit apparently not supported here */
- enc = AUDIO_ENCODING_LINEAR;
- this->spec.format = AUDIO_S16SYS;
- break; /* try again */
-
- case AUDIO_ENCODING_LINEAR:
- /* linear 16bit didn't work either, resort to µ-law */
- enc = AUDIO_ENCODING_ULAW;
- this->spec.channels = 1;
- this->spec.freq = 8000;
- this->spec.format = AUDIO_U8;
- this->hidden->ulaw_only = 1;
- break;
-
- default:
- /* oh well... */
- return SDL_SetError("Error setting audio parameters: %s",
- strerror(errno));
- }
- }
-#endif /* AUDIO_SETINFO */
- this->hidden->written = 0;
-
- /* We can actually convert on-the-fly to U-Law */
- if (this->hidden->ulaw_only) {
- this->spec.freq = desired_freq;
- this->hidden->fragsize = (this->spec.samples * 1000) /
- (this->spec.freq / 8);
- this->hidden->frequency = 8;
- this->hidden->ulaw_buf = (Uint8 *) SDL_malloc(this->hidden->fragsize);
- if (this->hidden->ulaw_buf == NULL) {
- return SDL_OutOfMemory();
- }
- this->spec.channels = 1;
- } else {
- this->hidden->fragsize = this->spec.samples;
- this->hidden->frequency = this->spec.freq / 1000;
- }
-#ifdef DEBUG_AUDIO
- fprintf(stderr, "Audio device %s U-Law only\n",
- this->hidden->ulaw_only ? "is" : "is not");
- fprintf(stderr, "format=0x%x chan=%d freq=%d\n",
- this->spec.format, this->spec.channels, this->spec.freq);
-#endif
-
- /* Update the fragment size as size in bytes */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate mixing buffer */
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
-
- /* We're ready to rock and roll. :-) */
- return 0;
-}
-
-/************************************************************************/
-/* This function (snd2au()) copyrighted: */
-/************************************************************************/
-/* Copyright 1989 by Rich Gopstein and Harris Corporation */
-/* */
-/* Permission to use, copy, modify, and distribute this software */
-/* and its documentation for any purpose and without fee is */
-/* hereby granted, provided that the above copyright notice */
-/* appears in all copies and that both that copyright notice and */
-/* this permission notice appear in supporting documentation, and */
-/* that the name of Rich Gopstein and Harris Corporation not be */
-/* used in advertising or publicity pertaining to distribution */
-/* of the software without specific, written prior permission. */
-/* Rich Gopstein and Harris Corporation make no representations */
-/* about the suitability of this software for any purpose. It */
-/* provided "as is" without express or implied warranty. */
-/************************************************************************/
-
-static Uint8
-snd2au(int sample)
-{
-
- int mask;
-
- if (sample < 0) {
- sample = -sample;
- mask = 0x7f;
- } else {
- mask = 0xff;
- }
-
- if (sample < 32) {
- sample = 0xF0 | (15 - sample / 2);
- } else if (sample < 96) {
- sample = 0xE0 | (15 - (sample - 32) / 4);
- } else if (sample < 224) {
- sample = 0xD0 | (15 - (sample - 96) / 8);
- } else if (sample < 480) {
- sample = 0xC0 | (15 - (sample - 224) / 16);
- } else if (sample < 992) {
- sample = 0xB0 | (15 - (sample - 480) / 32);
- } else if (sample < 2016) {
- sample = 0xA0 | (15 - (sample - 992) / 64);
- } else if (sample < 4064) {
- sample = 0x90 | (15 - (sample - 2016) / 128);
- } else if (sample < 8160) {
- sample = 0x80 | (15 - (sample - 4064) / 256);
- } else {
- sample = 0x80;
- }
- return (mask & sample);
-}
-
-static int
-SUNAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->DetectDevices = SUNAUDIO_DetectDevices;
- impl->OpenDevice = SUNAUDIO_OpenDevice;
- impl->PlayDevice = SUNAUDIO_PlayDevice;
- impl->WaitDevice = SUNAUDIO_WaitDevice;
- impl->GetDeviceBuf = SUNAUDIO_GetDeviceBuf;
- impl->CloseDevice = SUNAUDIO_CloseDevice;
-
- impl->AllowsArbitraryDeviceNames = 1;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap SUNAUDIO_bootstrap = {
- "audio", "UNIX /dev/audio interface", SUNAUDIO_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_SUNAUDIO */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/sun/SDL_sunaudio.h b/3rdparty/SDL2/src/audio/sun/SDL_sunaudio.h
deleted file mode 100644
index ecced0f5109..00000000000
--- a/3rdparty/SDL2/src/audio/sun/SDL_sunaudio.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_sunaudio_h
-#define _SDL_sunaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- /* The file descriptor for the audio device */
- int audio_fd;
-
- SDL_AudioFormat audio_fmt; /* The app audio format */
- Uint8 *mixbuf; /* The app mixing buffer */
- int ulaw_only; /* Flag -- does hardware only output U-law? */
- Uint8 *ulaw_buf; /* The U-law mixing buffer */
- Sint32 written; /* The number of samples written */
- int fragsize; /* The audio fragment size in samples */
- int frequency; /* The audio frequency in KHz */
-};
-
-#endif /* _SDL_sunaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/winmm/SDL_winmm.c b/3rdparty/SDL2/src/audio/winmm/SDL_winmm.c
deleted file mode 100644
index 34f543ddb33..00000000000
--- a/3rdparty/SDL2/src/audio/winmm/SDL_winmm.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_WINMM
-
-/* Allow access to a raw mixing buffer */
-
-#include "../../core/windows/SDL_windows.h"
-#include <mmsystem.h>
-
-#include "SDL_assert.h"
-#include "SDL_timer.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_winmm.h"
-
-#ifndef WAVE_FORMAT_IEEE_FLOAT
-#define WAVE_FORMAT_IEEE_FLOAT 0x0003
-#endif
-
-#define DETECT_DEV_IMPL(iscap, typ, capstyp) \
-static void DetectWave##typ##Devs(void) { \
- const UINT iscapture = iscap ? 1 : 0; \
- const UINT devcount = wave##typ##GetNumDevs(); \
- capstyp##2W caps; \
- UINT i; \
- for (i = 0; i < devcount; i++) { \
- if (wave##typ##GetDevCaps(i,(LP##capstyp##W)&caps,sizeof(caps))==MMSYSERR_NOERROR) { \
- char *name = WIN_LookupAudioDeviceName(caps.szPname,&caps.NameGuid); \
- if (name != NULL) { \
- SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i+1)); \
- SDL_free(name); \
- } \
- } \
- } \
-}
-
-DETECT_DEV_IMPL(SDL_FALSE, Out, WAVEOUTCAPS)
-DETECT_DEV_IMPL(SDL_TRUE, In, WAVEINCAPS)
-
-static void
-WINMM_DetectDevices(void)
-{
- DetectWaveInDevs();
- DetectWaveOutDevs();
-}
-
-static void CALLBACK
-CaptureSound(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance,
- DWORD_PTR dwParam1, DWORD_PTR dwParam2)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance;
-
- /* Only service "buffer is filled" messages */
- if (uMsg != WIM_DATA)
- return;
-
- /* Signal that we have a new buffer of data */
- ReleaseSemaphore(this->hidden->audio_sem, 1, NULL);
-}
-
-
-/* The Win32 callback for filling the WAVE device */
-static void CALLBACK
-FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
- DWORD_PTR dwParam1, DWORD_PTR dwParam2)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance;
-
- /* Only service "buffer done playing" messages */
- if (uMsg != WOM_DONE)
- return;
-
- /* Signal that we are done playing a buffer */
- ReleaseSemaphore(this->hidden->audio_sem, 1, NULL);
-}
-
-static int
-SetMMerror(char *function, MMRESULT code)
-{
- int len;
- char errbuf[MAXERRORLENGTH];
- wchar_t werrbuf[MAXERRORLENGTH];
-
- SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
- len = SDL_static_cast(int, SDL_strlen(errbuf));
-
- waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len);
- WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len,
- MAXERRORLENGTH - len, NULL, NULL);
-
- return SDL_SetError("%s", errbuf);
-}
-
-static void
-WINMM_WaitDevice(_THIS)
-{
- /* Wait for an audio chunk to finish */
- WaitForSingleObject(this->hidden->audio_sem, INFINITE);
-}
-
-static Uint8 *
-WINMM_GetDeviceBuf(_THIS)
-{
- return (Uint8 *) (this->hidden->
- wavebuf[this->hidden->next_buffer].lpData);
-}
-
-static void
-WINMM_PlayDevice(_THIS)
-{
- /* Queue it up */
- waveOutWrite(this->hidden->hout,
- &this->hidden->wavebuf[this->hidden->next_buffer],
- sizeof(this->hidden->wavebuf[0]));
- this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS;
-}
-
-static int
-WINMM_CaptureFromDevice(_THIS, void *buffer, int buflen)
-{
- const int nextbuf = this->hidden->next_buffer;
- MMRESULT result;
-
- SDL_assert(buflen == this->spec.size);
-
- /* Wait for an audio chunk to finish */
- WaitForSingleObject(this->hidden->audio_sem, INFINITE);
-
- /* Copy it to caller's buffer... */
- SDL_memcpy(buffer, this->hidden->wavebuf[nextbuf].lpData, this->spec.size);
-
- /* requeue the buffer that just finished. */
- result = waveInAddBuffer(this->hidden->hin,
- &this->hidden->wavebuf[nextbuf],
- sizeof (this->hidden->wavebuf[nextbuf]));
- if (result != MMSYSERR_NOERROR) {
- return -1; /* uhoh! Disable the device. */
- }
-
- /* queue the next buffer in sequence, next time. */
- this->hidden->next_buffer = (nextbuf + 1) % NUM_BUFFERS;
- return this->spec.size;
-}
-
-static void
-WINMM_FlushCapture(_THIS)
-{
- /* Wait for an audio chunk to finish */
- if (WaitForSingleObject(this->hidden->audio_sem, 0) == WAIT_OBJECT_0) {
- const int nextbuf = this->hidden->next_buffer;
- /* requeue the buffer that just finished without reading from it. */
- waveInAddBuffer(this->hidden->hin,
- &this->hidden->wavebuf[nextbuf],
- sizeof (this->hidden->wavebuf[nextbuf]));
- this->hidden->next_buffer = (nextbuf + 1) % NUM_BUFFERS;
- }
-}
-
-static void
-WINMM_CloseDevice(_THIS)
-{
- int i;
-
- if (this->hidden->hout) {
- waveOutReset(this->hidden->hout);
-
- /* Clean up mixing buffers */
- for (i = 0; i < NUM_BUFFERS; ++i) {
- if (this->hidden->wavebuf[i].dwUser != 0xFFFF) {
- waveOutUnprepareHeader(this->hidden->hout,
- &this->hidden->wavebuf[i],
- sizeof (this->hidden->wavebuf[i]));
- }
- }
-
- waveOutClose(this->hidden->hout);
- }
-
- if (this->hidden->hin) {
- waveInReset(this->hidden->hin);
-
- /* Clean up mixing buffers */
- for (i = 0; i < NUM_BUFFERS; ++i) {
- if (this->hidden->wavebuf[i].dwUser != 0xFFFF) {
- waveInUnprepareHeader(this->hidden->hin,
- &this->hidden->wavebuf[i],
- sizeof (this->hidden->wavebuf[i]));
- }
- }
- waveInClose(this->hidden->hin);
- }
-
- if (this->hidden->audio_sem) {
- CloseHandle(this->hidden->audio_sem);
- }
-
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static SDL_bool
-PrepWaveFormat(_THIS, UINT devId, WAVEFORMATEX *pfmt, const int iscapture)
-{
- SDL_zerop(pfmt);
-
- if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
- pfmt->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- pfmt->wFormatTag = WAVE_FORMAT_PCM;
- }
- pfmt->wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
-
- pfmt->nChannels = this->spec.channels;
- pfmt->nSamplesPerSec = this->spec.freq;
- pfmt->nBlockAlign = pfmt->nChannels * (pfmt->wBitsPerSample / 8);
- pfmt->nAvgBytesPerSec = pfmt->nSamplesPerSec * pfmt->nBlockAlign;
-
- if (iscapture) {
- return (waveInOpen(0, devId, pfmt, 0, 0, WAVE_FORMAT_QUERY) == 0);
- } else {
- return (waveOutOpen(0, devId, pfmt, 0, 0, WAVE_FORMAT_QUERY) == 0);
- }
-}
-
-static int
-WINMM_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
- int valid_datatype = 0;
- MMRESULT result;
- WAVEFORMATEX waveformat;
- UINT devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */
- UINT i;
-
- if (handle != NULL) { /* specific device requested? */
- /* -1 because we increment the original value to avoid NULL. */
- const size_t val = ((size_t) handle) - 1;
- devId = (UINT) val;
- }
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- /* Initialize the wavebuf structures for closing */
- for (i = 0; i < NUM_BUFFERS; ++i)
- this->hidden->wavebuf[i].dwUser = 0xFFFF;
-
- if (this->spec.channels > 2)
- this->spec.channels = 2; /* !!! FIXME: is this right? */
-
- while ((!valid_datatype) && (test_format)) {
- switch (test_format) {
- case AUDIO_U8:
- case AUDIO_S16:
- case AUDIO_S32:
- case AUDIO_F32:
- this->spec.format = test_format;
- if (PrepWaveFormat(this, devId, &waveformat, iscapture)) {
- valid_datatype = 1;
- } else {
- test_format = SDL_NextAudioFormat();
- }
- break;
-
- default:
- test_format = SDL_NextAudioFormat();
- break;
- }
- }
-
- if (!valid_datatype) {
- return SDL_SetError("Unsupported audio format");
- }
-
- /* Update the fragment size as size in bytes */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Open the audio device */
- if (iscapture) {
- result = waveInOpen(&this->hidden->hin, devId, &waveformat,
- (DWORD_PTR) CaptureSound, (DWORD_PTR) this,
- CALLBACK_FUNCTION);
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveInOpen()", result);
- }
- } else {
- result = waveOutOpen(&this->hidden->hout, devId, &waveformat,
- (DWORD_PTR) FillSound, (DWORD_PTR) this,
- CALLBACK_FUNCTION);
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveOutOpen()", result);
- }
- }
-
-#ifdef SOUND_DEBUG
- /* Check the sound device we retrieved */
- {
- if (iscapture) {
- WAVEINCAPS caps;
- result = waveInGetDevCaps((UINT) this->hidden->hout,
- &caps, sizeof (caps));
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveInGetDevCaps()", result);
- }
- printf("Audio device: %s\n", caps.szPname);
- } else {
- WAVEOUTCAPS caps;
- result = waveOutGetDevCaps((UINT) this->hidden->hout,
- &caps, sizeof(caps));
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveOutGetDevCaps()", result);
- }
- printf("Audio device: %s\n", caps.szPname);
- }
- }
-#endif
-
- /* Create the audio buffer semaphore */
- this->hidden->audio_sem =
- CreateSemaphore(NULL, iscapture ? 0 : NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
- if (this->hidden->audio_sem == NULL) {
- return SDL_SetError("Couldn't create semaphore");
- }
-
- /* Create the sound buffers */
- this->hidden->mixbuf =
- (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
-
- SDL_zero(this->hidden->wavebuf);
- for (i = 0; i < NUM_BUFFERS; ++i) {
- this->hidden->wavebuf[i].dwBufferLength = this->spec.size;
- this->hidden->wavebuf[i].dwFlags = WHDR_DONE;
- this->hidden->wavebuf[i].lpData =
- (LPSTR) & this->hidden->mixbuf[i * this->spec.size];
-
- if (iscapture) {
- result = waveInPrepareHeader(this->hidden->hin,
- &this->hidden->wavebuf[i],
- sizeof(this->hidden->wavebuf[i]));
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveInPrepareHeader()", result);
- }
-
- result = waveInAddBuffer(this->hidden->hin,
- &this->hidden->wavebuf[i],
- sizeof(this->hidden->wavebuf[i]));
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveInAddBuffer()", result);
- }
- } else {
- result = waveOutPrepareHeader(this->hidden->hout,
- &this->hidden->wavebuf[i],
- sizeof(this->hidden->wavebuf[i]));
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveOutPrepareHeader()", result);
- }
- }
- }
-
- if (iscapture) {
- result = waveInStart(this->hidden->hin);
- if (result != MMSYSERR_NOERROR) {
- return SetMMerror("waveInStart()", result);
- }
- }
-
- return 0; /* Ready to go! */
-}
-
-
-static int
-WINMM_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->DetectDevices = WINMM_DetectDevices;
- impl->OpenDevice = WINMM_OpenDevice;
- impl->PlayDevice = WINMM_PlayDevice;
- impl->WaitDevice = WINMM_WaitDevice;
- impl->GetDeviceBuf = WINMM_GetDeviceBuf;
- impl->CaptureFromDevice = WINMM_CaptureFromDevice;
- impl->FlushCapture = WINMM_FlushCapture;
- impl->CloseDevice = WINMM_CloseDevice;
-
- impl->HasCaptureSupport = SDL_TRUE;
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap WINMM_bootstrap = {
- "winmm", "Windows Waveform Audio", WINMM_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_WINMM */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/winmm/SDL_winmm.h b/3rdparty/SDL2/src/audio/winmm/SDL_winmm.h
deleted file mode 100644
index 401db398b68..00000000000
--- a/3rdparty/SDL2/src/audio/winmm/SDL_winmm.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifndef _SDL_winmm_h
-#define _SDL_winmm_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-#define NUM_BUFFERS 2 /* -- Don't lower this! */
-
-struct SDL_PrivateAudioData
-{
- HWAVEOUT hout;
- HWAVEIN hin;
- HANDLE audio_sem;
- Uint8 *mixbuf; /* The raw allocated mixing buffer */
- WAVEHDR wavebuf[NUM_BUFFERS]; /* Wave audio fragments */
- int next_buffer;
-};
-
-#endif /* _SDL_winmm_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.c b/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.c
deleted file mode 100644
index a18e5d24ec8..00000000000
--- a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-/* WinRT NOTICE:
-
- A few changes to SDL's XAudio2 backend were warranted by API
- changes to Windows. Many, but not all of these are documented by Microsoft
- at:
- http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx
-
- 1. Windows' thread synchronization function, CreateSemaphore, was removed
- from WinRT. SDL's semaphore API was substituted instead.
- 2. The method calls, IXAudio2::GetDeviceCount and IXAudio2::GetDeviceDetails
- were removed from the XAudio2 API. Microsoft is telling developers to
- use APIs in Windows::Foundation instead.
- For SDL, the missing methods were reimplemented using the APIs Microsoft
- said to use.
- 3. CoInitialize and CoUninitialize are not available in WinRT.
- These calls were removed, as COM will have been initialized earlier,
- at least by the call to the WinRT app's main function
- (aka 'int main(Platform::Array<Platform::String^>^)). (DLudwig:
- This was my understanding of how WinRT: the 'main' function uses
- a tag of [MTAThread], which should initialize COM. My understanding
- of COM is somewhat limited, and I may be incorrect here.)
- 4. IXAudio2::CreateMasteringVoice changed its integer-based 'DeviceIndex'
- argument to a string-based one, 'szDeviceId'. In WinRT, the
- string-based argument will be used.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_XAUDIO2
-
-#include "../../core/windows/SDL_windows.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_assert.h"
-
-#ifdef __GNUC__
-/* The configure script already did any necessary checking */
-# define SDL_XAUDIO2_HAS_SDK 1
-#elif defined(__WINRT__)
-/* WinRT always has access to the XAudio 2 SDK (albeit with a header file
- that doesn't compile as C code).
-*/
-# define SDL_XAUDIO2_HAS_SDK
-#include "SDL_xaudio2.h" /* ... compiles as C code, in contrast to XAudio2 headers
- in the Windows SDK, v.10.0.10240.0 (Win 10's initial SDK)
- */
-#else
-/* XAudio2 exists in the last DirectX SDK as well as the latest Windows SDK.
- To enable XAudio2 support, you will need to add the location of your DirectX SDK headers to
- the SDL projects additional include directories and then set SDL_XAUDIO2_HAS_SDK=1 as a
- preprocessor define
- */
-#if 0 /* See comment above */
-#include <dxsdkver.h>
-#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
-# pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.")
-#else
-# define SDL_XAUDIO2_HAS_SDK 1
-#endif
-#endif
-#endif /* 0 */
-
-#ifdef SDL_XAUDIO2_HAS_SDK
-
-/* Check to see if we're compiling for XAudio 2.8, or higher. */
-#ifdef WINVER
-#if WINVER >= 0x0602 /* Windows 8 SDK or higher? */
-#define SDL_XAUDIO2_WIN8 1
-#endif
-#endif
-
-#if !defined(_SDL_XAUDIO2_H)
-#define INITGUID 1
-#include <xaudio2.h>
-#endif
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-#ifdef __WINRT__
-#include "SDL_xaudio2_winrthelpers.h"
-#endif
-
-/* Fixes bug 1210 where some versions of gcc need named parameters */
-#ifdef __GNUC__
-#ifdef THIS
-#undef THIS
-#endif
-#define THIS INTERFACE *p
-#ifdef THIS_
-#undef THIS_
-#endif
-#define THIS_ INTERFACE *p,
-#endif
-
-struct SDL_PrivateAudioData
-{
- IXAudio2 *ixa2;
- IXAudio2SourceVoice *source;
- IXAudio2MasteringVoice *mastering;
- SDL_sem * semaphore;
- Uint8 *mixbuf;
- int mixlen;
- Uint8 *nextbuf;
-};
-
-
-static void
-XAUDIO2_DetectDevices(void)
-{
- IXAudio2 *ixa2 = NULL;
- UINT32 devcount = 0;
- UINT32 i = 0;
-
- if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
- SDL_SetError("XAudio2: XAudio2Create() failed at detection.");
- return;
- } else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
- SDL_SetError("XAudio2: IXAudio2::GetDeviceCount() failed.");
- IXAudio2_Release(ixa2);
- return;
- }
-
- for (i = 0; i < devcount; i++) {
- XAUDIO2_DEVICE_DETAILS details;
- if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
- char *str = WIN_StringToUTF8(details.DisplayName);
- if (str != NULL) {
- SDL_AddAudioDevice(SDL_FALSE, str, (void *) ((size_t) i+1));
- SDL_free(str); /* SDL_AddAudioDevice made a copy of the string. */
- }
- }
- }
-
- IXAudio2_Release(ixa2);
-}
-
-static void STDMETHODCALLTYPE
-VoiceCBOnBufferEnd(THIS_ void *data)
-{
- /* Just signal the SDL audio thread and get out of XAudio2's way. */
- SDL_AudioDevice *this = (SDL_AudioDevice *) data;
- SDL_SemPost(this->hidden->semaphore);
-}
-
-static void STDMETHODCALLTYPE
-VoiceCBOnVoiceError(THIS_ void *data, HRESULT Error)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) data;
- SDL_OpenedAudioDeviceDisconnected(this);
-}
-
-/* no-op callbacks... */
-static void STDMETHODCALLTYPE VoiceCBOnStreamEnd(THIS) {}
-static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassStart(THIS_ UINT32 b) {}
-static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassEnd(THIS) {}
-static void STDMETHODCALLTYPE VoiceCBOnBufferStart(THIS_ void *data) {}
-static void STDMETHODCALLTYPE VoiceCBOnLoopEnd(THIS_ void *data) {}
-
-
-static Uint8 *
-XAUDIO2_GetDeviceBuf(_THIS)
-{
- return this->hidden->nextbuf;
-}
-
-static void
-XAUDIO2_PlayDevice(_THIS)
-{
- XAUDIO2_BUFFER buffer;
- Uint8 *mixbuf = this->hidden->mixbuf;
- Uint8 *nextbuf = this->hidden->nextbuf;
- const int mixlen = this->hidden->mixlen;
- IXAudio2SourceVoice *source = this->hidden->source;
- HRESULT result = S_OK;
-
- if (!SDL_AtomicGet(&this->enabled)) { /* shutting down? */
- return;
- }
-
- /* Submit the next filled buffer */
- SDL_zero(buffer);
- buffer.AudioBytes = mixlen;
- buffer.pAudioData = nextbuf;
- buffer.pContext = this;
-
- if (nextbuf == mixbuf) {
- nextbuf += mixlen;
- } else {
- nextbuf = mixbuf;
- }
- this->hidden->nextbuf = nextbuf;
-
- result = IXAudio2SourceVoice_SubmitSourceBuffer(source, &buffer, NULL);
- if (result == XAUDIO2_E_DEVICE_INVALIDATED) {
- /* !!! FIXME: possibly disconnected or temporary lost. Recover? */
- }
-
- if (result != S_OK) { /* uhoh, panic! */
- IXAudio2SourceVoice_FlushSourceBuffers(source);
- SDL_OpenedAudioDeviceDisconnected(this);
- }
-}
-
-static void
-XAUDIO2_WaitDevice(_THIS)
-{
- if (SDL_AtomicGet(&this->enabled)) {
- SDL_SemWait(this->hidden->semaphore);
- }
-}
-
-static void
-XAUDIO2_PrepareToClose(_THIS)
-{
- IXAudio2SourceVoice *source = this->hidden->source;
- if (source) {
- IXAudio2SourceVoice_Discontinuity(source);
- }
-}
-
-static void
-XAUDIO2_CloseDevice(_THIS)
-{
- IXAudio2 *ixa2 = this->hidden->ixa2;
- IXAudio2SourceVoice *source = this->hidden->source;
- IXAudio2MasteringVoice *mastering = this->hidden->mastering;
-
- if (source != NULL) {
- IXAudio2SourceVoice_Stop(source, 0, XAUDIO2_COMMIT_NOW);
- IXAudio2SourceVoice_FlushSourceBuffers(source);
- IXAudio2SourceVoice_DestroyVoice(source);
- }
- if (ixa2 != NULL) {
- IXAudio2_StopEngine(ixa2);
- }
- if (mastering != NULL) {
- IXAudio2MasteringVoice_DestroyVoice(mastering);
- }
- if (ixa2 != NULL) {
- IXAudio2_Release(ixa2);
- }
- if (this->hidden->semaphore != NULL) {
- SDL_DestroySemaphore(this->hidden->semaphore);
- }
-
- SDL_free(this->hidden->mixbuf);
- SDL_free(this->hidden);
-}
-
-static int
-XAUDIO2_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
-{
- HRESULT result = S_OK;
- WAVEFORMATEX waveformat;
- int valid_format = 0;
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
- IXAudio2 *ixa2 = NULL;
- IXAudio2SourceVoice *source = NULL;
-#if defined(SDL_XAUDIO2_WIN8)
- LPCWSTR devId = NULL;
-#else
- UINT32 devId = 0; /* 0 == system default device. */
-#endif
-
- static IXAudio2VoiceCallbackVtbl callbacks_vtable = {
- VoiceCBOnVoiceProcessPassStart,
- VoiceCBOnVoiceProcessPassEnd,
- VoiceCBOnStreamEnd,
- VoiceCBOnBufferStart,
- VoiceCBOnBufferEnd,
- VoiceCBOnLoopEnd,
- VoiceCBOnVoiceError
- };
-
- static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
-
-#if defined(SDL_XAUDIO2_WIN8)
- /* !!! FIXME: hook up hotplugging. */
-#else
- if (handle != NULL) { /* specific device requested? */
- /* -1 because we increment the original value to avoid NULL. */
- const size_t val = ((size_t) handle) - 1;
- devId = (UINT32) val;
- }
-#endif
-
- if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
- return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
- }
-
- /*
- XAUDIO2_DEBUG_CONFIGURATION debugConfig;
- debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_FUNC_CALLS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING;
- debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS;
- debugConfig.LogThreadID = TRUE;
- debugConfig.LogFileline = TRUE;
- debugConfig.LogFunctionName = TRUE;
- debugConfig.LogTiming = TRUE;
- ixa2->SetDebugConfiguration(&debugConfig);
- */
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- IXAudio2_Release(ixa2);
- return SDL_OutOfMemory();
- }
- SDL_zerop(this->hidden);
-
- this->hidden->ixa2 = ixa2;
- this->hidden->semaphore = SDL_CreateSemaphore(1);
- if (this->hidden->semaphore == NULL) {
- return SDL_SetError("XAudio2: CreateSemaphore() failed!");
- }
-
- while ((!valid_format) && (test_format)) {
- switch (test_format) {
- case AUDIO_U8:
- case AUDIO_S16:
- case AUDIO_S32:
- case AUDIO_F32:
- this->spec.format = test_format;
- valid_format = 1;
- break;
- }
- test_format = SDL_NextAudioFormat();
- }
-
- if (!valid_format) {
- return SDL_SetError("XAudio2: Unsupported audio format");
- }
-
- /* Update the fragment size as size in bytes */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* We feed a Source, it feeds the Mastering, which feeds the device. */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(2 * this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- return SDL_OutOfMemory();
- }
- this->hidden->nextbuf = this->hidden->mixbuf;
- SDL_memset(this->hidden->mixbuf, this->spec.silence, 2 * this->hidden->mixlen);
-
- /* We use XAUDIO2_DEFAULT_CHANNELS instead of this->spec.channels. On
- Xbox360, this means 5.1 output, but on Windows, it means "figure out
- what the system has." It might be preferable to let XAudio2 blast
- stereo output to appropriate surround sound configurations
- instead of clamping to 2 channels, even though we'll configure the
- Source Voice for whatever number of channels you supply. */
-#if SDL_XAUDIO2_WIN8
- result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
- XAUDIO2_DEFAULT_CHANNELS,
- this->spec.freq, 0, devId, NULL, AudioCategory_GameEffects);
-#else
- result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
- XAUDIO2_DEFAULT_CHANNELS,
- this->spec.freq, 0, devId, NULL);
-#endif
- if (result != S_OK) {
- return SDL_SetError("XAudio2: Couldn't create mastering voice");
- }
-
- SDL_zero(waveformat);
- if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
- waveformat.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- waveformat.wFormatTag = WAVE_FORMAT_PCM;
- }
- waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
- waveformat.nChannels = this->spec.channels;
- waveformat.nSamplesPerSec = this->spec.freq;
- waveformat.nBlockAlign =
- waveformat.nChannels * (waveformat.wBitsPerSample / 8);
- waveformat.nAvgBytesPerSec =
- waveformat.nSamplesPerSec * waveformat.nBlockAlign;
- waveformat.cbSize = sizeof(waveformat);
-
-#ifdef __WINRT__
- // DLudwig: for now, make XAudio2 do sample rate conversion, just to
- // get the loopwave test to work.
- //
- // TODO, WinRT: consider removing WinRT-specific source-voice creation code from SDL_xaudio2.c
- result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
- 0,
- 1.0f, &callbacks, NULL, NULL);
-#else
- result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
- XAUDIO2_VOICE_NOSRC |
- XAUDIO2_VOICE_NOPITCH,
- 1.0f, &callbacks, NULL, NULL);
-
-#endif
- if (result != S_OK) {
- return SDL_SetError("XAudio2: Couldn't create source voice");
- }
- this->hidden->source = source;
-
- /* Start everything playing! */
- result = IXAudio2_StartEngine(ixa2);
- if (result != S_OK) {
- return SDL_SetError("XAudio2: Couldn't start engine");
- }
-
- result = IXAudio2SourceVoice_Start(source, 0, XAUDIO2_COMMIT_NOW);
- if (result != S_OK) {
- return SDL_SetError("XAudio2: Couldn't start source voice");
- }
-
- return 0; /* good to go. */
-}
-
-static void
-XAUDIO2_Deinitialize(void)
-{
-#if defined(__WIN32__)
- WIN_CoUninitialize();
-#endif
-}
-
-#endif /* SDL_XAUDIO2_HAS_SDK */
-
-
-static int
-XAUDIO2_Init(SDL_AudioDriverImpl * impl)
-{
-#ifndef SDL_XAUDIO2_HAS_SDK
- SDL_SetError("XAudio2: SDL was built without XAudio2 support (old DirectX SDK).");
- return 0; /* no XAudio2 support, ever. Update your SDK! */
-#else
- /* XAudio2Create() is a macro that uses COM; we don't load the .dll */
- IXAudio2 *ixa2 = NULL;
-#if defined(__WIN32__)
- // TODO, WinRT: Investigate using CoInitializeEx here
- if (FAILED(WIN_CoInitialize())) {
- SDL_SetError("XAudio2: CoInitialize() failed");
- return 0;
- }
-#endif
-
- if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
-#if defined(__WIN32__)
- WIN_CoUninitialize();
-#endif
- SDL_SetError("XAudio2: XAudio2Create() failed at initialization");
- return 0; /* not available. */
- }
- IXAudio2_Release(ixa2);
-
- /* Set the function pointers */
- impl->DetectDevices = XAUDIO2_DetectDevices;
- impl->OpenDevice = XAUDIO2_OpenDevice;
- impl->PlayDevice = XAUDIO2_PlayDevice;
- impl->WaitDevice = XAUDIO2_WaitDevice;
- impl->PrepareToClose = XAUDIO2_PrepareToClose;
- impl->GetDeviceBuf = XAUDIO2_GetDeviceBuf;
- impl->CloseDevice = XAUDIO2_CloseDevice;
- impl->Deinitialize = XAUDIO2_Deinitialize;
-
- /* !!! FIXME: We can apparently use a C++ interface on Windows 8
- * !!! FIXME: (Windows::Devices::Enumeration::DeviceInformation) for device
- * !!! FIXME: detection, but it's not implemented here yet.
- * !!! FIXME: see http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx
- * !!! FIXME: for now, force the default device.
- */
-#if defined(SDL_XAUDIO2_WIN8) || defined(__WINRT__)
- impl->OnlyHasDefaultOutputDevice = 1;
-#endif
-
- return 1; /* this audio target is available. */
-#endif
-}
-
-AudioBootStrap XAUDIO2_bootstrap = {
- "xaudio2", "XAudio2", XAUDIO2_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_XAUDIO2 */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.h b/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.h
deleted file mode 100644
index 864eba451d3..00000000000
--- a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2.h
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#ifndef _SDL_XAUDIO2_H
-#define _SDL_XAUDIO2_H
-
-#include <windows.h>
-#include <mmreg.h>
-#include <objbase.h>
-
-/* XAudio2 packs its structure members together as tightly as possible.
- This pragma is needed to ensure compatibility with XAudio2 on 64-bit
- platforms.
-*/
-#pragma pack(push, 1)
-
-typedef interface IXAudio2 IXAudio2;
-typedef interface IXAudio2SourceVoice IXAudio2SourceVoice;
-typedef interface IXAudio2MasteringVoice IXAudio2MasteringVoice;
-typedef interface IXAudio2EngineCallback IXAudio2EngineCallback;
-typedef interface IXAudio2VoiceCallback IXAudio2VoiceCallback;
-typedef interface IXAudio2Voice IXAudio2Voice;
-typedef interface IXAudio2SubmixVoice IXAudio2SubmixVoice;
-
-typedef enum _AUDIO_STREAM_CATEGORY {
- AudioCategory_Other = 0,
- AudioCategory_ForegroundOnlyMedia,
- AudioCategory_BackgroundCapableMedia,
- AudioCategory_Communications,
- AudioCategory_Alerts,
- AudioCategory_SoundEffects,
- AudioCategory_GameEffects,
- AudioCategory_GameMedia,
- AudioCategory_GameChat,
- AudioCategory_Movie,
- AudioCategory_Media
-} AUDIO_STREAM_CATEGORY;
-
-typedef struct XAUDIO2_BUFFER {
- UINT32 Flags;
- UINT32 AudioBytes;
- const BYTE *pAudioData;
- UINT32 PlayBegin;
- UINT32 PlayLength;
- UINT32 LoopBegin;
- UINT32 LoopLength;
- UINT32 LoopCount;
- void *pContext;
-} XAUDIO2_BUFFER;
-
-typedef struct XAUDIO2_BUFFER_WMA {
- const UINT32 *pDecodedPacketCumulativeBytes;
- UINT32 PacketCount;
-} XAUDIO2_BUFFER_WMA;
-
-typedef struct XAUDIO2_SEND_DESCRIPTOR {
- UINT32 Flags;
- IXAudio2Voice *pOutputVoice;
-} XAUDIO2_SEND_DESCRIPTOR;
-
-typedef struct XAUDIO2_VOICE_SENDS {
- UINT32 SendCount;
- XAUDIO2_SEND_DESCRIPTOR *pSends;
-} XAUDIO2_VOICE_SENDS;
-
-typedef struct XAUDIO2_EFFECT_DESCRIPTOR {
- IUnknown *pEffect;
- BOOL InitialState;
- UINT32 OutputChannels;
-} XAUDIO2_EFFECT_DESCRIPTOR;
-
-typedef struct XAUDIO2_EFFECT_CHAIN {
- UINT32 EffectCount;
- XAUDIO2_EFFECT_DESCRIPTOR *pEffectDescriptors;
-} XAUDIO2_EFFECT_CHAIN;
-
-typedef struct XAUDIO2_PERFORMANCE_DATA {
- UINT64 AudioCyclesSinceLastQuery;
- UINT64 TotalCyclesSinceLastQuery;
- UINT32 MinimumCyclesPerQuantum;
- UINT32 MaximumCyclesPerQuantum;
- UINT32 MemoryUsageInBytes;
- UINT32 CurrentLatencyInSamples;
- UINT32 GlitchesSinceEngineStarted;
- UINT32 ActiveSourceVoiceCount;
- UINT32 TotalSourceVoiceCount;
- UINT32 ActiveSubmixVoiceCount;
- UINT32 ActiveResamplerCount;
- UINT32 ActiveMatrixMixCount;
- UINT32 ActiveXmaSourceVoices;
- UINT32 ActiveXmaStreams;
-} XAUDIO2_PERFORMANCE_DATA;
-
-typedef struct XAUDIO2_DEBUG_CONFIGURATION {
- UINT32 TraceMask;
- UINT32 BreakMask;
- BOOL LogThreadID;
- BOOL LogFileline;
- BOOL LogFunctionName;
- BOOL LogTiming;
-} XAUDIO2_DEBUG_CONFIGURATION;
-
-typedef struct XAUDIO2_VOICE_DETAILS {
- UINT32 CreationFlags;
- UINT32 ActiveFlags;
- UINT32 InputChannels;
- UINT32 InputSampleRate;
-} XAUDIO2_VOICE_DETAILS;
-
-typedef enum XAUDIO2_FILTER_TYPE {
- LowPassFilter = 0,
- BandPassFilter = 1,
- HighPassFilter = 2,
- NotchFilter = 3,
- LowPassOnePoleFilter = 4,
- HighPassOnePoleFilter = 5
-} XAUDIO2_FILTER_TYPE;
-
-typedef struct XAUDIO2_FILTER_PARAMETERS {
- XAUDIO2_FILTER_TYPE Type;
- float Frequency;
- float OneOverQ;
-} XAUDIO2_FILTER_PARAMETERS;
-
-typedef struct XAUDIO2_VOICE_STATE {
- void *pCurrentBufferContext;
- UINT32 BuffersQueued;
- UINT64 SamplesPlayed;
-} XAUDIO2_VOICE_STATE;
-
-
-typedef UINT32 XAUDIO2_PROCESSOR;
-#define Processor1 0x00000001
-#define XAUDIO2_DEFAULT_PROCESSOR Processor1
-
-#define XAUDIO2_E_DEVICE_INVALIDATED 0x88960004
-#define XAUDIO2_COMMIT_NOW 0
-#define XAUDIO2_VOICE_NOSAMPLESPLAYED 0x0100
-#define XAUDIO2_DEFAULT_CHANNELS 0
-
-extern HRESULT __stdcall XAudio2Create(
- _Out_ IXAudio2 **ppXAudio2,
- _In_ UINT32 Flags,
- _In_ XAUDIO2_PROCESSOR XAudio2Processor
- );
-
-#undef INTERFACE
-#define INTERFACE IXAudio2
-typedef interface IXAudio2 {
- const struct IXAudio2Vtbl FAR* lpVtbl;
-} IXAudio2;
-typedef const struct IXAudio2Vtbl IXAudio2Vtbl;
-const struct IXAudio2Vtbl
-{
- /* IUnknown */
- STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
- STDMETHOD_(ULONG, AddRef)(THIS) PURE;
- STDMETHOD_(ULONG, Release)(THIS) PURE;
-
- /* IXAudio2 */
- STDMETHOD_(HRESULT, RegisterForCallbacks)(THIS, IXAudio2EngineCallback *pCallback) PURE;
- STDMETHOD_(VOID, UnregisterForCallbacks)(THIS, IXAudio2EngineCallback *pCallback) PURE;
- STDMETHOD_(HRESULT, CreateSourceVoice)(THIS, IXAudio2SourceVoice **ppSourceVoice,
- const WAVEFORMATEX *pSourceFormat,
- UINT32 Flags,
- float MaxFrequencyRatio,
- IXAudio2VoiceCallback *pCallback,
- const XAUDIO2_VOICE_SENDS *pSendList,
- const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
- STDMETHOD_(HRESULT, CreateSubmixVoice)(THIS, IXAudio2SubmixVoice **ppSubmixVoice,
- UINT32 InputChannels,
- UINT32 InputSampleRate,
- UINT32 Flags,
- UINT32 ProcessingStage,
- const XAUDIO2_VOICE_SENDS *pSendList,
- const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
- STDMETHOD_(HRESULT, CreateMasteringVoice)(THIS, IXAudio2MasteringVoice **ppMasteringVoice,
- UINT32 InputChannels,
- UINT32 InputSampleRate,
- UINT32 Flags,
- LPCWSTR szDeviceId,
- const XAUDIO2_EFFECT_CHAIN *pEffectChain,
- AUDIO_STREAM_CATEGORY StreamCategory) PURE;
- STDMETHOD_(HRESULT, StartEngine)(THIS) PURE;
- STDMETHOD_(VOID, StopEngine)(THIS) PURE;
- STDMETHOD_(HRESULT, CommitChanges)(THIS, UINT32 OperationSet) PURE;
- STDMETHOD_(HRESULT, GetPerformanceData)(THIS, XAUDIO2_PERFORMANCE_DATA *pPerfData) PURE;
- STDMETHOD_(HRESULT, SetDebugConfiguration)(THIS, XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration,
- VOID *pReserved) PURE;
-};
-
-#define IXAudio2_Release(A) ((A)->lpVtbl->Release(A))
-#define IXAudio2_CreateSourceVoice(A,B,C,D,E,F,G,H) ((A)->lpVtbl->CreateSourceVoice(A,B,C,D,E,F,G,H))
-#define IXAudio2_CreateMasteringVoice(A,B,C,D,E,F,G,H) ((A)->lpVtbl->CreateMasteringVoice(A,B,C,D,E,F,G,H))
-#define IXAudio2_StartEngine(A) ((A)->lpVtbl->StartEngine(A))
-#define IXAudio2_StopEngine(A) ((A)->lpVtbl->StopEngine(A))
-
-
-#undef INTERFACE
-#define INTERFACE IXAudio2SourceVoice
-typedef interface IXAudio2SourceVoice {
- const struct IXAudio2SourceVoiceVtbl FAR* lpVtbl;
-} IXAudio2SourceVoice;
-typedef const struct IXAudio2SourceVoiceVtbl IXAudio2SourceVoiceVtbl;
-const struct IXAudio2SourceVoiceVtbl
-{
- /* MSDN says that IXAudio2Voice inherits from IXAudio2, but MSVC's debugger
- * says otherwise, and that IXAudio2Voice doesn't inherit from any other
- * interface!
- */
-
- /* IXAudio2Voice */
- STDMETHOD_(VOID, GetVoiceDetails)(THIS, XAUDIO2_VOICE_DETAILS *pVoiceDetails) PURE;
- STDMETHOD_(HRESULT, SetOutputVoices)(THIS, const XAUDIO2_VOICE_SENDS *pSendList) PURE;
- STDMETHOD_(HRESULT, SetEffectChain)(THIS, const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
- STDMETHOD_(HRESULT, EnableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
- STDMETHOD_(HRESULT, DisableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetEffectState)(THIS, UINT32 EffectIndex, BOOL *pEnabled) PURE;
- STDMETHOD_(HRESULT, SetEffectParameters)(THIS, UINT32 EffectIndex,
- const void *pParameters,
- UINT32 ParametersByteSize,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetEffectParameters)(THIS, UINT32 EffectIndex,
- void *pParameters,
- UINT32 ParametersByteSize) PURE;
- STDMETHOD_(HRESULT, SetFilterParameters)(THIS, const XAUDIO2_FILTER_PARAMETERS *pParameters,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetFilterParameters)(THIS, XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
- STDMETHOD_(HRESULT, SetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
- XAUDIO2_FILTER_PARAMETERS *pParameters,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
- XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
- STDMETHOD_(HRESULT, SetVolume)(THIS, float Volume,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetVolume)(THIS, float *pVolume) PURE;
- STDMETHOD_(HRESULT, SetChannelVolumes)(THIS, UINT32 Channels,
- const float *pVolumes,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetChannelVolumes)(THIS, UINT32 Channels,
- float *pVolumes) PURE;
- STDMETHOD_(HRESULT, SetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
- UINT32 SourceChannels,
- UINT32 DestinationChannels,
- const float *pLevelMatrix,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
- UINT32 SourceChannels,
- UINT32 DestinationChannels,
- float *pLevelMatrix) PURE;
- STDMETHOD_(VOID, DestroyVoice)(THIS) PURE;
-
- /* IXAudio2SourceVoice */
- STDMETHOD_(HRESULT, Start)(THIS, UINT32 Flags,
- UINT32 OperationSet) PURE;
- STDMETHOD_(HRESULT, Stop)(THIS, UINT32 Flags,
- UINT32 OperationSet) PURE;
- STDMETHOD_(HRESULT, SubmitSourceBuffer)(THIS, const XAUDIO2_BUFFER *pBuffer,
- const XAUDIO2_BUFFER_WMA *pBufferWMA) PURE;
- STDMETHOD_(HRESULT, FlushSourceBuffers)(THIS) PURE;
- STDMETHOD_(HRESULT, Discontinuity)(THIS) PURE;
- STDMETHOD_(HRESULT, ExitLoop)(THIS, UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetState)(THIS, XAUDIO2_VOICE_STATE *pVoiceState,
- UINT32 Flags) PURE;
- STDMETHOD_(HRESULT, SetFrequencyRatio)(THIS, float Ratio,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetFrequencyRatio)(THIS, float *pRatio) PURE;
- STDMETHOD_(HRESULT, SetSourceSampleRate)(THIS, UINT32 NewSourceSampleRate) PURE;
-};
-
-#define IXAudio2SourceVoice_DestroyVoice(A) ((A)->lpVtbl->DestroyVoice(A))
-#define IXAudio2SourceVoice_Start(A,B,C) ((A)->lpVtbl->Start(A,B,C))
-#define IXAudio2SourceVoice_Stop(A,B,C) ((A)->lpVtbl->Stop(A,B,C))
-#define IXAudio2SourceVoice_SubmitSourceBuffer(A,B,C) ((A)->lpVtbl->SubmitSourceBuffer(A,B,C))
-#define IXAudio2SourceVoice_FlushSourceBuffers(A) ((A)->lpVtbl->FlushSourceBuffers(A))
-#define IXAudio2SourceVoice_Discontinuity(A) ((A)->lpVtbl->Discontinuity(A))
-#define IXAudio2SourceVoice_GetState(A,B,C) ((A)->lpVtbl->GetState(A,B,C))
-
-
-#undef INTERFACE
-#define INTERFACE IXAudio2MasteringVoice
-typedef interface IXAudio2MasteringVoice {
- const struct IXAudio2MasteringVoiceVtbl FAR* lpVtbl;
-} IXAudio2MasteringVoice;
-typedef const struct IXAudio2MasteringVoiceVtbl IXAudio2MasteringVoiceVtbl;
-const struct IXAudio2MasteringVoiceVtbl
-{
- /* MSDN says that IXAudio2Voice inherits from IXAudio2, but MSVC's debugger
- * says otherwise, and that IXAudio2Voice doesn't inherit from any other
- * interface!
- */
-
- /* IXAudio2Voice */
- STDMETHOD_(VOID, GetVoiceDetails)(THIS, XAUDIO2_VOICE_DETAILS *pVoiceDetails) PURE;
- STDMETHOD_(HRESULT, SetOutputVoices)(THIS, const XAUDIO2_VOICE_SENDS *pSendList) PURE;
- STDMETHOD_(HRESULT, SetEffectChain)(THIS, const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
- STDMETHOD_(HRESULT, EnableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
- STDMETHOD_(HRESULT, DisableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetEffectState)(THIS, UINT32 EffectIndex, BOOL *pEnabled) PURE;
- STDMETHOD_(HRESULT, SetEffectParameters)(THIS, UINT32 EffectIndex,
- const void *pParameters,
- UINT32 ParametersByteSize,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetEffectParameters)(THIS, UINT32 EffectIndex,
- void *pParameters,
- UINT32 ParametersByteSize) PURE;
- STDMETHOD_(HRESULT, SetFilterParameters)(THIS, const XAUDIO2_FILTER_PARAMETERS *pParameters,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetFilterParameters)(THIS, XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
- STDMETHOD_(HRESULT, SetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
- XAUDIO2_FILTER_PARAMETERS *pParameters,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
- XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
- STDMETHOD_(HRESULT, SetVolume)(THIS, float Volume,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetVolume)(THIS, float *pVolume) PURE;
- STDMETHOD_(HRESULT, SetChannelVolumes)(THIS, UINT32 Channels,
- const float *pVolumes,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetChannelVolumes)(THIS, UINT32 Channels,
- float *pVolumes) PURE;
- STDMETHOD_(HRESULT, SetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
- UINT32 SourceChannels,
- UINT32 DestinationChannels,
- const float *pLevelMatrix,
- UINT32 OperationSet) PURE;
- STDMETHOD_(VOID, GetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
- UINT32 SourceChannels,
- UINT32 DestinationChannels,
- float *pLevelMatrix) PURE;
- STDMETHOD_(VOID, DestroyVoice)(THIS) PURE;
-
- /* IXAudio2SourceVoice */
- STDMETHOD_(VOID, GetChannelMask)(THIS, DWORD *pChannelMask) PURE;
-};
-
-#define IXAudio2MasteringVoice_DestroyVoice(A) ((A)->lpVtbl->DestroyVoice(A))
-
-
-#undef INTERFACE
-#define INTERFACE IXAudio2VoiceCallback
-typedef interface IXAudio2VoiceCallback {
- const struct IXAudio2VoiceCallbackVtbl FAR* lpVtbl;
-} IXAudio2VoiceCallback;
-typedef const struct IXAudio2VoiceCallbackVtbl IXAudio2VoiceCallbackVtbl;
-const struct IXAudio2VoiceCallbackVtbl
-{
- /* MSDN says that IXAudio2VoiceCallback inherits from IXAudio2, but SDL's
- * own code says otherwise, and that IXAudio2VoiceCallback doesn't inherit
- * from any other interface!
- */
-
- /* IXAudio2VoiceCallback */
- STDMETHOD_(VOID, OnVoiceProcessingPassStart)(THIS, UINT32 BytesRequired) PURE;
- STDMETHOD_(VOID, OnVoiceProcessingPassEnd)(THIS) PURE;
- STDMETHOD_(VOID, OnStreamEnd)(THIS) PURE;
- STDMETHOD_(VOID, OnBufferStart)(THIS, void *pBufferContext) PURE;
- STDMETHOD_(VOID, OnBufferEnd)(THIS, void *pBufferContext) PURE;
- STDMETHOD_(VOID, OnLoopEnd)(THIS, void *pBufferContext) PURE;
- STDMETHOD_(VOID, OnVoiceError)(THIS, void *pBufferContext, HRESULT Error) PURE;
-};
-
-#pragma pack(pop) /* Undo pragma push */
-
-#endif /* _SDL_XAUDIO2_H */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp b/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
deleted file mode 100644
index b2d67c7fb02..00000000000
--- a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#include <xaudio2.h>
-#include "SDL_xaudio2_winrthelpers.h"
-
-#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
-using Windows::Devices::Enumeration::DeviceClass;
-using Windows::Devices::Enumeration::DeviceInformation;
-using Windows::Devices::Enumeration::DeviceInformationCollection;
-#endif
-
-extern "C" HRESULT __cdecl IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
-{
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- // There doesn't seem to be any audio device enumeration on Windows Phone.
- // In lieu of this, just treat things as if there is one and only one
- // audio device.
- *devcount = 1;
- return S_OK;
-#else
- // TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
- auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
- while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
- {
- }
-
- DeviceInformationCollection^ devices = operation->GetResults();
- *devcount = devices->Size;
- return S_OK;
-#endif
-}
-
-extern "C" HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
-{
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- // Windows Phone doesn't seem to have the same device enumeration APIs that
- // Windows 8/RT has, or it doesn't have them at all. In lieu of this,
- // just treat things as if there is one, and only one, default device.
- if (index != 0)
- {
- return XAUDIO2_E_INVALID_CALL;
- }
-
- if (details)
- {
- wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE);
- wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE);
- }
- return S_OK;
-#else
- auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
- while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
- {
- }
-
- DeviceInformationCollection^ devices = operation->GetResults();
- if (index >= devices->Size)
- {
- return XAUDIO2_E_INVALID_CALL;
- }
-
- DeviceInformation^ d = devices->GetAt(index);
- if (details)
- {
- wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
- wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
- }
- return S_OK;
-#endif
-}
diff --git a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h b/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
deleted file mode 100644
index aa6486f91c3..00000000000
--- a/3rdparty/SDL2/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-//
-// Re-implementation of methods removed from XAudio2 (in WinRT):
-//
-
-typedef struct XAUDIO2_DEVICE_DETAILS
-{
- WCHAR DeviceID[256];
- WCHAR DisplayName[256];
- /* Other fields exist in the pre-Windows 8 version of this struct, however
- they weren't used by SDL, so they weren't added.
- */
-} XAUDIO2_DEVICE_DETAILS;
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HRESULT IXAudio2_GetDeviceCount(IXAudio2 * unused, UINT32 * devcount);
-HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-//
-// C-style macros to call XAudio2's methods in C++:
-//
-#ifdef __cplusplus
-/*
-#define IXAudio2_CreateMasteringVoice(A, B, C, D, E, F, G) (A)->CreateMasteringVoice((B), (C), (D), (E), (F), (G))
-#define IXAudio2_CreateSourceVoice(A, B, C, D, E, F, G, H) (A)->CreateSourceVoice((B), (C), (D), (E), (F), (G), (H))
-#define IXAudio2_QueryInterface(A, B, C) (A)->QueryInterface((B), (C))
-#define IXAudio2_Release(A) (A)->Release()
-#define IXAudio2_StartEngine(A) (A)->StartEngine()
-#define IXAudio2_StopEngine(A) (A)->StopEngine()
-
-#define IXAudio2MasteringVoice_DestroyVoice(A) (A)->DestroyVoice()
-
-#define IXAudio2SourceVoice_DestroyVoice(A) (A)->DestroyVoice()
-#define IXAudio2SourceVoice_Discontinuity(A) (A)->Discontinuity()
-#define IXAudio2SourceVoice_FlushSourceBuffers(A) (A)->FlushSourceBuffers()
-#define IXAudio2SourceVoice_GetState(A, B) (A)->GetState((B))
-#define IXAudio2SourceVoice_Start(A, B, C) (A)->Start((B), (C))
-#define IXAudio2SourceVoice_Stop(A, B, C) (A)->Stop((B), (C))
-#define IXAudio2SourceVoice_SubmitSourceBuffer(A, B, C) (A)->SubmitSourceBuffer((B), (C))
-*/
-#endif // ifdef __cplusplus