diff options
author | Chris Robinson <[email protected]> | 2008-01-25 05:02:00 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-01-25 05:02:00 -0800 |
commit | 04b62f77e37335be68d3e8c04c2cc7a354aef18c (patch) | |
tree | db64a23ff42082dd5dd5192111a89788a8952082 | |
parent | 029dff3f40976a0927fe256eed19eaf91311c05c (diff) |
Set the output format according to the speaker setup reported by directsound
-rw-r--r-- | Alc/dsound.c | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/Alc/dsound.c b/Alc/dsound.c index 0ca1fc66..b5796fd9 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -32,6 +32,9 @@ #include "AL/al.h" #include "AL/alc.h" +#ifndef DSSPEAKER_7POINT1 +#define DSSPEAKER_7POINT1 7 +#endif typedef struct { // DirectSound Playback Device @@ -113,6 +116,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam DSBUFFERDESC DSBDescription; DSoundData *pData = NULL; WAVEFORMATEX OutputType; + DWORD speakers; HRESULT hr; if(deviceName) @@ -132,15 +136,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam else device->szDeviceName = DeviceList[0]; - //Platform specific memset(&OutputType, 0, sizeof(WAVEFORMATEX)); - OutputType.wFormatTag = WAVE_FORMAT_PCM; - OutputType.nChannels = device->Channels; - OutputType.wBitsPerSample = aluBytesFromFormat(device->Format) * 8; - OutputType.nBlockAlign = OutputType.nChannels*OutputType.wBitsPerSample/8; - OutputType.nSamplesPerSec = device->Frequency; - OutputType.nAvgBytesPerSec = OutputType.nSamplesPerSec*OutputType.nBlockAlign; - OutputType.cbSize = 0; //Initialise requested device @@ -162,6 +158,56 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY); if(SUCCEEDED(hr)) + hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers); + if(SUCCEEDED(hr)) + { + speakers = DSSPEAKER_CONFIG(speakers); + if(speakers == DSSPEAKER_MONO) + { + if(aluBytesFromFormat(device->Format) == 8) + device->Format = AL_FORMAT_MONO8; + else + device->Format = AL_FORMAT_MONO16; + } + else if(speakers == DSSPEAKER_STEREO) + { + if(aluBytesFromFormat(device->Format) == 8) + device->Format = AL_FORMAT_STEREO8; + else + device->Format = AL_FORMAT_STEREO16; + } + else if(speakers == DSSPEAKER_QUAD) + { + if(aluBytesFromFormat(device->Format) == 8) + device->Format = AL_FORMAT_QUAD8; + else + device->Format = AL_FORMAT_QUAD16; + } + else if(speakers == DSSPEAKER_5POINT1) + { + if(aluBytesFromFormat(device->Format) == 8) + device->Format = AL_FORMAT_51CHN8; + else + device->Format = AL_FORMAT_51CHN16; + } + else if(speakers == DSSPEAKER_7POINT1) + { + if(aluBytesFromFormat(device->Format) == 8) + device->Format = AL_FORMAT_71CHN8; + else + device->Format = AL_FORMAT_71CHN16; + } + + OutputType.wFormatTag = WAVE_FORMAT_PCM; + OutputType.nChannels = device->Channels; + OutputType.wBitsPerSample = aluBytesFromFormat(device->Format) * 8; + OutputType.nBlockAlign = OutputType.nChannels*OutputType.wBitsPerSample/8; + OutputType.nSamplesPerSec = device->Frequency; + OutputType.nAvgBytesPerSec = OutputType.nSamplesPerSec*OutputType.nBlockAlign; + OutputType.cbSize = 0; + } + + if(SUCCEEDED(hr)) { memset(&DSBDescription,0,sizeof(DSBUFFERDESC)); DSBDescription.dwSize=sizeof(DSBUFFERDESC); |