2002-06-13 21:15:06 +02:00
|
|
|
/* DirectSound
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998 Rob Riggs
|
|
|
|
* Copyright 2000-2002 TransGaming Technologies, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
|
|
|
|
2015-03-11 11:30:29 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2007-04-29 18:45:44 +02:00
|
|
|
#define COBJMACROS
|
2011-09-27 15:51:33 +02:00
|
|
|
#define NONAMELESSUNION
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2005-10-17 11:24:50 +02:00
|
|
|
#include "winuser.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "mmsystem.h"
|
2003-04-30 00:49:52 +02:00
|
|
|
#include "winnls.h"
|
2005-01-28 18:21:07 +01:00
|
|
|
#include "vfwmsgs.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "mmddk.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dsound.h"
|
|
|
|
#include "dsound_private.h"
|
2004-07-22 21:40:44 +02:00
|
|
|
#include "dsconf.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
#include "ksmedia.h"
|
|
|
|
#include "propkey.h"
|
|
|
|
#include "devpkey.h"
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
|
|
|
|
|
2020-10-18 23:33:26 +02:00
|
|
|
static WCHAR wInterface[] = L"Interface";
|
2011-09-27 15:51:33 +02:00
|
|
|
|
2011-04-08 14:11:34 +02:00
|
|
|
typedef struct IKsPrivatePropertySetImpl
|
|
|
|
{
|
|
|
|
IKsPropertySet IKsPropertySet_iface;
|
|
|
|
LONG ref;
|
|
|
|
} IKsPrivatePropertySetImpl;
|
|
|
|
|
|
|
|
static IKsPrivatePropertySetImpl *impl_from_IKsPropertySet(IKsPropertySet *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IKsPrivatePropertySetImpl, IKsPropertySet_iface);
|
|
|
|
}
|
|
|
|
|
2003-08-20 20:18:23 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* IKsPrivatePropertySet
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* IUnknown methods */
|
|
|
|
static HRESULT WINAPI IKsPrivatePropertySetImpl_QueryInterface(
|
2012-08-27 12:28:04 +02:00
|
|
|
IKsPropertySet *iface, REFIID riid, void **ppobj)
|
2003-08-20 20:18:23 +02:00
|
|
|
{
|
2011-04-08 14:11:34 +02:00
|
|
|
IKsPrivatePropertySetImpl *This = impl_from_IKsPropertySet(iface);
|
2003-08-20 20:18:23 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
2007-04-29 18:45:44 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IKsPropertySet)) {
|
|
|
|
*ppobj = iface;
|
2012-08-27 12:28:04 +02:00
|
|
|
IKsPropertySet_AddRef(iface);
|
2007-04-29 18:45:44 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2003-08-20 20:18:23 +02:00
|
|
|
*ppobj = NULL;
|
2007-04-29 18:45:44 +02:00
|
|
|
return E_NOINTERFACE;
|
2003-08-20 20:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IKsPrivatePropertySetImpl_AddRef(LPKSPROPERTYSET iface)
|
|
|
|
{
|
2011-04-08 14:11:34 +02:00
|
|
|
IKsPrivatePropertySetImpl *This = impl_from_IKsPropertySet(iface);
|
2005-02-11 12:49:05 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("(%p) ref %ld\n", This, ref);
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2003-08-20 20:18:23 +02:00
|
|
|
static ULONG WINAPI IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface)
|
|
|
|
{
|
2011-04-08 14:11:34 +02:00
|
|
|
IKsPrivatePropertySetImpl *This = impl_from_IKsPropertySet(iface);
|
2005-02-11 12:49:05 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("(%p) ref %ld\n", This, ref);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
if (!ref) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
2004-09-16 21:08:04 +02:00
|
|
|
}
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
struct search_data {
|
|
|
|
const WCHAR *tgt_name;
|
|
|
|
GUID *found_guid;
|
|
|
|
};
|
|
|
|
|
2011-10-03 13:24:12 +02:00
|
|
|
static BOOL CALLBACK search_callback(GUID *guid, const WCHAR *desc,
|
2011-09-27 15:51:33 +02:00
|
|
|
const WCHAR *module, void *user)
|
|
|
|
{
|
|
|
|
struct search_data *search = user;
|
|
|
|
|
|
|
|
if(!lstrcmpW(desc, search->tgt_name)){
|
|
|
|
*search->found_guid = *guid;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-12-09 16:57:58 +01:00
|
|
|
static HRESULT DSPROPERTY_WaveDeviceMappingW(
|
2004-07-14 01:35:09 +02:00
|
|
|
LPVOID pPropData,
|
2003-04-30 00:49:52 +02:00
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned )
|
|
|
|
{
|
2011-09-27 15:51:33 +02:00
|
|
|
HRESULT hr;
|
|
|
|
PDSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA ppd = pPropData;
|
|
|
|
struct search_data search;
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
|
2011-09-27 15:51:33 +02:00
|
|
|
pPropData,cbPropData,pcbReturned);
|
2003-04-30 00:49:52 +02:00
|
|
|
|
|
|
|
if (!ppd) {
|
2011-09-27 15:51:33 +02:00
|
|
|
WARN("invalid parameter: pPropData\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-04-30 00:49:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
search.tgt_name = ppd->DeviceName;
|
|
|
|
search.found_guid = &ppd->DeviceId;
|
|
|
|
|
|
|
|
if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER)
|
|
|
|
hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids,
|
|
|
|
search_callback, &search);
|
|
|
|
else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE)
|
|
|
|
hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids,
|
|
|
|
search_callback, &search);
|
|
|
|
else
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
|
|
|
|
if(hr != S_FALSE)
|
|
|
|
/* device was not found */
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2005-04-13 16:39:49 +02:00
|
|
|
if (pcbReturned)
|
2009-12-09 16:57:58 +01:00
|
|
|
*pcbReturned = cbPropData;
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
return DS_OK;
|
2003-04-30 00:49:52 +02:00
|
|
|
}
|
|
|
|
|
2009-12-09 16:57:58 +01:00
|
|
|
static HRESULT DSPROPERTY_WaveDeviceMappingA(
|
2004-07-14 01:35:09 +02:00
|
|
|
LPVOID pPropData,
|
2003-04-30 00:49:52 +02:00
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned )
|
|
|
|
{
|
2009-12-09 16:57:58 +01:00
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A_DATA *ppd = pPropData;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W_DATA data;
|
|
|
|
DWORD len;
|
|
|
|
HRESULT hr;
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
|
2009-12-09 16:57:58 +01:00
|
|
|
pPropData,cbPropData,pcbReturned);
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2009-12-09 16:57:58 +01:00
|
|
|
if (!ppd || !ppd->DeviceName) {
|
|
|
|
WARN("invalid parameter: ppd=%p\n", ppd);
|
|
|
|
return DSERR_INVALIDPARAM;
|
2003-04-30 00:49:52 +02:00
|
|
|
}
|
|
|
|
|
2009-12-09 16:57:58 +01:00
|
|
|
data.DataFlow = ppd->DataFlow;
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, ppd->DeviceName, -1, NULL, 0);
|
|
|
|
data.DeviceName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!data.DeviceName)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, ppd->DeviceName, -1, data.DeviceName, len);
|
|
|
|
|
|
|
|
hr = DSPROPERTY_WaveDeviceMappingW(&data, cbPropData, pcbReturned);
|
|
|
|
HeapFree(GetProcessHeap(), 0, data.DeviceName);
|
|
|
|
ppd->DeviceId = data.DeviceId;
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2005-04-13 16:39:49 +02:00
|
|
|
if (pcbReturned)
|
|
|
|
*pcbReturned = cbPropData;
|
|
|
|
|
|
|
|
return hr;
|
2003-04-30 00:49:52 +02:00
|
|
|
}
|
|
|
|
|
2008-11-28 15:20:03 +01:00
|
|
|
static HRESULT DSPROPERTY_DescriptionW(
|
2003-04-30 00:49:52 +02:00
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned )
|
|
|
|
{
|
2009-01-11 00:15:53 +01:00
|
|
|
PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = pPropData;
|
2004-08-20 22:01:31 +02:00
|
|
|
GUID dev_guid;
|
2011-09-27 15:51:33 +02:00
|
|
|
IMMDevice *mmdevice;
|
|
|
|
IPropertyStore *ps;
|
|
|
|
PROPVARIANT pv;
|
|
|
|
HRESULT hr;
|
2009-12-09 16:57:59 +01:00
|
|
|
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
|
2009-12-09 16:57:59 +01:00
|
|
|
pPropData,cbPropData,pcbReturned);
|
2003-04-30 00:49:52 +02:00
|
|
|
|
|
|
|
TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
|
|
|
|
if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
|
2009-12-09 16:57:59 +01:00
|
|
|
/* default device of type specified by ppd->DataFlow */
|
|
|
|
if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
|
|
|
|
TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
|
|
|
|
ppd->DeviceId = DSDEVID_DefaultCapture;
|
|
|
|
} else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
|
|
|
|
TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
|
|
|
|
ppd->DeviceId = DSDEVID_DefaultPlayback;
|
|
|
|
} else {
|
|
|
|
WARN("DataFlow=Unknown(%d)\n", ppd->DataFlow);
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
2003-09-03 21:28:20 +02:00
|
|
|
}
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2011-06-23 20:12:01 +02:00
|
|
|
setup_dsound_options();
|
|
|
|
|
2003-09-03 21:28:20 +02:00
|
|
|
GetDeviceID(&ppd->DeviceId, &dev_guid);
|
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
hr = get_mmdevice(eRender, &dev_guid, &mmdevice);
|
|
|
|
if(FAILED(hr)){
|
|
|
|
hr = get_mmdevice(eCapture, &dev_guid, &mmdevice);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
2009-12-09 16:57:59 +01:00
|
|
|
}
|
2005-03-14 11:03:54 +01:00
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
hr = IMMDevice_OpenPropertyStore(mmdevice, STGM_READ, &ps);
|
|
|
|
if(FAILED(hr)){
|
|
|
|
IMMDevice_Release(mmdevice);
|
2022-02-10 08:41:37 +01:00
|
|
|
WARN("OpenPropertyStore failed: %08lx\n", hr);
|
2011-09-27 15:51:33 +02:00
|
|
|
return hr;
|
2009-12-09 16:57:59 +01:00
|
|
|
}
|
2003-10-09 00:35:26 +02:00
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
hr = IPropertyStore_GetValue(ps,
|
|
|
|
(const PROPERTYKEY *)&DEVPKEY_Device_FriendlyName, &pv);
|
|
|
|
if(FAILED(hr)){
|
|
|
|
IPropertyStore_Release(ps);
|
|
|
|
IMMDevice_Release(mmdevice);
|
2022-02-10 08:41:37 +01:00
|
|
|
WARN("GetValue(FriendlyName) failed: %08lx\n", hr);
|
2011-09-27 15:51:33 +02:00
|
|
|
return hr;
|
2003-04-30 00:49:52 +02:00
|
|
|
}
|
|
|
|
|
2021-03-30 20:09:43 +02:00
|
|
|
ppd->Description = strdupW(pv.pwszVal);
|
2017-06-21 10:23:52 +02:00
|
|
|
ppd->Module = strdupW(wine_vxd_drv);
|
|
|
|
ppd->Interface = strdupW(wInterface);
|
2009-12-09 16:57:59 +01:00
|
|
|
ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
|
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
PropVariantClear(&pv);
|
|
|
|
IPropertyStore_Release(ps);
|
|
|
|
IMMDevice_Release(mmdevice);
|
|
|
|
|
2003-04-30 00:49:52 +02:00
|
|
|
if (pcbReturned) {
|
2009-12-09 16:57:59 +01:00
|
|
|
*pcbReturned = sizeof(*ppd);
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("*pcbReturned=%ld\n", *pcbReturned);
|
2003-04-30 00:49:52 +02:00
|
|
|
}
|
2003-05-02 22:16:48 +02:00
|
|
|
|
2003-04-30 00:49:52 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-03 13:24:12 +02:00
|
|
|
static
|
2011-09-27 15:51:33 +02:00
|
|
|
BOOL CALLBACK enum_callback(GUID *guid, const WCHAR *desc, const WCHAR *module,
|
|
|
|
void *user)
|
|
|
|
{
|
|
|
|
PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = user;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
|
|
|
|
DWORD len;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("%s %s %s %p\n", wine_dbgstr_guid(guid), wine_dbgstr_w(desc),
|
|
|
|
wine_dbgstr_w(module), user);
|
|
|
|
|
|
|
|
if(!guid)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
data.DeviceId = *guid;
|
|
|
|
|
|
|
|
len = lstrlenW(module) + 1;
|
|
|
|
data.Module = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
memcpy(data.Module, module, len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
len = lstrlenW(desc) + 1;
|
|
|
|
data.Description = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
memcpy(data.Description, desc, len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
data.Interface = wInterface;
|
|
|
|
|
|
|
|
ret = ppd->Callback(&data, ppd->Context);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, data.Module);
|
|
|
|
HeapFree(GetProcessHeap(), 0, data.Description);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-11-28 15:20:03 +01:00
|
|
|
static HRESULT DSPROPERTY_EnumerateW(
|
2003-04-30 00:49:52 +02:00
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned )
|
|
|
|
{
|
2009-01-11 00:15:53 +01:00
|
|
|
PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = pPropData;
|
2011-09-27 15:51:33 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
|
2006-08-22 13:36:08 +02:00
|
|
|
pPropData,cbPropData,pcbReturned);
|
|
|
|
|
2009-12-09 16:58:00 +01:00
|
|
|
if (pcbReturned)
|
|
|
|
*pcbReturned = 0;
|
2006-08-22 13:36:08 +02:00
|
|
|
|
2009-12-09 16:58:00 +01:00
|
|
|
if (!ppd || !ppd->Callback)
|
|
|
|
{
|
|
|
|
WARN("Invalid ppd %p\n", ppd);
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
2006-08-22 13:36:08 +02:00
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids,
|
|
|
|
enum_callback, ppd);
|
2003-08-07 00:57:24 +02:00
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
if(hr == S_OK)
|
|
|
|
hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids,
|
|
|
|
enum_callback, ppd);
|
2003-08-07 00:57:24 +02:00
|
|
|
|
2011-09-27 15:51:33 +02:00
|
|
|
return SUCCEEDED(hr) ? DS_OK : hr;
|
2003-04-30 00:49:52 +02:00
|
|
|
}
|
|
|
|
|
2010-09-11 18:02:12 +02:00
|
|
|
static BOOL DSPROPERTY_descWtoA(const DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA *dataW,
|
2009-12-09 16:58:01 +01:00
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA *dataA)
|
|
|
|
{
|
|
|
|
DWORD modlen, desclen;
|
|
|
|
static char Interface[] = "Interface";
|
|
|
|
|
|
|
|
modlen = WideCharToMultiByte(CP_ACP, 0, dataW->Module, -1, NULL, 0, NULL, NULL);
|
|
|
|
desclen = WideCharToMultiByte(CP_ACP, 0, dataW->Description, -1, NULL, 0, NULL, NULL);
|
|
|
|
dataA->Type = dataW->Type;
|
|
|
|
dataA->DataFlow = dataW->DataFlow;
|
|
|
|
dataA->DeviceId = dataW->DeviceId;
|
|
|
|
dataA->WaveDeviceId = dataW->WaveDeviceId;
|
|
|
|
dataA->Interface = Interface;
|
|
|
|
dataA->Module = HeapAlloc(GetProcessHeap(), 0, modlen);
|
|
|
|
dataA->Description = HeapAlloc(GetProcessHeap(), 0, desclen);
|
|
|
|
if (!dataA->Module || !dataA->Description)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, dataA->Module);
|
|
|
|
HeapFree(GetProcessHeap(), 0, dataA->Description);
|
|
|
|
dataA->Module = dataA->Description = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, dataW->Module, -1, dataA->Module, modlen, NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, dataW->Description, -1, dataA->Description, desclen, NULL, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-09-11 18:02:12 +02:00
|
|
|
static void DSPROPERTY_descWto1(const DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA *dataW,
|
2009-12-09 16:58:02 +01:00
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA *data1)
|
|
|
|
{
|
|
|
|
data1->DeviceId = dataW->DeviceId;
|
2018-08-08 11:30:06 +02:00
|
|
|
lstrcpynW(data1->ModuleW, dataW->Module, ARRAY_SIZE(data1->ModuleW));
|
|
|
|
lstrcpynW(data1->DescriptionW, dataW->Description, ARRAY_SIZE(data1->DescriptionW));
|
2009-12-09 16:58:02 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, data1->DescriptionW, -1, data1->DescriptionA, sizeof(data1->DescriptionA)-1, NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, data1->ModuleW, -1, data1->ModuleA, sizeof(data1->ModuleA)-1, NULL, NULL);
|
|
|
|
data1->DescriptionA[sizeof(data1->DescriptionA)-1] = 0;
|
|
|
|
data1->ModuleA[sizeof(data1->ModuleA)-1] = 0;
|
|
|
|
data1->Type = dataW->Type;
|
|
|
|
data1->DataFlow = dataW->DataFlow;
|
|
|
|
data1->WaveDeviceId = data1->Devnode = dataW->WaveDeviceId;
|
|
|
|
}
|
|
|
|
|
2009-12-09 16:58:01 +01:00
|
|
|
static BOOL CALLBACK DSPROPERTY_enumWtoA(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA *descW, void *data)
|
|
|
|
{
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA descA;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA *ppd = data;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ret = DSPROPERTY_descWtoA(descW, &descA);
|
|
|
|
if (!ret)
|
|
|
|
return FALSE;
|
|
|
|
ret = ppd->Callback(&descA, ppd->Context);
|
|
|
|
HeapFree(GetProcessHeap(), 0, descA.Module);
|
|
|
|
HeapFree(GetProcessHeap(), 0, descA.Description);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT DSPROPERTY_EnumerateA(
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned)
|
|
|
|
{
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA *ppd = pPropData;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
|
|
|
|
|
|
|
|
if (!ppd || !ppd->Callback)
|
|
|
|
{
|
|
|
|
WARN("Invalid ppd %p\n", ppd);
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
data.Callback = DSPROPERTY_enumWtoA;
|
|
|
|
data.Context = ppd;
|
|
|
|
|
|
|
|
return DSPROPERTY_EnumerateW(&data, cbPropData, pcbReturned);
|
|
|
|
}
|
|
|
|
|
2009-12-09 16:58:02 +01:00
|
|
|
static BOOL CALLBACK DSPROPERTY_enumWto1(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA *descW, void *data)
|
|
|
|
{
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA desc1;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA *ppd = data;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
DSPROPERTY_descWto1(descW, &desc1);
|
|
|
|
ret = ppd->Callback(&desc1, ppd->Context);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT DSPROPERTY_Enumerate1(
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned)
|
|
|
|
{
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA *ppd = pPropData;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
|
|
|
|
|
|
|
|
if (!ppd || !ppd->Callback)
|
|
|
|
{
|
|
|
|
WARN("Invalid ppd %p\n", ppd);
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
data.Callback = DSPROPERTY_enumWto1;
|
|
|
|
data.Context = ppd;
|
|
|
|
|
|
|
|
return DSPROPERTY_EnumerateW(&data, cbPropData, pcbReturned);
|
|
|
|
}
|
|
|
|
|
2009-12-09 16:58:03 +01:00
|
|
|
static HRESULT DSPROPERTY_DescriptionA(
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned)
|
|
|
|
{
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA *ppd = pPropData;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (pcbReturned)
|
|
|
|
*pcbReturned = sizeof(*ppd);
|
|
|
|
if (!pPropData)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
data.DeviceId = ppd->DeviceId;
|
|
|
|
data.DataFlow = ppd->DataFlow;
|
|
|
|
hr = DSPROPERTY_DescriptionW(&data, sizeof(data), NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
if (!DSPROPERTY_descWtoA(&data, ppd))
|
|
|
|
hr = E_OUTOFMEMORY;
|
2017-06-21 10:23:52 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, data.Description);
|
2009-12-09 16:58:03 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, data.Module);
|
|
|
|
HeapFree(GetProcessHeap(), 0, data.Interface);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-12-09 16:58:04 +01:00
|
|
|
static HRESULT DSPROPERTY_Description1(
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned)
|
|
|
|
{
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data;
|
|
|
|
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA *ppd = pPropData;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (pcbReturned)
|
|
|
|
*pcbReturned = sizeof(*ppd);
|
|
|
|
if (!pPropData)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
data.DeviceId = ppd->DeviceId;
|
|
|
|
data.DataFlow = ppd->DataFlow;
|
|
|
|
hr = DSPROPERTY_DescriptionW(&data, sizeof(data), NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
DSPROPERTY_descWto1(&data, ppd);
|
2017-06-21 10:23:52 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, data.Description);
|
2009-12-09 16:58:04 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, data.Module);
|
|
|
|
HeapFree(GetProcessHeap(), 0, data.Interface);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2003-08-20 20:18:23 +02:00
|
|
|
static HRESULT WINAPI IKsPrivatePropertySetImpl_Get(
|
|
|
|
LPKSPROPERTYSET iface,
|
|
|
|
REFGUID guidPropSet,
|
|
|
|
ULONG dwPropID,
|
|
|
|
LPVOID pInstanceData,
|
|
|
|
ULONG cbInstanceData,
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
2005-03-14 11:03:54 +01:00
|
|
|
PULONG pcbReturned )
|
|
|
|
{
|
2011-04-08 14:11:34 +02:00
|
|
|
IKsPrivatePropertySetImpl *This = impl_from_IKsPropertySet(iface);
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("(iface=%p,guidPropSet=%s,dwPropID=%lu,pInstanceData=%p,cbInstanceData=%lu,pPropData=%p,cbPropData=%lu,pcbReturned=%p)\n",
|
2006-08-22 13:36:08 +02:00
|
|
|
This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
|
2003-08-07 00:57:24 +02:00
|
|
|
|
|
|
|
if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
|
2006-08-22 13:36:08 +02:00
|
|
|
switch (dwPropID) {
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
|
|
|
|
return DSPROPERTY_WaveDeviceMappingA(pPropData,cbPropData,pcbReturned);
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
|
|
|
|
return DSPROPERTY_Description1(pPropData,cbPropData,pcbReturned);
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
|
|
|
|
return DSPROPERTY_Enumerate1(pPropData,cbPropData,pcbReturned);
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
|
|
|
|
return DSPROPERTY_WaveDeviceMappingW(pPropData,cbPropData,pcbReturned);
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
|
|
|
|
return DSPROPERTY_DescriptionA(pPropData,cbPropData,pcbReturned);
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
|
|
|
|
return DSPROPERTY_DescriptionW(pPropData,cbPropData,pcbReturned);
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
|
|
|
|
return DSPROPERTY_EnumerateA(pPropData,cbPropData,pcbReturned);
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
|
|
|
|
return DSPROPERTY_EnumerateW(pPropData,cbPropData,pcbReturned);
|
|
|
|
default:
|
2022-02-10 08:41:37 +01:00
|
|
|
FIXME("unsupported ID: %ld\n",dwPropID);
|
2006-08-22 13:36:08 +02:00
|
|
|
break;
|
|
|
|
}
|
2003-08-07 00:57:24 +02:00
|
|
|
} else {
|
2006-08-22 13:36:08 +02:00
|
|
|
FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
|
2003-08-07 00:57:24 +02:00
|
|
|
}
|
2003-04-30 00:49:52 +02:00
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
if (pcbReturned) {
|
2006-08-22 13:36:08 +02:00
|
|
|
*pcbReturned = 0;
|
2022-02-10 08:41:37 +01:00
|
|
|
FIXME("*pcbReturned=%ld\n", *pcbReturned);
|
2003-08-07 00:57:24 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2003-08-20 20:18:23 +02:00
|
|
|
static HRESULT WINAPI IKsPrivatePropertySetImpl_Set(
|
|
|
|
LPKSPROPERTYSET iface,
|
|
|
|
REFGUID guidPropSet,
|
|
|
|
ULONG dwPropID,
|
|
|
|
LPVOID pInstanceData,
|
|
|
|
ULONG cbInstanceData,
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData )
|
|
|
|
{
|
2011-04-08 14:11:34 +02:00
|
|
|
IKsPrivatePropertySetImpl *This = impl_from_IKsPropertySet(iface);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2022-02-10 08:41:37 +01:00
|
|
|
FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
|
2003-08-20 20:18:23 +02:00
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2003-08-20 20:18:23 +02:00
|
|
|
static HRESULT WINAPI IKsPrivatePropertySetImpl_QuerySupport(
|
|
|
|
LPKSPROPERTYSET iface,
|
|
|
|
REFGUID guidPropSet,
|
|
|
|
ULONG dwPropID,
|
|
|
|
PULONG pTypeSupport )
|
|
|
|
{
|
2011-04-08 14:11:34 +02:00
|
|
|
IKsPrivatePropertySetImpl *This = impl_from_IKsPropertySet(iface);
|
2022-02-10 08:41:37 +01:00
|
|
|
TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
|
2003-08-07 00:57:24 +02:00
|
|
|
|
|
|
|
if ( IsEqualGUID( &DSPROPSETID_DirectSoundDevice, guidPropSet) ) {
|
|
|
|
switch (dwPropID) {
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
case DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W:
|
|
|
|
*pTypeSupport = KSPROPERTY_SUPPORT_GET;
|
|
|
|
return S_OK;
|
|
|
|
default:
|
2022-02-10 08:41:37 +01:00
|
|
|
FIXME("unsupported ID: %ld\n",dwPropID);
|
2003-08-07 00:57:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
FIXME("unsupported property: %s\n",debugstr_guid(guidPropSet));
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IKsPropertySetVtbl ikspvt = {
|
2003-08-20 20:18:23 +02:00
|
|
|
IKsPrivatePropertySetImpl_QueryInterface,
|
|
|
|
IKsPrivatePropertySetImpl_AddRef,
|
|
|
|
IKsPrivatePropertySetImpl_Release,
|
|
|
|
IKsPrivatePropertySetImpl_Get,
|
|
|
|
IKsPrivatePropertySetImpl_Set,
|
|
|
|
IKsPrivatePropertySetImpl_QuerySupport
|
2002-06-13 21:15:06 +02:00
|
|
|
};
|
|
|
|
|
2012-08-24 01:47:14 +02:00
|
|
|
HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, void **ppv)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-08-20 20:18:23 +02:00
|
|
|
IKsPrivatePropertySetImpl *iks;
|
2012-08-24 01:47:14 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
|
2006-08-18 07:13:31 +02:00
|
|
|
|
2012-08-24 01:47:14 +02:00
|
|
|
iks = HeapAlloc(GetProcessHeap(), 0, sizeof(*iks));
|
|
|
|
if (!iks) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
2006-08-18 07:13:31 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2005-06-04 11:38:14 +02:00
|
|
|
iks->ref = 1;
|
2011-04-08 14:11:34 +02:00
|
|
|
iks->IKsPropertySet_iface.lpVtbl = &ikspvt;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2012-08-24 01:47:14 +02:00
|
|
|
hr = IKsPropertySet_QueryInterface(&iks->IKsPropertySet_iface, riid, ppv);
|
|
|
|
IKsPropertySet_Release(&iks->IKsPropertySet_iface);
|
|
|
|
|
|
|
|
return hr;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|