Mark Harmstone : dsound: Degrade speaker config if too many channels.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jan 13 15:01:25 CST 2015
Module: wine
Branch: master
Commit: b5aec2e40ffb3a49134a424e936f38adfa27470e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b5aec2e40ffb3a49134a424e936f38adfa27470e
Author: Mark Harmstone <hellas at burntcomma.com>
Date: Sun Jan 11 17:40:52 2015 +0000
dsound: Degrade speaker config if too many channels.
---
dlls/dsound/dsound_private.h | 1 +
dlls/dsound/primary.c | 17 ++++++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index af2034a..52b2847 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -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;
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index d3c2689..7d05efd 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -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);
More information about the wine-cvs
mailing list