diff options
author | Chris Robinson <[email protected]> | 2011-05-15 05:24:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-05-15 05:24:27 -0700 |
commit | e95b718cf437aa21e758f8c3c764e4bc548727e7 (patch) | |
tree | dcc0b7d0433fd1a624955c5b2ce08320a9c68a7c | |
parent | 143c08bfcbba9cbd59ed61936e4adec0b109d41e (diff) |
Improve handling of device channels with DSound
-rw-r--r-- | Alc/dsound.c | 102 |
1 files changed, 47 insertions, 55 deletions
diff --git a/Alc/dsound.c b/Alc/dsound.c index 6a77328a..a521ad65 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -354,76 +354,68 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device) } hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers); - if(FAILED(hr) || (device->Flags&DEVICE_CHANNELS_REQUEST)) + if(SUCCEEDED(hr)) { + if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) + { + speakers = DSSPEAKER_CONFIG(speakers); + if(speakers == DSSPEAKER_MONO) + device->FmtChans = DevFmtMono; + else if(speakers == DSSPEAKER_STEREO || speakers == DSSPEAKER_HEADPHONE) + device->FmtChans = DevFmtStereo; + else if(speakers == DSSPEAKER_QUAD) + device->FmtChans = DevFmtQuad; + else if(speakers == DSSPEAKER_5POINT1) + device->FmtChans = DevFmtX51; + else if(speakers == DSSPEAKER_7POINT1) + device->FmtChans = DevFmtX71; + else + AL_PRINT("Unknown system speaker config: 0x%lx\n", speakers); + } + switch(device->FmtChans) { case DevFmtMono: - speakers = DSSPEAKER_COMBINED(DSSPEAKER_MONO, 0); + OutputType.dwChannelMask = SPEAKER_FRONT_CENTER; break; case DevFmtStereo: - speakers = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, 0); + OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | + SPEAKER_FRONT_RIGHT; break; case DevFmtQuad: - speakers = DSSPEAKER_COMBINED(DSSPEAKER_QUAD, 0); + OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | + SPEAKER_FRONT_RIGHT | + SPEAKER_BACK_LEFT | + SPEAKER_BACK_RIGHT; break; case DevFmtX51: - speakers = DSSPEAKER_COMBINED(DSSPEAKER_5POINT1, 0); + OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | + SPEAKER_FRONT_RIGHT | + SPEAKER_FRONT_CENTER | + SPEAKER_LOW_FREQUENCY | + SPEAKER_BACK_LEFT | + SPEAKER_BACK_RIGHT; break; case DevFmtX61: - /* ??? */ - AL_PRINT("6.1 not supported with DirectSound\n"); - device->Flags &= ~DEVICE_CHANNELS_REQUEST; + OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | + SPEAKER_FRONT_RIGHT | + SPEAKER_FRONT_CENTER | + SPEAKER_LOW_FREQUENCY | + SPEAKER_BACK_CENTER | + SPEAKER_SIDE_LEFT | + SPEAKER_SIDE_RIGHT; break; case DevFmtX71: - speakers = DSSPEAKER_COMBINED(DSSPEAKER_7POINT1, 0); + OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | + SPEAKER_FRONT_RIGHT | + SPEAKER_FRONT_CENTER | + SPEAKER_LOW_FREQUENCY | + SPEAKER_BACK_LEFT | + SPEAKER_BACK_RIGHT | + SPEAKER_SIDE_LEFT | + SPEAKER_SIDE_RIGHT; break; } - } - if(SUCCEEDED(hr)) - { - speakers = DSSPEAKER_CONFIG(speakers); - if(speakers == DSSPEAKER_MONO) - { - device->FmtChans = DevFmtMono; - OutputType.dwChannelMask = SPEAKER_FRONT_CENTER; - } - else if(speakers == DSSPEAKER_STEREO || speakers == DSSPEAKER_HEADPHONE) - { - device->FmtChans = DevFmtStereo; - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT; - } - else if(speakers == DSSPEAKER_QUAD) - { - device->FmtChans = DevFmtQuad; - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - } - else if(speakers == DSSPEAKER_5POINT1) - { - device->FmtChans = DevFmtX51; - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - } - else if(speakers == DSSPEAKER_7POINT1) - { - device->FmtChans = DevFmtX71; - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - } OutputType.Format.wFormatTag = WAVE_FORMAT_PCM; OutputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans); @@ -438,7 +430,7 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device) { OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample; - OutputType.Format.cbSize = 22; + OutputType.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); if(device->FmtType == DevFmtFloat) OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; else |