Implement float32 support for winmm and directsound targets (Thanks, John!).

Fixes Bugzilla #1657.
This commit is contained in:
Ryan C. Gordon 2013-07-14 13:27:54 -04:00
parent 4e5bd8491f
commit c944a4fdf9
2 changed files with 22 additions and 2 deletions

View file

@ -30,6 +30,10 @@
#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);
@ -466,6 +470,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
case AUDIO_F32:
this->spec.format = test_format;
valid_format = 1;
break;
@ -479,7 +484,12 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
}
SDL_memset(&waveformat, 0, sizeof(waveformat));
waveformat.wFormatTag = WAVE_FORMAT_PCM;
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;

View file

@ -32,6 +32,10 @@
#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(); \
@ -257,6 +261,7 @@ WINMM_OpenDevice(_THIS, const char *devname, int iscapture)
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
case AUDIO_F32:
break; /* valid. */
default:
@ -273,7 +278,12 @@ WINMM_OpenDevice(_THIS, const char *devname, int iscapture)
/* Set basic WAVE format parameters */
SDL_memset(&waveformat, '\0', sizeof(waveformat));
waveformat.wFormatTag = WAVE_FORMAT_PCM;
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);
if (this->spec.channels > 2)