You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/03/23 17:18:54 UTC
[06/83] [abbrv] [partial] incubator-corinthia git commit: removed SDL2
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.c b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.c
deleted file mode 100644
index 7efe30e..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@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_audiomem.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(int iscapture, SDL_AddAudioDevice addfn)
-{
- SDL_EnumUnixAudioDevices(iscapture, 1, (int (*)(int fd)) NULL, addfn);
-}
-
-#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 */
- this->enabled = 0;
- }
- 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 */
- this->enabled = 0;
- }
- this->hidden->written += this->hidden->fragsize;
- }
-}
-
-static Uint8 *
-SUNAUDIO_GetDeviceBuf(_THIS)
-{
- return (this->hidden->mixbuf);
-}
-
-static void
-SUNAUDIO_CloseDevice(_THIS)
-{
- if (this->hidden != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- SDL_free(this->hidden->ulaw_buf);
- this->hidden->ulaw_buf = NULL;
- if (this->hidden->audio_fd >= 0) {
- close(this->hidden->audio_fd);
- this->hidden->audio_fd = -1;
- }
- SDL_free(this->hidden);
- this->hidden = NULL;
- }
-}
-
-static int
-SUNAUDIO_OpenDevice(_THIS, 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_memset(this->hidden, 0, (sizeof *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_AllocAudioMem(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;
-
- 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: */
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.h b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.h
deleted file mode 100644
index df05e6f..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@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: */
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.c b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.c
deleted file mode 100644
index 88a8154..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@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_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(typ, capstyp) \
-static void DetectWave##typ##Devs(SDL_AddAudioDevice addfn) { \
- const UINT devcount = wave##typ##GetNumDevs(); \
- capstyp caps; \
- UINT i; \
- for (i = 0; i < devcount; i++) { \
- if (wave##typ##GetDevCaps(i,&caps,sizeof(caps))==MMSYSERR_NOERROR) { \
- char *name = WIN_StringToUTF8(caps.szPname); \
- if (name != NULL) { \
- addfn(name); \
- SDL_free(name); \
- } \
- } \
- } \
-}
-
-DETECT_DEV_IMPL(Out, WAVEOUTCAPS)
-DETECT_DEV_IMPL(In, WAVEINCAPS)
-
-static void
-WINMM_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
-{
- if (iscapture) {
- DetectWaveInDevs(addfn);
- } else {
- DetectWaveOutDevs(addfn);
- }
-}
-
-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 void
-WINMM_WaitDone(_THIS)
-{
- int i, left;
-
- do {
- left = NUM_BUFFERS;
- for (i = 0; i < NUM_BUFFERS; ++i) {
- if (this->hidden->wavebuf[i].dwFlags & WHDR_DONE) {
- --left;
- }
- }
- if (left > 0) {
- SDL_Delay(100);
- }
- } while (left > 0);
-}
-
-static void
-WINMM_CloseDevice(_THIS)
-{
- /* Close up audio */
- if (this->hidden != NULL) {
- int i;
-
- if (this->hidden->audio_sem) {
- CloseHandle(this->hidden->audio_sem);
- this->hidden->audio_sem = 0;
- }
-
- /* 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]));
- this->hidden->wavebuf[i].dwUser = 0xFFFF;
- }
- }
-
- /* Free raw mixing buffer */
- SDL_free(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
-
- if (this->hidden->hin) {
- waveInClose(this->hidden->hin);
- this->hidden->hin = 0;
- }
-
- if (this->hidden->hout) {
- waveOutClose(this->hidden->hout);
- this->hidden->hout = 0;
- }
-
- SDL_free(this->hidden);
- this->hidden = NULL;
- }
-}
-
-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, 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 */
- char *utf8 = NULL;
- UINT i;
-
- if (devname != NULL) { /* specific device requested? */
- if (iscapture) {
- const UINT devcount = waveInGetNumDevs();
- WAVEINCAPS caps;
- for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
- result = waveInGetDevCaps(i, &caps, sizeof (caps));
- if (result != MMSYSERR_NOERROR)
- continue;
- else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
- continue;
- else if (SDL_strcmp(devname, utf8) == 0)
- devId = i;
- SDL_free(utf8);
- }
- } else {
- const UINT devcount = waveOutGetNumDevs();
- WAVEOUTCAPS caps;
- for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
- result = waveOutGetDevCaps(i, &caps, sizeof (caps));
- if (result != MMSYSERR_NOERROR)
- continue;
- else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
- continue;
- else if (SDL_strcmp(devname, utf8) == 0)
- devId = i;
- SDL_free(utf8);
- }
- }
-
- if (devId == WAVE_MAPPER) {
- return SDL_SetError("Requested device not found");
- }
- }
-
- /* 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_memset(this->hidden, 0, (sizeof *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? */
-
- /* Check the buffer size -- minimum of 1/4 second (word aligned) */
- if (this->spec.samples < (this->spec.freq / 4))
- this->spec.samples = ((this->spec.freq / 4) + 3) & ~3;
-
- 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) {
- WINMM_CloseDevice(this);
- 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);
- } else {
- result = waveOutOpen(&this->hidden->hout, devId, &waveformat,
- (DWORD_PTR) FillSound, (DWORD_PTR) this,
- CALLBACK_FUNCTION);
- }
-
- if (result != MMSYSERR_NOERROR) {
- WINMM_CloseDevice(this);
- return SetMMerror("waveOutOpen()", result);
- }
-#ifdef SOUND_DEBUG
- /* Check the sound device we retrieved */
- {
- WAVEOUTCAPS caps;
-
- result = waveOutGetDevCaps((UINT) this->hidden->hout,
- &caps, sizeof(caps));
- if (result != MMSYSERR_NOERROR) {
- WINMM_CloseDevice(this);
- return SetMMerror("waveOutGetDevCaps()", result);
- }
- printf("Audio device: %s\n", caps.szPname);
- }
-#endif
-
- /* Create the audio buffer semaphore */
- this->hidden->audio_sem =
- CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
- if (this->hidden->audio_sem == NULL) {
- WINMM_CloseDevice(this);
- 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) {
- WINMM_CloseDevice(this);
- return SDL_OutOfMemory();
- }
- for (i = 0; i < NUM_BUFFERS; ++i) {
- SDL_memset(&this->hidden->wavebuf[i], 0,
- sizeof(this->hidden->wavebuf[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];
- result = waveOutPrepareHeader(this->hidden->hout,
- &this->hidden->wavebuf[i],
- sizeof(this->hidden->wavebuf[i]));
- if (result != MMSYSERR_NOERROR) {
- WINMM_CloseDevice(this);
- return SetMMerror("waveOutPrepareHeader()", 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->WaitDone = WINMM_WaitDone;
- impl->GetDeviceBuf = WINMM_GetDeviceBuf;
- impl->CloseDevice = WINMM_CloseDevice;
-
- 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: */
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.h b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.h
deleted file mode 100644
index 47996c1..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/winmm/SDL_winmm.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@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: */
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2.c b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2.c
deleted file mode 100644
index a1a18df..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@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 .the XAudio 2 SDK */
-# define SDL_XAUDIO2_HAS_SDK
-#else
-/* XAudio2 exists as of the March 2008 DirectX SDK
- The XAudio2 implementation available in the Windows 8 SDK targets Windows 8 and newer.
- If you want to build SDL with XAudio2 support you should install the DirectX SDK.
- */
-#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
-
-#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
-
-/* The XAudio header file, when #include'd on WinRT, will only compile in C++
- files, but not C. A few preprocessor-based hacks are defined below in order
- to get xaudio2.h to compile in the C/non-C++ file, SDL_xaudio2.c.
- */
-#ifdef __WINRT__
-#define uuid(x)
-#define DX_BUILD
-#endif
-
-#define INITGUID 1
-#include <xaudio2.h>
-
-/* 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(int iscapture, SDL_AddAudioDevice addfn)
-{
- IXAudio2 *ixa2 = NULL;
- UINT32 devcount = 0;
- UINT32 i = 0;
-
- if (iscapture) {
- SDL_SetError("XAudio2: capture devices unsupported.");
- return;
- } else 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) {
- addfn(str);
- SDL_free(str); /* addfn() 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)
-{
- /* !!! FIXME: attempt to recover, or mark device disconnected. */
- SDL_assert(0 && "write me!");
-}
-
-/* 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 (!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);
- this->enabled = 0;
- }
-}
-
-static void
-XAUDIO2_WaitDevice(_THIS)
-{
- if (this->enabled) {
- SDL_SemWait(this->hidden->semaphore);
- }
-}
-
-static void
-XAUDIO2_WaitDone(_THIS)
-{
- IXAudio2SourceVoice *source = this->hidden->source;
- XAUDIO2_VOICE_STATE state;
- SDL_assert(!this->enabled); /* flag that stops playing. */
- IXAudio2SourceVoice_Discontinuity(source);
-#if SDL_XAUDIO2_WIN8
- IXAudio2SourceVoice_GetState(source, &state, 0);
-#else
- IXAudio2SourceVoice_GetState(source, &state);
-#endif
- while (state.BuffersQueued > 0) {
- SDL_SemWait(this->hidden->semaphore);
-#if SDL_XAUDIO2_WIN8
- IXAudio2SourceVoice_GetState(source, &state, 0);
-#else
- IXAudio2SourceVoice_GetState(source, &state);
-#endif
- }
-}
-
-
-static void
-XAUDIO2_CloseDevice(_THIS)
-{
- if (this->hidden != NULL) {
- 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);
- }
- SDL_free(this->hidden->mixbuf);
- if (this->hidden->semaphore != NULL) {
- SDL_DestroySemaphore(this->hidden->semaphore);
- }
-
- SDL_free(this->hidden);
- this->hidden = NULL;
- }
-}
-
-static int
-XAUDIO2_OpenDevice(_THIS, 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 (iscapture) {
- return SDL_SetError("XAudio2: capture devices unsupported.");
- } else 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);
- */
-
-#if ! defined(__WINRT__)
- if (devname != NULL) {
- UINT32 devcount = 0;
- UINT32 i = 0;
-
- if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
- IXAudio2_Release(ixa2);
- return SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed.");
- }
- 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) {
- const int match = (SDL_strcmp(str, devname) == 0);
- SDL_free(str);
- if (match) {
- devId = i;
- break;
- }
- }
- }
- }
-
- if (i == devcount) {
- IXAudio2_Release(ixa2);
- return SDL_SetError("XAudio2: Requested device not found.");
- }
- }
-#endif
-
- /* 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_memset(this->hidden, 0, (sizeof *this->hidden));
-
- this->hidden->ixa2 = ixa2;
- this->hidden->semaphore = SDL_CreateSemaphore(1);
- if (this->hidden->semaphore == NULL) {
- XAUDIO2_CloseDevice(this);
- 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) {
- XAUDIO2_CloseDevice(this);
- 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) {
- XAUDIO2_CloseDevice(this);
- return SDL_OutOfMemory();
- }
- this->hidden->nextbuf = this->hidden->mixbuf;
- SDL_memset(this->hidden->mixbuf, 0, 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) {
- XAUDIO2_CloseDevice(this);
- 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) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: Couldn't create source voice");
- }
- this->hidden->source = source;
-
- /* Start everything playing! */
- result = IXAudio2_StartEngine(ixa2);
- if (result != S_OK) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: Couldn't start engine");
- }
-
- result = IXAudio2SourceVoice_Start(source, 0, XAUDIO2_COMMIT_NOW);
- if (result != S_OK) {
- XAUDIO2_CloseDevice(this);
- 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->WaitDone = XAUDIO2_WaitDone;
- impl->GetDeviceBuf = XAUDIO2_GetDeviceBuf;
- impl->CloseDevice = XAUDIO2_CloseDevice;
- impl->Deinitialize = XAUDIO2_Deinitialize;
-
- 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: */
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
deleted file mode 100644
index 69eb5ad..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@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
-}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
deleted file mode 100644
index 3db04cf..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@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