Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Implement float32 support for winmm and directsound targets (Thanks, …
Browse files Browse the repository at this point in the history
…John!).

Fixes Bugzilla #1657.
  • Loading branch information
icculus committed Jul 14, 2013
1 parent 232877f commit 9ea9b69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/audio/directsound/SDL_directsound.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion src/audio/winmm/SDL_winmm.c
Expand Up @@ -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(); \
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 9ea9b69

Please sign in to comment.