Commit b5aec2e4 authored by Mark Harmstone's avatar Mark Harmstone Committed by Alexandre Julliard

dsound: Degrade speaker config if too many channels.

parent dcf8767b
......@@ -219,6 +219,7 @@ HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LP
LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device) DECLSPEC_HIDDEN;
DWORD DSOUND_FindSpeakerConfig(IMMDevice *mmdevice, int channels) DECLSPEC_HIDDEN;
HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
......
......@@ -93,7 +93,10 @@ static HRESULT DSOUND_WaveFormat(DirectSoundDevice *device, IAudioClient *client
if (FAILED(hr))
return hr;
if (mixwfe->Format.nChannels > device->num_speakers) {
if (mixwfe->Format.nChannels < device->num_speakers) {
device->speaker_config = DSOUND_FindSpeakerConfig(device->mmdevice, mixwfe->Format.nChannels);
DSOUND_ParseSpeakerConfig(device);
} else if (mixwfe->Format.nChannels > device->num_speakers) {
mixwfe->Format.nChannels = device->num_speakers;
mixwfe->Format.nBlockAlign = mixwfe->Format.nChannels * mixwfe->Format.wBitsPerSample / 8;
mixwfe->Format.nAvgBytesPerSec = mixwfe->Format.nSamplesPerSec * mixwfe->Format.nBlockAlign;
......@@ -163,7 +166,7 @@ static HRESULT DSOUND_WaveFormat(DirectSoundDevice *device, IAudioClient *client
return S_OK;
}
static DWORD DSOUND_FindSpeakerConfig(IMMDevice *mmdevice)
DWORD DSOUND_FindSpeakerConfig(IMMDevice *mmdevice, int channels)
{
IPropertyStore *store;
HRESULT hr;
......@@ -198,13 +201,13 @@ static DWORD DSOUND_FindSpeakerConfig(IMMDevice *mmdevice)
PropVariantClear(&pv);
IPropertyStore_Release(store);
if ((phys_speakers & KSAUDIO_SPEAKER_5POINT1) == KSAUDIO_SPEAKER_5POINT1)
if ((channels >= 6 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_5POINT1) == KSAUDIO_SPEAKER_5POINT1)
return DSSPEAKER_5POINT1_BACK;
else if ((phys_speakers & KSAUDIO_SPEAKER_5POINT1_SURROUND) == KSAUDIO_SPEAKER_5POINT1_SURROUND)
else if ((channels >= 6 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_5POINT1_SURROUND) == KSAUDIO_SPEAKER_5POINT1_SURROUND)
return DSSPEAKER_5POINT1_SURROUND;
else if ((phys_speakers & KSAUDIO_SPEAKER_QUAD) == KSAUDIO_SPEAKER_QUAD)
else if ((channels >= 4 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_QUAD) == KSAUDIO_SPEAKER_QUAD)
return DSSPEAKER_QUAD;
else if ((phys_speakers & KSAUDIO_SPEAKER_STEREO) == KSAUDIO_SPEAKER_STEREO)
else if ((channels >= 2 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_STEREO) == KSAUDIO_SPEAKER_STEREO)
return DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE);
else if ((phys_speakers & KSAUDIO_SPEAKER_MONO) == KSAUDIO_SPEAKER_MONO)
return DSSPEAKER_MONO;
......@@ -247,7 +250,7 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
return hres;
}
device->speaker_config = DSOUND_FindSpeakerConfig(device->mmdevice);
device->speaker_config = DSOUND_FindSpeakerConfig(device->mmdevice, 0);
DSOUND_ParseSpeakerConfig(device);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment