[PATCH 5/7] dsound: Add IDirectSoundCapture stub
Maarten Lankhorst
m.b.lankhorst at gmail.com
Thu Dec 3 03:07:05 CST 2009
---
dlls/dsound/capture.c | 228 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 228 insertions(+), 0 deletions(-)
diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c
index 18b025e..3acd78e 100644
--- a/dlls/dsound/capture.c
+++ b/dlls/dsound/capture.c
@@ -45,6 +45,232 @@ HRESULT DSOUND_CaptureCreate(REFIID riid, IDirectSoundCapture **cap)
return DSOUND_CaptureCreate8(riid, cap);
}
+#ifdef HAVE_OPENAL
+
+typedef struct DSCImpl
+{
+ const IDirectSoundCaptureVtbl *lpVtbl;
+ LONG ref;
+
+ ALCchar *device;
+ CRITICAL_SECTION crst;
+} DSCImpl;
+
+static const IDirectSoundCaptureVtbl DSC_Vtbl;
+
+static void DSCImpl_Destroy(DSCImpl *This);
+
+HRESULT DSOUND_CaptureCreate8(REFIID riid, IDirectSoundCapture8 **cap)
+{
+ DSCImpl *This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
+ *cap = NULL;
+ if (!This)
+ return DSERR_OUTOFMEMORY;
+ This->lpVtbl = &DSC_Vtbl;
+
+ InitializeCriticalSection(&This->crst);
+ This->crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DSCImpl.crst");
+ if (FAILED(IUnknown_QueryInterface((IUnknown*)This, riid, (void**)cap)))
+ {
+ DSCImpl_Destroy(This);
+ return E_NOINTERFACE;
+ }
+ return S_OK;
+}
+
+static void DSCImpl_Destroy(DSCImpl *This)
+{
+ HeapFree(GetProcessHeap(), 0, This->device);
+ This->crst.DebugInfo->Spare[0] = 0;
+ DeleteCriticalSection(&This->crst);
+ HeapFree(GetProcessHeap(), 0, This);
+}
+
+static HRESULT WINAPI DSCImpl_QueryInterface(IDirectSoundCapture *iface, REFIID riid, void **ppv)
+{
+ *ppv = NULL;
+ if (IsEqualIID(riid, &IID_IUnknown)
+ || IsEqualIID(riid, &IID_IDirectSoundCapture))
+ {
+ *ppv = iface;
+ }
+ if (!*ppv)
+ return E_NOINTERFACE;
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
+}
+
+static ULONG WINAPI DSCImpl_AddRef(IDirectSoundCapture8 *iface)
+{
+ DSCImpl *This = (DSCImpl*)iface;
+ LONG ref;
+ ref = InterlockedIncrement(&This->ref);
+ TRACE("Reference count incremented to %i\n", ref);
+ return ref;
+}
+
+static ULONG WINAPI DSCImpl_Release(IDirectSoundCapture8 *iface)
+{
+ DSCImpl *This = (DSCImpl*)iface;
+ LONG ref;
+ ref = InterlockedDecrement(&This->ref);
+ TRACE("Reference count decremented to %i\n", ref);
+ if (!ref)
+ DSCImpl_Destroy(This);
+ return ref;
+}
+
+static HRESULT WINAPI DSCImpl_CreateCaptureBuffer(IDirectSoundCapture8 *iface, const DSCBUFFERDESC *desc, IDirectSoundCaptureBuffer **ppv, IUnknown *unk)
+{
+ DSCImpl *This = (DSCImpl*)iface;
+ HRESULT hr;
+ TRACE("(%p)->(%p,%p,%p)\n", This, desc, ppv, unk);
+
+ if (unk)
+ {
+ WARN("Aggregation isn't supported\n");
+ return DSERR_NOAGGREGATION;
+ }
+
+ if (!desc || desc->dwSize < sizeof(DSCBUFFERDESC1))
+ {
+ WARN("Passed invalid description %p %u\n", desc, desc?desc->dwSize:0);
+ return DSERR_INVALIDPARAM;
+ }
+ if (!ppv)
+ {
+ WARN("Passed null pointer\n");
+ return DSERR_INVALIDPARAM;
+ }
+ *ppv = NULL;
+
+ EnterCriticalSection(&This->crst);
+ if (!This->device)
+ {
+ hr = DSERR_UNINITIALIZED;
+ WARN("Not initialized\n");
+ goto out;
+ }
+ FIXME("stub\n");
+ hr = E_NOTIMPL;
+out:
+ LeaveCriticalSection(&This->crst);
+ return hr;
+}
+
+static HRESULT WINAPI DSCImpl_GetCaps(IDirectSoundCapture8 *iface, DSCCAPS *caps)
+{
+ DSCImpl *This = (DSCImpl*)iface;
+ TRACE("(%p,%p)\n", This, caps);
+
+ if (!This->device) {
+ WARN("Not initialized\n");
+ return DSERR_UNINITIALIZED;
+ }
+
+ if (!caps) {
+ WARN("Caps is null\n");
+ return DSERR_INVALIDPARAM;
+ }
+
+ if (caps->dwSize < sizeof(*caps)) {
+ WARN("Invalid size %d\n", caps->dwSize);
+ return DSERR_INVALIDPARAM;
+ }
+
+ caps->dwFlags = 0;
+ /* Support all WAVE_FORMAT formats specified in mmsystem.h */
+ caps->dwFormats = 0x000fffff;
+ caps->dwChannels = 2;
+
+ return DS_OK;
+}
+
+static HRESULT WINAPI DSCImpl_Initialize(IDirectSoundCapture8 *iface, const GUID *devguid)
+{
+ DSCImpl *This = (DSCImpl*)iface;
+ HRESULT hr;
+ const ALCchar *devs, *drv_name;
+ GUID guid;
+ UINT n;
+ TRACE("(%p,%p)\n", This, devguid);
+
+ if (!openal_loaded)
+ {
+ ERR("OpenAL not loaded!\n");
+ return DSERR_NODRIVER;
+ }
+
+ if (This->device) {
+ WARN("Already initialized\n");
+ return DSERR_ALREADYINITIALIZED;
+ }
+
+ if (!devguid)
+ devguid = &DSDEVID_DefaultCapture;
+
+ hr = GetDeviceID(devguid, &guid);
+ if (FAILED(hr))
+ return DSERR_INVALIDPARAM;
+ devguid = &guid;
+
+ EnterCriticalSection(&This->crst);
+ EnterCriticalSection(&openal_crst);
+ devs = DSOUND_getcapturedevicestrings();
+ n = guid.Data4[7];
+
+ hr = DSERR_NODRIVER;
+ if (memcmp(devguid, &DSOUND_capture_guid, sizeof(GUID)-1)
+ || !devs || !*devs)
+ {
+ WARN("No driver found\n");
+ goto out;
+ }
+
+ if (n)
+ {
+ const ALCchar *str = devs;
+ while (n--)
+ {
+ str += strlen(str) + 1;
+ if (!*str)
+ {
+ WARN("No driver string found\n");
+ goto out;
+ }
+ }
+ drv_name = str;
+ }
+ else
+ drv_name = devs;
+
+ This->device = HeapAlloc(GetProcessHeap(), 0, strlen(drv_name)+1);
+ if (!This->device)
+ {
+ WARN("Out of memory to allocate %s\n", drv_name);
+ goto out;
+ }
+ strcpy(This->device, drv_name);
+
+ hr = S_OK;
+out:
+ LeaveCriticalSection(&openal_crst);
+ LeaveCriticalSection(&This->crst);
+ return hr;
+}
+
+static const IDirectSoundCaptureVtbl DSC_Vtbl =
+{
+ DSCImpl_QueryInterface,
+ DSCImpl_AddRef,
+ DSCImpl_Release,
+ DSCImpl_CreateCaptureBuffer,
+ DSCImpl_GetCaps,
+ DSCImpl_Initialize
+};
+
+#else
+
HRESULT DSOUND_CaptureCreate8(REFIID riid, IDirectSoundCapture8 **cap)
{
*cap = NULL;
@@ -55,3 +281,5 @@ HRESULT DSOUND_CaptureCreate8(REFIID riid, IDirectSoundCapture8 **cap)
return DSERR_NODRIVER;
}
+#endif
+
--
1.6.5.3
More information about the wine-patches
mailing list