dsound: Make DSOUND_FindSpeakerConfig() static.

oldstable
Francois Gouget 2015-01-20 03:25:49 +01:00 committed by Alexandre Julliard
parent 038399fcdd
commit 82c298ee6e
2 changed files with 49 additions and 50 deletions

View File

@ -219,7 +219,6 @@ 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;

View File

@ -79,6 +79,55 @@ static DWORD speaker_config_to_channel_mask(DWORD speaker_config)
return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
}
static DWORD DSOUND_FindSpeakerConfig(IMMDevice *mmdevice, int channels)
{
IPropertyStore *store;
HRESULT hr;
PROPVARIANT pv;
ULONG phys_speakers;
const DWORD def = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE);
hr = IMMDevice_OpenPropertyStore(mmdevice, STGM_READ, &store);
if (FAILED(hr)) {
WARN("IMMDevice_OpenPropertyStore failed: %08x\n", hr);
return def;
}
hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_PhysicalSpeakers, &pv);
if (FAILED(hr)) {
WARN("IPropertyStore_GetValue failed: %08x\n", hr);
IPropertyStore_Release(store);
return def;
}
if (pv.vt != VT_UI4) {
WARN("PKEY_AudioEndpoint_PhysicalSpeakers is not a ULONG: 0x%x\n", pv.vt);
PropVariantClear(&pv);
IPropertyStore_Release(store);
return def;
}
phys_speakers = pv.u.ulVal;
PropVariantClear(&pv);
IPropertyStore_Release(store);
if ((channels >= 6 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_5POINT1) == KSAUDIO_SPEAKER_5POINT1)
return DSSPEAKER_5POINT1_BACK;
else if ((channels >= 6 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_5POINT1_SURROUND) == KSAUDIO_SPEAKER_5POINT1_SURROUND)
return DSSPEAKER_5POINT1_SURROUND;
else if ((channels >= 4 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_QUAD) == KSAUDIO_SPEAKER_QUAD)
return DSSPEAKER_QUAD;
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;
return def;
}
static HRESULT DSOUND_WaveFormat(DirectSoundDevice *device, IAudioClient *client,
BOOL forcewave, WAVEFORMATEX **wfx)
{
@ -166,55 +215,6 @@ static HRESULT DSOUND_WaveFormat(DirectSoundDevice *device, IAudioClient *client
return S_OK;
}
DWORD DSOUND_FindSpeakerConfig(IMMDevice *mmdevice, int channels)
{
IPropertyStore *store;
HRESULT hr;
PROPVARIANT pv;
ULONG phys_speakers;
const DWORD def = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE);
hr = IMMDevice_OpenPropertyStore(mmdevice, STGM_READ, &store);
if (FAILED(hr)) {
WARN("IMMDevice_OpenPropertyStore failed: %08x\n", hr);
return def;
}
hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_PhysicalSpeakers, &pv);
if (FAILED(hr)) {
WARN("IPropertyStore_GetValue failed: %08x\n", hr);
IPropertyStore_Release(store);
return def;
}
if (pv.vt != VT_UI4) {
WARN("PKEY_AudioEndpoint_PhysicalSpeakers is not a ULONG: 0x%x\n", pv.vt);
PropVariantClear(&pv);
IPropertyStore_Release(store);
return def;
}
phys_speakers = pv.u.ulVal;
PropVariantClear(&pv);
IPropertyStore_Release(store);
if ((channels >= 6 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_5POINT1) == KSAUDIO_SPEAKER_5POINT1)
return DSSPEAKER_5POINT1_BACK;
else if ((channels >= 6 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_5POINT1_SURROUND) == KSAUDIO_SPEAKER_5POINT1_SURROUND)
return DSSPEAKER_5POINT1_SURROUND;
else if ((channels >= 4 || channels == 0) && (phys_speakers & KSAUDIO_SPEAKER_QUAD) == KSAUDIO_SPEAKER_QUAD)
return DSSPEAKER_QUAD;
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;
return def;
}
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
{
UINT prebuf_frames;