aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/dsound.cpp
diff options
context:
space:
mode:
authorChris Robinson <chris.kcat@gmail.com>2022-06-08 02:21:37 -0700
committerChris Robinson <chris.kcat@gmail.com>2022-06-08 02:21:37 -0700
commit1278d3b84998ad0153a0a0f63a3a6696410f3b2c (patch)
tree94c7efb62899c069b69cc4aebd27960c440fd90c /alc/backends/dsound.cpp
parent14e6d3836a0bb4279be56aa75077275b3d0feb6e (diff)
Handle 5.1 Rear with DSound playback
Diffstat (limited to 'alc/backends/dsound.cpp')
-rw-r--r--alc/backends/dsound.cpp86
1 files changed, 44 insertions, 42 deletions
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index 36c4cd78..3f2bf8df 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -389,53 +389,55 @@ bool DSoundPlayback::reset()
}
WAVEFORMATEXTENSIBLE OutputType{};
- DWORD speakers;
+ DWORD speakers{};
HRESULT hr{mDS->GetSpeakerConfig(&speakers)};
- if(SUCCEEDED(hr))
+ if(FAILED(hr))
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "Failed to get speaker config: 0x%08lx", hr};
+
+ speakers = DSSPEAKER_CONFIG(speakers);
+ if(!mDevice->Flags.test(ChannelsRequest))
{
- speakers = DSSPEAKER_CONFIG(speakers);
- if(!mDevice->Flags.test(ChannelsRequest))
- {
- if(speakers == DSSPEAKER_MONO)
- mDevice->FmtChans = DevFmtMono;
- else if(speakers == DSSPEAKER_STEREO || speakers == DSSPEAKER_HEADPHONE)
- mDevice->FmtChans = DevFmtStereo;
- else if(speakers == DSSPEAKER_QUAD)
- mDevice->FmtChans = DevFmtQuad;
- else if(speakers == DSSPEAKER_5POINT1_SURROUND || speakers == DSSPEAKER_5POINT1_BACK)
- mDevice->FmtChans = DevFmtX51;
- else if(speakers == DSSPEAKER_7POINT1 || speakers == DSSPEAKER_7POINT1_SURROUND)
- mDevice->FmtChans = DevFmtX71;
- else
- ERR("Unknown system speaker config: 0x%lx\n", speakers);
- }
- mDevice->Flags.set(DirectEar, (speakers == DSSPEAKER_HEADPHONE));
+ if(speakers == DSSPEAKER_MONO)
+ mDevice->FmtChans = DevFmtMono;
+ else if(speakers == DSSPEAKER_STEREO || speakers == DSSPEAKER_HEADPHONE)
+ mDevice->FmtChans = DevFmtStereo;
+ else if(speakers == DSSPEAKER_QUAD)
+ mDevice->FmtChans = DevFmtQuad;
+ else if(speakers == DSSPEAKER_5POINT1_SURROUND || speakers == DSSPEAKER_5POINT1_BACK)
+ mDevice->FmtChans = DevFmtX51;
+ else if(speakers == DSSPEAKER_7POINT1 || speakers == DSSPEAKER_7POINT1_SURROUND)
+ mDevice->FmtChans = DevFmtX71;
+ else
+ ERR("Unknown system speaker config: 0x%lx\n", speakers);
+ }
+ mDevice->Flags.set(DirectEar, (speakers == DSSPEAKER_HEADPHONE));
+ const bool isRear51{speakers == DSSPEAKER_5POINT1_BACK};
- switch(mDevice->FmtChans)
- {
- case DevFmtMono: OutputType.dwChannelMask = MONO; break;
- case DevFmtAmbi3D: mDevice->FmtChans = DevFmtStereo;
- /*fall-through*/
- case DevFmtStereo: OutputType.dwChannelMask = STEREO; break;
- case DevFmtQuad: OutputType.dwChannelMask = QUAD; break;
- case DevFmtX51: OutputType.dwChannelMask = X5DOT1; break;
- case DevFmtX61: OutputType.dwChannelMask = X6DOT1; break;
- case DevFmtX71: OutputType.dwChannelMask = X7DOT1; break;
- case DevFmtX3D71: OutputType.dwChannelMask = X7DOT1; break;
- }
+ switch(mDevice->FmtChans)
+ {
+ case DevFmtMono: OutputType.dwChannelMask = MONO; break;
+ case DevFmtAmbi3D: mDevice->FmtChans = DevFmtStereo;
+ /* fall-through */
+ case DevFmtStereo: OutputType.dwChannelMask = STEREO; break;
+ case DevFmtQuad: OutputType.dwChannelMask = QUAD; break;
+ case DevFmtX51: OutputType.dwChannelMask = isRear51 ? X5DOT1REAR : X5DOT1; break;
+ case DevFmtX61: OutputType.dwChannelMask = X6DOT1; break;
+ case DevFmtX71: OutputType.dwChannelMask = X7DOT1; break;
+ case DevFmtX3D71: OutputType.dwChannelMask = X7DOT1; break;
+ }
retry_open:
- hr = S_OK;
- OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
- OutputType.Format.nChannels = static_cast<WORD>(mDevice->channelsFromFmt());
- OutputType.Format.wBitsPerSample = static_cast<WORD>(mDevice->bytesFromFmt() * 8);
- OutputType.Format.nBlockAlign = static_cast<WORD>(OutputType.Format.nChannels *
- OutputType.Format.wBitsPerSample / 8);
- OutputType.Format.nSamplesPerSec = mDevice->Frequency;
- OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec *
- OutputType.Format.nBlockAlign;
- OutputType.Format.cbSize = 0;
- }
+ hr = S_OK;
+ OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
+ OutputType.Format.nChannels = static_cast<WORD>(mDevice->channelsFromFmt());
+ OutputType.Format.wBitsPerSample = static_cast<WORD>(mDevice->bytesFromFmt() * 8);
+ OutputType.Format.nBlockAlign = static_cast<WORD>(OutputType.Format.nChannels *
+ OutputType.Format.wBitsPerSample / 8);
+ OutputType.Format.nSamplesPerSec = mDevice->Frequency;
+ OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec *
+ OutputType.Format.nBlockAlign;
+ OutputType.Format.cbSize = 0;
if(OutputType.Format.nChannels > 2 || mDevice->FmtType == DevFmtFloat)
{