1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS Configuration of network devices 4 * FILE: dll/directx/dsound_new/property.c 5 * PURPOSE: Secondary IDirectSoundBuffer8 implementation 6 * 7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org) 8 */ 9 10 11 #include "precomp.h" 12 13 typedef struct 14 { 15 IKsPropertySetVtbl *lpVtbl; 16 LONG ref; 17 18 }CKsPropertySetImpl, *LPCKsPropertySetImpl; 19 20 HRESULT 21 WINAPI 22 KSPropertySetImpl_fnQueryInterface( 23 LPKSPROPERTYSET iface, 24 REFIID riid, 25 LPVOID * ppobj) 26 { 27 LPOLESTR pStr; 28 LPCKsPropertySetImpl This = (LPCKsPropertySetImpl)CONTAINING_RECORD(iface, CKsPropertySetImpl, lpVtbl); 29 30 31 if (IsEqualIID(riid, &IID_IUnknown) || 32 IsEqualIID(riid, &IID_IKsPropertySet)) 33 { 34 *ppobj = (LPVOID)&This->lpVtbl; 35 InterlockedIncrement(&This->ref); 36 return S_OK; 37 } 38 39 if (SUCCEEDED(StringFromIID(riid, &pStr))) 40 { 41 DPRINT("No Interface for riid %s\n", pStr); 42 CoTaskMemFree(pStr); 43 } 44 return E_NOINTERFACE; 45 } 46 47 ULONG 48 WINAPI 49 KSPropertySetImpl_fnAddRef( 50 LPKSPROPERTYSET iface) 51 { 52 ULONG ref; 53 LPCKsPropertySetImpl This = (LPCKsPropertySetImpl)CONTAINING_RECORD(iface, CKsPropertySetImpl, lpVtbl); 54 55 ref = InterlockedIncrement(&This->ref); 56 57 return ref; 58 } 59 60 ULONG 61 WINAPI 62 KSPropertySetImpl_fnRelease( 63 LPKSPROPERTYSET iface) 64 { 65 ULONG ref; 66 LPCKsPropertySetImpl This = (LPCKsPropertySetImpl)CONTAINING_RECORD(iface, CKsPropertySetImpl, lpVtbl); 67 68 ref = InterlockedDecrement(&(This->ref)); 69 70 if (!ref) 71 { 72 HeapFree(GetProcessHeap(), 0, This); 73 } 74 75 return ref; 76 } 77 78 79 HRESULT 80 WINAPI 81 KSPropertySetImpl_Get( 82 LPKSPROPERTYSET iface, 83 REFGUID guidPropSet, 84 ULONG dwPropID, 85 LPVOID pInstanceData, 86 ULONG cbInstanceData, 87 LPVOID pPropData, 88 ULONG cbPropData, 89 PULONG pcbReturned ) 90 { 91 LPOLESTR pStr; 92 //HRESULT hr; 93 MMRESULT Result; 94 WAVEINCAPSW CapsIn; 95 WAVEOUTCAPSW CapsOut; 96 97 GUID DeviceGuid; 98 LPFILTERINFO Filter = NULL; 99 PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA Desc; 100 101 StringFromIID(guidPropSet, &pStr); 102 103 //DPRINT("Requested Property %ws dwPropID %u pInstanceData %p cbInstanceData %u pPropData %p cbPropData %u pcbReturned %p\n", 104 // pStr, dwPropID, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned); 105 CoTaskMemFree(pStr); 106 107 if (!IsEqualGUID(guidPropSet, &DSPROPSETID_DirectSoundDevice)) 108 { 109 /* unsupported property set */ 110 return E_PROP_ID_UNSUPPORTED; 111 } 112 113 if (dwPropID == DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) 114 { 115 if (cbPropData < sizeof(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA)) 116 { 117 /* invalid parameter */ 118 return DSERR_INVALIDPARAM; 119 } 120 121 Desc = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA)pPropData; 122 123 if (IsEqualGUID(&Desc->DeviceId, &GUID_NULL)) 124 { 125 if (Desc->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) 126 { 127 DPRINT("Using default capture guid\n"); 128 CopyMemory(&DeviceGuid, &DSDEVID_DefaultCapture, sizeof(GUID)); 129 } 130 else 131 { 132 DPRINT("Using default playback guid\n"); 133 CopyMemory(&DeviceGuid, &DSDEVID_DefaultPlayback, sizeof(GUID)); 134 } 135 } 136 else 137 { 138 /* use provided guid */ 139 CopyMemory(&DeviceGuid, &Desc->DeviceId, sizeof(GUID)); 140 } 141 142 if (GetDeviceID(&DeviceGuid, &Desc->DeviceId) != DS_OK) 143 { 144 DPRINT("Unknown device guid\n"); 145 return DSERR_INVALIDPARAM; 146 } 147 148 /* sanity check */ 149 ASSERT(FindDeviceByGuid(&Desc->DeviceId, &Filter)); 150 ASSERT(Filter != NULL); 151 152 /* fill in description */ 153 if (IsEqualGUID(&Desc->DeviceId, &Filter->DeviceGuid[0])) 154 { 155 /* capture device */ 156 Desc->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE; 157 Desc->WaveDeviceId = Filter->MappedId[0]; 158 159 Result = waveInGetDevCapsW(Filter->MappedId[0], &CapsIn, sizeof(WAVEINCAPSW)); 160 if (Result != MMSYSERR_NOERROR) 161 { 162 CapsIn.szPname[0] = 0; 163 DPRINT("waveInGetDevCaps Device %u failed with %x\n", Filter->MappedId[0], Result); 164 } 165 166 CapsIn.szPname[MAXPNAMELEN-1] = 0; 167 wcscpy(Desc->DescriptionW, CapsIn.szPname); 168 WideCharToMultiByte(CP_ACP, 0, CapsIn.szPname, -1, Desc->DescriptionA, sizeof(Desc->DescriptionA), NULL, NULL); 169 170 } 171 else 172 { 173 /* render device */ 174 Desc->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER; 175 Desc->WaveDeviceId = Filter->MappedId[1]; 176 177 Result = waveOutGetDevCapsW(Filter->MappedId[1], &CapsOut, sizeof(WAVEOUTCAPSW)); 178 if (Result != MMSYSERR_NOERROR) 179 { 180 CapsOut.szPname[0] = 0; 181 DPRINT("waveOutGetDevCaps Device %u failed with %x\n", Filter->MappedId[1], Result); 182 } 183 184 CapsOut.szPname[MAXPNAMELEN-1] = 0; 185 wcscpy(Desc->DescriptionW, CapsOut.szPname); 186 WideCharToMultiByte(CP_ACP, 0, CapsOut.szPname, -1, Desc->DescriptionA, sizeof(Desc->DescriptionA), NULL, NULL); 187 } 188 189 /* ReactOS doesnt support vxd or emulated */ 190 Desc->Type = DIRECTSOUNDDEVICE_TYPE_WDM; 191 Desc->ModuleA[0] = 0; 192 Desc->ModuleW[0] = 0; 193 194 *pcbReturned = sizeof(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA); 195 return S_OK; 196 } 197 198 199 UNIMPLEMENTED; 200 return E_PROP_ID_UNSUPPORTED; 201 } 202 203 HRESULT 204 WINAPI 205 KSPropertySetImpl_Set( 206 LPKSPROPERTYSET iface, 207 REFGUID guidPropSet, 208 ULONG dwPropID, 209 LPVOID pInstanceData, 210 ULONG cbInstanceData, 211 LPVOID pPropData, 212 ULONG cbPropData ) 213 { 214 UNIMPLEMENTED; 215 return E_PROP_ID_UNSUPPORTED; 216 } 217 218 HRESULT 219 WINAPI 220 KSPropertySetImpl_QuerySupport( 221 LPKSPROPERTYSET iface, 222 REFGUID guidPropSet, 223 ULONG dwPropID, 224 PULONG pTypeSupport ) 225 { 226 UNIMPLEMENTED; 227 return E_PROP_ID_UNSUPPORTED; 228 } 229 230 static IKsPropertySetVtbl vt_KsPropertySet = 231 { 232 /* IUnknown methods */ 233 KSPropertySetImpl_fnQueryInterface, 234 KSPropertySetImpl_fnAddRef, 235 KSPropertySetImpl_fnRelease, 236 /* IKsPropertySet methods */ 237 KSPropertySetImpl_Get, 238 KSPropertySetImpl_Set, 239 KSPropertySetImpl_QuerySupport 240 }; 241 242 HRESULT 243 CALLBACK 244 NewKsPropertySet( 245 IUnknown* pUnkOuter, 246 REFIID riid, 247 LPVOID* ppvObject) 248 { 249 LPOLESTR pStr; 250 LPCKsPropertySetImpl This; 251 252 /* check requested interface */ 253 if (!IsEqualIID(riid, &IID_IUnknown) && !IsEqualIID(riid, &IID_IKsPropertySet)) 254 { 255 *ppvObject = 0; 256 StringFromIID(riid, &pStr); 257 DPRINT("KsPropertySet does not support Interface %ws\n", pStr); 258 CoTaskMemFree(pStr); 259 return E_NOINTERFACE; 260 } 261 262 /* allocate object */ 263 This = HeapAlloc(GetProcessHeap(), 0, sizeof(CKsPropertySetImpl)); 264 if (!This) 265 return E_OUTOFMEMORY; 266 267 /* initialize object */ 268 This->ref = 1; 269 This->lpVtbl = &vt_KsPropertySet; 270 *ppvObject = (LPVOID)&This->lpVtbl; 271 272 return S_OK; 273 } 274