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
24 * Implement DirectSoundFullDuplex support.
29 #define NONAMELESSSTRUCT
30 #define NONAMELESSUNION
39 #include "wine/debug.h"
42 #include "dsound_private.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
46 static HRESULT WINAPI
IDirectSoundFullDuplexImpl_Initialize(
47 LPDIRECTSOUNDFULLDUPLEX iface
,
49 LPCGUID pRendererGuid
,
50 LPCDSCBUFFERDESC lpDscBufferDesc
,
51 LPCDSBUFFERDESC lpDsBufferDesc
,
54 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8
,
55 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8
);
57 static const IDirectSoundFullDuplexVtbl dsfdvt
;
59 /***************************************************************************
60 * DirectSoundFullDuplexCreate [DSOUND.10]
62 * Create and initialize a DirectSoundFullDuplex interface.
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.
78 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
79 * DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER
82 DirectSoundFullDuplexCreate(
83 LPCGUID pcGuidCaptureDevice
,
84 LPCGUID pcGuidRenderDevice
,
85 LPCDSCBUFFERDESC pcDSCBufferDesc
,
86 LPCDSBUFFERDESC pcDSBufferDesc
,
89 LPDIRECTSOUNDFULLDUPLEX
*ppDSFD
,
90 LPDIRECTSOUNDCAPTUREBUFFER8
*ppDSCBuffer8
,
91 LPDIRECTSOUNDBUFFER8
*ppDSBuffer8
,
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
);
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
;
112 IDirectSoundFullDuplexImpl
*This
= (IDirectSoundFullDuplexImpl
*)*ippDSFD
;
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
);
125 WARN("IDirectSoundFullDuplexImpl_Initialize failed\n");
130 static HRESULT WINAPI
131 IDirectSoundFullDuplexImpl_QueryInterface(
132 LPDIRECTSOUNDFULLDUPLEX iface
,
136 IDirectSoundFullDuplexImpl
*This
= (IDirectSoundFullDuplexImpl
*)iface
;
137 TRACE( "(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppobj
);
140 WARN("invalid parameter\n");
145 return E_NOINTERFACE
;
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);
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);
165 This
->lock
.DebugInfo
->Spare
[0] = 0;
166 DeleteCriticalSection( &(This
->lock
) );
167 HeapFree( GetProcessHeap(), 0, This
);
168 TRACE("(%p) released\n", This
);
173 static HRESULT WINAPI
174 IDirectSoundFullDuplexImpl_Initialize(
175 LPDIRECTSOUNDFULLDUPLEX iface
,
176 LPCGUID pCaptureGuid
,
177 LPCGUID pRendererGuid
,
178 LPCDSCBUFFERDESC lpDscBufferDesc
,
179 LPCDSBUFFERDESC lpDsBufferDesc
,
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
,
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
;
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
));
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
);
246 WARN("aggregation not supported\n");
247 return CLASS_E_NOAGGREGATION
;
251 WARN("invalid parameter\n");
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
);
275 static const IClassFactoryVtbl DSFDCF_Vtbl
=
277 DSFDCF_QueryInterface
,
280 DSFDCF_CreateInstance
,
284 IClassFactoryImpl DSOUND_FULLDUPLEX_CF
= { &DSFDCF_Vtbl
, 1 };