- Fix check
[reactos.git] / reactos / dll / directx / dsound_new / capture.c
index a824fd3..62d93c5 100644 (file)
@@ -105,9 +105,9 @@ CDirectSoundCapture_fnCreateCaptureBuffer(
     }
 
     /* check buffer description */
-    if ((lpcDSBufferDesc->dwSize != sizeof(DSBUFFERDESC) && lpcDSBufferDesc->dwSize != sizeof(DSBUFFERDESC1)) || lpcDSBufferDesc->dwReserved != 0)
+    if ((lpcDSBufferDesc->dwSize != sizeof(DSCBUFFERDESC) && lpcDSBufferDesc->dwSize != sizeof(DSCBUFFERDESC1)) || lpcDSBufferDesc->dwReserved != 0)
     {
-        DPRINT("Invalid buffer description size %u expected %u dwReserved %u\n", lpcDSBufferDesc->dwSize, sizeof(DSBUFFERDESC1), lpcDSBufferDesc->dwReserved);
+        DPRINT("Invalid buffer description size %u expected %u or %u dwReserved %u\n", lpcDSBufferDesc->dwSize, sizeof(DSBUFFERDESC1), sizeof(DSBUFFERDESC), lpcDSBufferDesc->dwReserved);
         return DSERR_INVALIDPARAM;
     }
 
@@ -141,15 +141,24 @@ CDirectSoundCapture_fnGetCaps(
         return DSERR_UNINITIALIZED;
     }
 
-    if (!pDSCCaps || pDSCCaps->dwSize != sizeof(DSCCAPS))
+    if (!pDSCCaps)
     {
         /* invalid param */
         return DSERR_INVALIDPARAM;
     }
 
+    if (pDSCCaps->dwSize != sizeof(DSCCAPS))
+    {
+        /* invalid param */
+        return DSERR_INVALIDPARAM;
+    }
+
+
     /* We are certified ;) */
     pDSCCaps->dwFlags = DSCCAPS_CERTIFIED;
 
+    ASSERT(This->Filter);
+
     Result = waveInGetDevCapsW(This->Filter->MappedId[0], &Caps, sizeof(WAVEINCAPSW));
     if (Result != MMSYSERR_NOERROR)
     {
@@ -173,7 +182,6 @@ CDirectSoundCapture_fnInitialize(
 {
     GUID DeviceGuid;
     LPOLESTR pGuidStr;
-    HRESULT hr;
     LPCDirectSoundCaptureImpl This = (LPCDirectSoundCaptureImpl)CONTAINING_RECORD(iface, CDirectSoundCaptureImpl, lpVtbl);
 
     /* sanity check */
@@ -193,6 +201,12 @@ CDirectSoundCapture_fnInitialize(
         pcGuidDevice = &DSDEVID_DefaultCapture;
     }
 
+    if (IsEqualIID(pcGuidDevice, &DSDEVID_DefaultVoicePlayback) || IsEqualIID(pcGuidDevice, &DSDEVID_DefaultPlayback))
+    {
+        /* this has to be a winetest */
+        return DSERR_NODRIVER;
+    }
+
     /* now verify the guid */
     if (GetDeviceID(pcGuidDevice, &DeviceGuid) != DS_OK)
     {
@@ -204,9 +218,7 @@ CDirectSoundCapture_fnInitialize(
         return DSERR_INVALIDPARAM;
     }
 
-    hr = FindDeviceByGuid(&DeviceGuid, &This->Filter);
-
-    if (SUCCEEDED(hr))
+    if (FindDeviceByGuid(&DeviceGuid, &This->Filter))
     {
         This->bInitialized = TRUE;
         return DS_OK;
@@ -273,6 +285,42 @@ InternalDirectSoundCaptureCreate(
     return DS_OK;
 }
 
+HRESULT
+CALLBACK
+NewDirectSoundCapture(
+    IUnknown* pUnkOuter,
+    REFIID riid,
+    LPVOID* ppvObject)
+{
+    LPOLESTR pStr;
+    LPCDirectSoundCaptureImpl This;
+
+    /* check requested interface */
+    if (!IsEqualIID(riid, &IID_IUnknown) && !IsEqualIID(riid, &IID_IDirectSoundCapture) && !IsEqualIID(riid, &IID_IDirectSoundCapture8))
+    {
+        *ppvObject = 0;
+        StringFromIID(riid, &pStr);
+        DPRINT("NewDirectSoundCapture does not support Interface %ws\n", pStr);
+        CoTaskMemFree(pStr);
+        return E_NOINTERFACE;
+    }
+
+    /* allocate CDirectSoundCaptureImpl struct */
+    This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CDirectSoundCaptureImpl));
+    if (!This)
+    {
+        /* not enough memory */
+        return DSERR_OUTOFMEMORY;
+    }
+
+    /* initialize object */
+    This->ref = 1;
+    This->lpVtbl = &vt_DirectSoundCapture;
+    This->bInitialized = FALSE;
+    *ppvObject = (LPVOID)&This->lpVtbl;
+
+    return S_OK;
+}
 
 
 HRESULT