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
38 #include "wine/debug.h"
41 #include "dsound_private.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
45 static HRESULT WINAPI
IDirectSoundFullDuplexImpl_Initialize(
46 LPDIRECTSOUNDFULLDUPLEX iface
,
48 LPCGUID pRendererGuid
,
49 LPCDSCBUFFERDESC lpDscBufferDesc
,
50 LPCDSBUFFERDESC lpDsBufferDesc
,
53 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8
,
54 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8
);
56 static const IDirectSoundFullDuplexVtbl dsfdvt
;
58 /***************************************************************************
59 * DirectSoundFullDuplexCreate [DSOUND.10]
61 * Create and initialize a DirectSoundFullDuplex interface.
64 * pcGuidCaptureDevice [I] Address of sound capture device GUID.
65 * pcGuidRenderDevice [I] Address of sound render device GUID.
66 * pcDSCBufferDesc [I] Address of capture buffer description.
67 * pcDSBufferDesc [I] Address of render buffer description.
68 * hWnd [I] Handle to application window.
69 * dwLevel [I] Cooperative level.
70 * ppDSFD [O] Address where full duplex interface returned.
71 * ppDSCBuffer8 [0] Address where capture buffer interface returned.
72 * ppDSBuffer8 [0] Address where render buffer interface returned.
73 * pUnkOuter [I] Must be NULL.
77 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
78 * DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER
81 DirectSoundFullDuplexCreate(
82 LPCGUID pcGuidCaptureDevice
,
83 LPCGUID pcGuidRenderDevice
,
84 LPCDSCBUFFERDESC pcDSCBufferDesc
,
85 LPCDSBUFFERDESC pcDSBufferDesc
,
88 LPDIRECTSOUNDFULLDUPLEX
*ppDSFD
,
89 LPDIRECTSOUNDCAPTUREBUFFER8
*ppDSCBuffer8
,
90 LPDIRECTSOUNDBUFFER8
*ppDSBuffer8
,
93 IDirectSoundFullDuplexImpl
** ippDSFD
=(IDirectSoundFullDuplexImpl
**)ppDSFD
;
94 TRACE("(%s,%s,%p,%p,%p,%lx,%p,%p,%p,%p)\n", debugstr_guid(pcGuidCaptureDevice
),
95 debugstr_guid(pcGuidRenderDevice
), pcDSCBufferDesc
, pcDSBufferDesc
,
96 hWnd
, dwLevel
, ppDSFD
, ppDSCBuffer8
, ppDSBuffer8
, pUnkOuter
);
99 WARN("pUnkOuter != 0\n");
100 return DSERR_NOAGGREGATION
;
103 *ippDSFD
= HeapAlloc(GetProcessHeap(),
104 HEAP_ZERO_MEMORY
, sizeof(IDirectSoundFullDuplexImpl
));
106 if (*ippDSFD
== NULL
) {
107 WARN("out of memory\n");
108 return DSERR_OUTOFMEMORY
;
111 IDirectSoundFullDuplexImpl
*This
= (IDirectSoundFullDuplexImpl
*)*ippDSFD
;
114 This
->lpVtbl
= &dsfdvt
;
116 InitializeCriticalSection( &(This
->lock
) );
117 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)"DSDUPLEX_lock";
119 hres
= IDirectSoundFullDuplexImpl_Initialize( (LPDIRECTSOUNDFULLDUPLEX
)This
,
120 pcGuidCaptureDevice
, pcGuidRenderDevice
,
121 pcDSCBufferDesc
, pcDSBufferDesc
,
122 hWnd
, dwLevel
, ppDSCBuffer8
, ppDSBuffer8
);
124 WARN("IDirectSoundFullDuplexImpl_Initialize failed\n");
129 static HRESULT WINAPI
130 IDirectSoundFullDuplexImpl_QueryInterface(
131 LPDIRECTSOUNDFULLDUPLEX iface
,
135 IDirectSoundFullDuplexImpl
*This
= (IDirectSoundFullDuplexImpl
*)iface
;
136 TRACE( "(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppobj
);
139 WARN("invalid parameter\n");
144 return E_NOINTERFACE
;
148 IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface
)
150 IDirectSoundFullDuplexImpl
*This
= (IDirectSoundFullDuplexImpl
*)iface
;
151 ULONG ref
= InterlockedIncrement(&(This
->ref
));
152 TRACE("(%p) ref was %ld\n", This
, ref
- 1);
157 IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface
)
159 IDirectSoundFullDuplexImpl
*This
= (IDirectSoundFullDuplexImpl
*)iface
;
160 ULONG ref
= InterlockedDecrement(&(This
->ref
));
161 TRACE("(%p) ref was %ld\n", This
, ref
- 1);
164 This
->lock
.DebugInfo
->Spare
[0] = 0;
165 DeleteCriticalSection( &(This
->lock
) );
166 HeapFree( GetProcessHeap(), 0, This
);
167 TRACE("(%p) released\n", This
);
172 static HRESULT WINAPI
173 IDirectSoundFullDuplexImpl_Initialize(
174 LPDIRECTSOUNDFULLDUPLEX iface
,
175 LPCGUID pCaptureGuid
,
176 LPCGUID pRendererGuid
,
177 LPCDSCBUFFERDESC lpDscBufferDesc
,
178 LPCDSBUFFERDESC lpDsBufferDesc
,
181 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8
,
182 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8
)
184 IDirectSoundFullDuplexImpl
*This
= (IDirectSoundFullDuplexImpl
*)iface
;
185 IDirectSoundCaptureBufferImpl
** ippdscb
=(IDirectSoundCaptureBufferImpl
**)lplpDirectSoundCaptureBuffer8
;
186 IDirectSoundBufferImpl
** ippdsc
=(IDirectSoundBufferImpl
**)lplpDirectSoundBuffer8
;
188 FIXME( "(%p,%s,%s,%p,%p,%p,%lx,%p,%p) stub!\n", This
, debugstr_guid(pCaptureGuid
),
189 debugstr_guid(pRendererGuid
), lpDscBufferDesc
, lpDsBufferDesc
, hWnd
, dwLevel
,
195 static const IDirectSoundFullDuplexVtbl dsfdvt
=
197 /* IUnknown methods */
198 IDirectSoundFullDuplexImpl_QueryInterface
,
199 IDirectSoundFullDuplexImpl_AddRef
,
200 IDirectSoundFullDuplexImpl_Release
,
202 /* IDirectSoundFullDuplex methods */
203 IDirectSoundFullDuplexImpl_Initialize
206 /*******************************************************************************
207 * DirectSoundFullDuplex ClassFactory
210 static HRESULT WINAPI
211 DSFDCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
213 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
215 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
216 return E_NOINTERFACE
;
220 DSFDCF_AddRef(LPCLASSFACTORY iface
)
222 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
223 TRACE("(%p) ref was %ld\n", This
, This
->ref
);
224 return InterlockedIncrement(&(This
->ref
));
228 DSFDCF_Release(LPCLASSFACTORY iface
)
230 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
231 /* static class, won't be freed */
232 TRACE("(%p) ref was %ld\n", This
, This
->ref
);
233 return InterlockedDecrement(&(This
->ref
));
236 static HRESULT WINAPI
237 DSFDCF_CreateInstance(
238 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
)
240 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
242 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
245 WARN("aggregation not supported\n");
246 return CLASS_E_NOAGGREGATION
;
250 WARN("invalid parameter\n");
256 if ( IsEqualGUID( &IID_IDirectSoundFullDuplex
, riid
) ) {
257 /* FIXME: how do we do this one ? */
258 FIXME("not implemented\n");
259 return E_NOINTERFACE
;
262 WARN("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
263 return E_NOINTERFACE
;
266 static HRESULT WINAPI
267 DSFDCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
269 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
270 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
274 static const IClassFactoryVtbl DSFDCF_Vtbl
=
276 DSFDCF_QueryInterface
,
279 DSFDCF_CreateInstance
,
283 IClassFactoryImpl DSOUND_FULLDUPLEX_CF
= { &DSFDCF_Vtbl
, 1 };