Include winuser.h so the code compiles cleanly on windows using
[wine.git] / dlls / dsound / duplex.c
blobfccd72893a4227631c4228a6be4dbc6da087f93d
1 /* DirectSoundFullDuplex
3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2001 TransGaming Technologies, Inc.
6 * Copyright 2005 Robert Reif
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * TODO:
24 * Implement DirectSoundFullDuplex support.
27 #include <stdarg.h>
29 #define NONAMELESSSTRUCT
30 #define NONAMELESSUNION
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "mmsystem.h"
35 #include "mmddk.h"
36 #include "winreg.h"
37 #include "winternl.h"
38 #include "winnls.h"
39 #include "wine/debug.h"
40 #include "dsound.h"
41 #include "dsdriver.h"
42 #include "dsound_private.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
46 static HRESULT WINAPI IDirectSoundFullDuplexImpl_Initialize(
47 LPDIRECTSOUNDFULLDUPLEX iface,
48 LPCGUID pCaptureGuid,
49 LPCGUID pRendererGuid,
50 LPCDSCBUFFERDESC lpDscBufferDesc,
51 LPCDSBUFFERDESC lpDsBufferDesc,
52 HWND hWnd,
53 DWORD dwLevel,
54 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8,
55 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 );
57 static const IDirectSoundFullDuplexVtbl dsfdvt;
59 /***************************************************************************
60 * DirectSoundFullDuplexCreate [DSOUND.10]
62 * Create and initialize a DirectSoundFullDuplex interface.
64 * PARAMS
65 * pcGuidCaptureDevice [I] Address of sound capture device GUID.
66 * pcGuidRenderDevice [I] Address of sound render device GUID.
67 * pcDSCBufferDesc [I] Address of capture buffer description.
68 * pcDSBufferDesc [I] Address of render buffer description.
69 * hWnd [I] Handle to application window.
70 * dwLevel [I] Cooperative level.
71 * ppDSFD [O] Address where full duplex interface returned.
72 * ppDSCBuffer8 [0] Address where capture buffer interface returned.
73 * ppDSBuffer8 [0] Address where render buffer interface returned.
74 * pUnkOuter [I] Must be NULL.
76 * RETURNS
77 * Success: DS_OK
78 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
79 * DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER
81 HRESULT WINAPI
82 DirectSoundFullDuplexCreate(
83 LPCGUID pcGuidCaptureDevice,
84 LPCGUID pcGuidRenderDevice,
85 LPCDSCBUFFERDESC pcDSCBufferDesc,
86 LPCDSBUFFERDESC pcDSBufferDesc,
87 HWND hWnd,
88 DWORD dwLevel,
89 LPDIRECTSOUNDFULLDUPLEX *ppDSFD,
90 LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8,
91 LPDIRECTSOUNDBUFFER8 *ppDSBuffer8,
92 LPUNKNOWN pUnkOuter)
94 IDirectSoundFullDuplexImpl** ippDSFD=(IDirectSoundFullDuplexImpl**)ppDSFD;
95 TRACE("(%s,%s,%p,%p,%p,%lx,%p,%p,%p,%p)\n", debugstr_guid(pcGuidCaptureDevice),
96 debugstr_guid(pcGuidRenderDevice), pcDSCBufferDesc, pcDSBufferDesc,
97 hWnd, dwLevel, ppDSFD, ppDSCBuffer8, ppDSBuffer8, pUnkOuter);
99 if ( pUnkOuter ) {
100 WARN("pUnkOuter != 0\n");
101 return DSERR_NOAGGREGATION;
104 *ippDSFD = HeapAlloc(GetProcessHeap(),
105 HEAP_ZERO_MEMORY, sizeof(IDirectSoundFullDuplexImpl));
107 if (*ippDSFD == NULL) {
108 WARN("out of memory\n");
109 return DSERR_OUTOFMEMORY;
110 } else {
111 HRESULT hres;
112 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)*ippDSFD;
114 This->ref = 1;
115 This->lpVtbl = &dsfdvt;
117 InitializeCriticalSection( &(This->lock) );
118 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)"DSDUPLEX_lock";
120 hres = IDirectSoundFullDuplexImpl_Initialize( (LPDIRECTSOUNDFULLDUPLEX)This,
121 pcGuidCaptureDevice, pcGuidRenderDevice,
122 pcDSCBufferDesc, pcDSBufferDesc,
123 hWnd, dwLevel, ppDSCBuffer8, ppDSBuffer8);
124 if (hres != DS_OK)
125 WARN("IDirectSoundFullDuplexImpl_Initialize failed\n");
126 return hres;
130 static HRESULT WINAPI
131 IDirectSoundFullDuplexImpl_QueryInterface(
132 LPDIRECTSOUNDFULLDUPLEX iface,
133 REFIID riid,
134 LPVOID* ppobj )
136 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
137 TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
139 if (ppobj == NULL) {
140 WARN("invalid parameter\n");
141 return E_INVALIDARG;
144 *ppobj = NULL;
145 return E_NOINTERFACE;
148 static ULONG WINAPI
149 IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface )
151 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
152 ULONG ref = InterlockedIncrement(&(This->ref));
153 TRACE("(%p) ref was %ld\n", This, ref - 1);
154 return ref;
157 static ULONG WINAPI
158 IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
160 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
161 ULONG ref = InterlockedDecrement(&(This->ref));
162 TRACE("(%p) ref was %ld\n", This, ref - 1);
164 if (!ref) {
165 This->lock.DebugInfo->Spare[0] = 0;
166 DeleteCriticalSection( &(This->lock) );
167 HeapFree( GetProcessHeap(), 0, This );
168 TRACE("(%p) released\n", This);
170 return ref;
173 static HRESULT WINAPI
174 IDirectSoundFullDuplexImpl_Initialize(
175 LPDIRECTSOUNDFULLDUPLEX iface,
176 LPCGUID pCaptureGuid,
177 LPCGUID pRendererGuid,
178 LPCDSCBUFFERDESC lpDscBufferDesc,
179 LPCDSBUFFERDESC lpDsBufferDesc,
180 HWND hWnd,
181 DWORD dwLevel,
182 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8,
183 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 )
185 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
186 IDirectSoundCaptureBufferImpl** ippdscb=(IDirectSoundCaptureBufferImpl**)lplpDirectSoundCaptureBuffer8;
187 IDirectSoundBufferImpl** ippdsc=(IDirectSoundBufferImpl**)lplpDirectSoundBuffer8;
189 FIXME( "(%p,%s,%s,%p,%p,%p,%lx,%p,%p) stub!\n", This, debugstr_guid(pCaptureGuid),
190 debugstr_guid(pRendererGuid), lpDscBufferDesc, lpDsBufferDesc, hWnd, dwLevel,
191 ippdscb, ippdsc);
193 return E_FAIL;
196 static const IDirectSoundFullDuplexVtbl dsfdvt =
198 /* IUnknown methods */
199 IDirectSoundFullDuplexImpl_QueryInterface,
200 IDirectSoundFullDuplexImpl_AddRef,
201 IDirectSoundFullDuplexImpl_Release,
203 /* IDirectSoundFullDuplex methods */
204 IDirectSoundFullDuplexImpl_Initialize
207 /*******************************************************************************
208 * DirectSoundFullDuplex ClassFactory
211 static HRESULT WINAPI
212 DSFDCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
214 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
216 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
217 return E_NOINTERFACE;
220 static ULONG WINAPI
221 DSFDCF_AddRef(LPCLASSFACTORY iface)
223 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
224 TRACE("(%p) ref was %ld\n", This, This->ref);
225 return InterlockedIncrement(&(This->ref));
228 static ULONG WINAPI
229 DSFDCF_Release(LPCLASSFACTORY iface)
231 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
232 /* static class, won't be freed */
233 TRACE("(%p) ref was %ld\n", This, This->ref);
234 return InterlockedDecrement(&(This->ref));
237 static HRESULT WINAPI
238 DSFDCF_CreateInstance(
239 LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj )
241 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
243 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
245 if (pOuter) {
246 WARN("aggregation not supported\n");
247 return CLASS_E_NOAGGREGATION;
250 if (ppobj == NULL) {
251 WARN("invalid parameter\n");
252 return E_INVALIDARG;
255 *ppobj = NULL;
257 if ( IsEqualGUID( &IID_IDirectSoundFullDuplex, riid ) ) {
258 /* FIXME: how do we do this one ? */
259 FIXME("not implemented\n");
260 return E_NOINTERFACE;
263 WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
264 return E_NOINTERFACE;
267 static HRESULT WINAPI
268 DSFDCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
270 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
271 FIXME("(%p)->(%d),stub!\n",This,dolock);
272 return S_OK;
275 static const IClassFactoryVtbl DSFDCF_Vtbl =
277 DSFDCF_QueryInterface,
278 DSFDCF_AddRef,
279 DSFDCF_Release,
280 DSFDCF_CreateInstance,
281 DSFDCF_LockServer
284 IClassFactoryImpl DSOUND_FULLDUPLEX_CF = { &DSFDCF_Vtbl, 1 };