From 05597627e0eea1a7181eed68363be42b8c4ee4ac Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Wed, 8 Apr 2015 17:10:40 +0000 Subject: [PATCH] [MMDEVAPI] Sync with Wine Staging 1.7.37. CORE-9246 svn path=/trunk/; revision=67085 --- reactos/dll/win32/mmdevapi/CMakeLists.txt | 1 + reactos/dll/win32/mmdevapi/audiovolume.c | 57 ++++++++++++++++------ reactos/dll/win32/mmdevapi/devenum.c | 59 ++++++++++++++++++++++- reactos/dll/win32/mmdevapi/main.c | 5 +- reactos/dll/win32/mmdevapi/mmdevapi.h | 2 + reactos/media/doc/README.WINE | 2 +- 6 files changed, 107 insertions(+), 19 deletions(-) diff --git a/reactos/dll/win32/mmdevapi/CMakeLists.txt b/reactos/dll/win32/mmdevapi/CMakeLists.txt index 1172f54f012..2ab3fd0905b 100644 --- a/reactos/dll/win32/mmdevapi/CMakeLists.txt +++ b/reactos/dll/win32/mmdevapi/CMakeLists.txt @@ -23,4 +23,5 @@ set_module_type(mmdevapi win32dll) target_link_libraries(mmdevapi uuid wine) add_importlibs(mmdevapi ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) add_pch(mmdevapi mmdevapi.h SOURCE) +add_dependencies(mmdevapi dxsdk) add_cd_file(TARGET mmdevapi DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/mmdevapi/audiovolume.c b/reactos/dll/win32/mmdevapi/audiovolume.c index 845241a3284..9c37cf8b255 100644 --- a/reactos/dll/win32/mmdevapi/audiovolume.c +++ b/reactos/dll/win32/mmdevapi/audiovolume.c @@ -23,6 +23,8 @@ static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl; typedef struct AEVImpl { IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface; LONG ref; + float level; + BOOL mute; } AEVImpl; static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface) @@ -39,6 +41,8 @@ HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv) return E_OUTOFMEMORY; This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl; This->ref = 1; + This->level = 1.0f; + This->mute = FALSE; return S_OK; } @@ -112,9 +116,13 @@ static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *c static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx) { - TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx)); - FIXME("stub\n"); - return E_NOTIMPL; + AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); + + FIXME("(%p)->(%f,%s): stub\n", iface, leveldb, debugstr_guid(ctx)); + + This->level = leveldb; + + return S_OK; } static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx) @@ -126,11 +134,16 @@ static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *ifa static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb) { - TRACE("(%p)->(%p)\n", iface, leveldb); + AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); + + FIXME("(%p)->(%p): stub\n", iface, leveldb); + if (!leveldb) return E_POINTER; - FIXME("stub\n"); - return E_NOTIMPL; + + *leveldb = This->level; + + return S_OK; } static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level) @@ -176,18 +189,27 @@ static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *if static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx) { - TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx)); - FIXME("stub\n"); - return E_NOTIMPL; + AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); + + FIXME("(%p)->(%u,%s): stub\n", iface, mute, debugstr_guid(ctx)); + + This->mute = mute; + + return S_OK; } static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute) { - TRACE("(%p)->(%p)\n", iface, mute); + AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); + + FIXME("(%p)->(%p): stub\n", iface, mute); + if (!mute) return E_POINTER; - FIXME("stub\n"); - return E_NOTIMPL; + + *mute = This->mute; + + return S_OK; } static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount) @@ -224,11 +246,16 @@ static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DW static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc) { - TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc); + FIXME("(%p)->(%p,%p,%p): stub\n", iface, mindb, maxdb, inc); + if (!mindb || !maxdb || !inc) return E_POINTER; - FIXME("stub\n"); - return E_NOTIMPL; + + *mindb = 0.0f; + *maxdb = 1.0f; + *inc = 0.1f; + + return S_OK; } static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc) diff --git a/reactos/dll/win32/mmdevapi/devenum.c b/reactos/dll/win32/mmdevapi/devenum.c index a4c77764f6f..1551b9e3471 100644 --- a/reactos/dll/win32/mmdevapi/devenum.c +++ b/reactos/dll/win32/mmdevapi/devenum.c @@ -246,6 +246,25 @@ static HRESULT MMDevice_SetPropValue(const GUID *devguid, DWORD flow, REFPROPERT return hr; } +static HRESULT set_driver_prop_value(GUID *id, const EDataFlow flow, const PROPERTYKEY *prop) +{ + HRESULT hr; + PROPVARIANT pv; + + if (!drvs.pGetPropValue) + return E_NOTIMPL; + + hr = drvs.pGetPropValue(id, prop, &pv); + + if (SUCCEEDED(hr)) + { + MMDevice_SetPropValue(id, flow, prop, &pv); + PropVariantClear(&pv); + } + + return hr; +} + /* Creates or updates the state of a device * If GUID is null, a random guid will be assigned * and the device will be created @@ -261,6 +280,10 @@ static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD st {0x233164c8, 0x1b2c, 0x4c7d, {0xbc, 0x68, 0xb6, 0x71, 0x68, 0x7a, 0x25, 0x67}}, 1 }; + static const PROPERTYKEY devicepath_key = { + {0xb3f8fa53, 0x0004, 0x438e, {0x90, 0x03, 0x51, 0xa4, 0x6e, 0x13, 0x9b, 0xfc}}, 2 + }; + for (i = 0; i < MMDevice_count; ++i) { MMDevice *device = MMDevice_head[i]; @@ -320,6 +343,29 @@ static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD st pv.u.pwszVal = guidstr; MMDevice_SetPropValue(id, flow, &deviceinterface_key, &pv); + set_driver_prop_value(id, flow, &devicepath_key); + + if (FAILED(set_driver_prop_value(id, flow, &PKEY_AudioEndpoint_FormFactor))) + { + pv.vt = VT_UI4; + pv.u.ulVal = (flow == eCapture) ? Microphone : Speakers; + + MMDevice_SetPropValue(id, flow, &PKEY_AudioEndpoint_FormFactor, &pv); + } + + if (flow != eCapture) + { + PROPVARIANT pv2; + + PropVariantInit(&pv2); + + /* make read-write by not overwriting if already set */ + if (FAILED(MMDevice_GetPropValue(id, flow, &PKEY_AudioEndpoint_PhysicalSpeakers, &pv2)) || pv2.vt != VT_UI4) + set_driver_prop_value(id, flow, &PKEY_AudioEndpoint_PhysicalSpeakers); + + PropVariantClear(&pv2); + } + RegCloseKey(keyprop); } RegCloseKey(key); @@ -1405,8 +1451,17 @@ static HRESULT WINAPI MMDevPropStore_SetValue(IPropertyStore *iface, REFPROPERTY static HRESULT WINAPI MMDevPropStore_Commit(IPropertyStore *iface) { - FIXME("stub\n"); - return E_NOTIMPL; + MMDevPropStore *This = impl_from_IPropertyStore(iface); + TRACE("(%p)\n", iface); + + if (This->access != STGM_WRITE + && This->access != STGM_READWRITE) + return STG_E_ACCESSDENIED; + + /* Does nothing - for mmdevapi, the propstore values are written on SetValue, + * not on Commit. */ + + return S_OK; } static const IPropertyStoreVtbl MMDevPropVtbl = diff --git a/reactos/dll/win32/mmdevapi/main.c b/reactos/dll/win32/mmdevapi/main.c index 63432de0cb9..184280a53ff 100644 --- a/reactos/dll/win32/mmdevapi/main.c +++ b/reactos/dll/win32/mmdevapi/main.c @@ -70,6 +70,9 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) LDFC(GetAudioSessionManager); #undef LDFC + /* optional - do not fail if not found */ + driver->pGetPropValue = (void*)GetProcAddress(driver->module, "GetPropValue"); + driver->priority = driver->pGetPriority(); lstrcpyW(driver->module_name, driver_module); @@ -83,7 +86,7 @@ static BOOL init_driver(void) { static const WCHAR drv_value[] = {'A','u','d','i','o',0}; - static WCHAR default_list[] = {'a','l','s','a',',','o','s','s',',', + static WCHAR default_list[] = {'p','u','l','s','e',',','a','l','s','a',',','o','s','s',',', 'c','o','r','e','a','u','d','i','o',0}; DriverFuncs driver; diff --git a/reactos/dll/win32/mmdevapi/mmdevapi.h b/reactos/dll/win32/mmdevapi/mmdevapi.h index 19b87ca7887..7a23458577d 100644 --- a/reactos/dll/win32/mmdevapi/mmdevapi.h +++ b/reactos/dll/win32/mmdevapi/mmdevapi.h @@ -79,6 +79,8 @@ typedef struct _DriverFuncs { IAudioClient **out); HRESULT (WINAPI *pGetAudioSessionManager)(IMMDevice *device, IAudioSessionManager2 **out); + HRESULT (WINAPI *pGetPropValue)(GUID *guid, + const PROPERTYKEY *prop, PROPVARIANT *out); } DriverFuncs; extern DriverFuncs drvs DECLSPEC_HIDDEN; diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 6ed2cbc2e4d..fb1bfe10639 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -108,7 +108,7 @@ reactos/dll/win32/mciseq # Synced to WineStaging-1.7.37 reactos/dll/win32/mciwave # Synced to WineStaging-1.7.37 reactos/dll/win32/mgmtapi # Synced to Wine-1.7.27 reactos/dll/win32/mlang # Synced to WineStaging-1.7.37 -reactos/dll/win32/mmdevapi # Synced to Wine-1.7.27 +reactos/dll/win32/mmdevapi # Synced to WineStaging-1.7.37 reactos/dll/win32/mpr # Synced to Wine-1.7.27 reactos/dll/win32/mprapi # Synced to Wine-1.7.27 reactos/dll/win32/msacm32 # Synced to Wine-1.7.27