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
25 #define NONAMELESSSTRUCT
26 #define NONAMELESSUNION
35 #include "wine/debug.h"
38 #include "dsound_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
42 /*******************************************************************************
45 static HRESULT WINAPI IDirectSoundFullDuplex_IUnknown_QueryInterface(
50 IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
51 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
52 return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
55 static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_AddRef(
58 IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
59 ULONG ref = InterlockedIncrement(&(This->ref));
60 TRACE("(%p) ref was %ld\n", This, ref - 1);
64 static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_Release(
67 IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
68 ULONG ref = InterlockedDecrement(&(This->ref));
69 TRACE("(%p) ref was %ld\n", This, ref + 1);
71 IDirectSound_Release(This->pdsfd->pUnknown);
72 HeapFree(GetProcessHeap(), 0, This);
73 TRACE("(%p) released\n", This);
78 static const IUnknownVtbl DirectSoundFullDuplex_Unknown_Vtbl =
80 IDirectSoundFullDuplex_IUnknown_QueryInterface,
81 IDirectSoundFullDuplex_IUnknown_AddRef,
82 IDirectSoundFullDuplex_IUnknown_Release
85 HRESULT IDirectSoundFullDuplex_IUnknown_Create(
86 LPDIRECTSOUNDFULLDUPLEX pdsfd,
89 IDirectSoundFullDuplex_IUnknown * pdsfdunk;
90 TRACE("(%p,%p)\n",pdsfd,ppunk);
93 ERR("invalid parameter: pdsfd == NULL\n");
94 return DSERR_INVALIDPARAM;
98 ERR("invalid parameter: ppunk == NULL\n");
99 return DSERR_INVALIDPARAM;
102 pdsfdunk = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdunk));
103 if (pdsfdunk == NULL) {
104 WARN("out of memory\n");
106 return DSERR_OUTOFMEMORY;
109 pdsfdunk->lpVtbl = &DirectSoundFullDuplex_Unknown_Vtbl;
111 pdsfdunk->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
113 *ppunk = (LPUNKNOWN)pdsfdunk;
118 /*******************************************************************************
119 * IDirectSoundFullDuplex_IDirectSound
121 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_QueryInterface(
126 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
127 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
128 return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
131 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound_AddRef(
134 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
135 ULONG ref = InterlockedIncrement(&(This->ref));
136 TRACE("(%p) ref was %ld\n", This, ref - 1);
140 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound_Release(
143 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
144 ULONG ref = InterlockedDecrement(&(This->ref));
145 TRACE("(%p) ref was %ld\n", This, ref + 1);
147 IDirectSound_Release(This->pdsfd->pDS);
148 HeapFree(GetProcessHeap(), 0, This);
149 TRACE("(%p) released\n", This);
154 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_CreateSoundBuffer(
156 LPCDSBUFFERDESC dsbd,
157 LPLPDIRECTSOUNDBUFFER ppdsb,
160 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
161 TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
162 return DirectSoundDevice_CreateSoundBuffer(This->pdsfd->renderer_device,dsbd,ppdsb,lpunk,FALSE);
165 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetCaps(
169 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
170 TRACE("(%p,%p)\n",This,lpDSCaps);
171 return DirectSoundDevice_GetCaps(This->pdsfd->renderer_device, lpDSCaps);
174 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_DuplicateSoundBuffer(
176 LPDIRECTSOUNDBUFFER psb,
177 LPLPDIRECTSOUNDBUFFER ppdsb)
179 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
180 TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
181 return DirectSoundDevice_DuplicateSoundBuffer(This->pdsfd->renderer_device,psb,ppdsb);
184 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetCooperativeLevel(
189 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
190 TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
191 return DirectSoundDevice_SetCooperativeLevel(This->pdsfd->renderer_device,hwnd,level);
194 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Compact(
197 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
198 TRACE("(%p)\n", This);
199 return DirectSoundDevice_Compact(This->pdsfd->renderer_device);
202 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetSpeakerConfig(
204 LPDWORD lpdwSpeakerConfig)
206 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
207 TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
208 return DirectSoundDevice_GetSpeakerConfig(This->pdsfd->renderer_device,lpdwSpeakerConfig);
211 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetSpeakerConfig(
215 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
216 TRACE("(%p,0x%08lx)\n",This,config);
217 return DirectSoundDevice_SetSpeakerConfig(This->pdsfd->renderer_device,config);
220 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Initialize(
224 IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
225 TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
226 return DirectSoundDevice_Initialize(&This->pdsfd->renderer_device,lpcGuid);
229 static const IDirectSoundVtbl DirectSoundFullDuplex_DirectSound_Vtbl =
231 IDirectSoundFullDuplex_IDirectSound_QueryInterface,
232 IDirectSoundFullDuplex_IDirectSound_AddRef,
233 IDirectSoundFullDuplex_IDirectSound_Release,
234 IDirectSoundFullDuplex_IDirectSound_CreateSoundBuffer,
235 IDirectSoundFullDuplex_IDirectSound_GetCaps,
236 IDirectSoundFullDuplex_IDirectSound_DuplicateSoundBuffer,
237 IDirectSoundFullDuplex_IDirectSound_SetCooperativeLevel,
238 IDirectSoundFullDuplex_IDirectSound_Compact,
239 IDirectSoundFullDuplex_IDirectSound_GetSpeakerConfig,
240 IDirectSoundFullDuplex_IDirectSound_SetSpeakerConfig,
241 IDirectSoundFullDuplex_IDirectSound_Initialize
244 HRESULT IDirectSoundFullDuplex_IDirectSound_Create(
245 LPDIRECTSOUNDFULLDUPLEX pdsfd,
246 LPDIRECTSOUND * ppds)
248 IDirectSoundFullDuplex_IDirectSound * pdsfdds;
249 TRACE("(%p,%p)\n",pdsfd,ppds);
252 ERR("invalid parameter: pdsfd == NULL\n");
253 return DSERR_INVALIDPARAM;
257 ERR("invalid parameter: ppds == NULL\n");
258 return DSERR_INVALIDPARAM;
261 pdsfdds = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdds));
262 if (pdsfdds == NULL) {
263 WARN("out of memory\n");
265 return DSERR_OUTOFMEMORY;
268 pdsfdds->lpVtbl = &DirectSoundFullDuplex_DirectSound_Vtbl;
270 pdsfdds->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
272 *ppds = (LPDIRECTSOUND)pdsfdds;
277 /*******************************************************************************
278 * IDirectSoundFullDuplex_IDirectSound8
280 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_QueryInterface(
281 LPDIRECTSOUND8 iface,
285 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
286 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
287 return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
290 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_AddRef(
291 LPDIRECTSOUND8 iface)
293 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
294 ULONG ref = InterlockedIncrement(&(This->ref));
295 TRACE("(%p) ref was %ld\n", This, ref - 1);
299 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_Release(
300 LPDIRECTSOUND8 iface)
302 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
303 ULONG ref = InterlockedDecrement(&(This->ref));
304 TRACE("(%p) ref was %ld\n", This, ref + 1);
306 IDirectSound_Release(This->pdsfd->pDS8);
307 HeapFree(GetProcessHeap(), 0, This);
308 TRACE("(%p) released\n", This);
313 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_CreateSoundBuffer(
314 LPDIRECTSOUND8 iface,
315 LPCDSBUFFERDESC dsbd,
316 LPLPDIRECTSOUNDBUFFER ppdsb,
319 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
320 TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
321 return DirectSoundDevice_CreateSoundBuffer(This->pdsfd->renderer_device,dsbd,ppdsb,lpunk,TRUE);
324 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetCaps(
325 LPDIRECTSOUND8 iface,
328 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
329 TRACE("(%p,%p)\n",This,lpDSCaps);
330 return DirectSoundDevice_GetCaps(This->pdsfd->renderer_device, lpDSCaps);
333 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_DuplicateSoundBuffer(
334 LPDIRECTSOUND8 iface,
335 LPDIRECTSOUNDBUFFER psb,
336 LPLPDIRECTSOUNDBUFFER ppdsb)
338 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
339 TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
340 return DirectSoundDevice_DuplicateSoundBuffer(This->pdsfd->renderer_device,psb,ppdsb);
343 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel(
344 LPDIRECTSOUND8 iface,
348 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
349 TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
350 return DirectSoundDevice_SetCooperativeLevel(This->pdsfd->renderer_device,hwnd,level);
353 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Compact(
354 LPDIRECTSOUND8 iface)
356 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
357 TRACE("(%p)\n", This);
358 return DirectSoundDevice_Compact(This->pdsfd->renderer_device);
361 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetSpeakerConfig(
362 LPDIRECTSOUND8 iface,
363 LPDWORD lpdwSpeakerConfig)
365 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
366 TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
367 return DirectSoundDevice_GetSpeakerConfig(This->pdsfd->renderer_device,lpdwSpeakerConfig);
370 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetSpeakerConfig(
371 LPDIRECTSOUND8 iface,
374 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
375 TRACE("(%p,0x%08lx)\n",This,config);
376 return DirectSoundDevice_SetSpeakerConfig(This->pdsfd->renderer_device,config);
379 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Initialize(
380 LPDIRECTSOUND8 iface,
383 IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
384 TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
385 return DirectSoundDevice_Initialize(&This->pdsfd->renderer_device,lpcGuid);
388 static const IDirectSound8Vtbl DirectSoundFullDuplex_DirectSound8_Vtbl =
390 IDirectSoundFullDuplex_IDirectSound8_QueryInterface,
391 IDirectSoundFullDuplex_IDirectSound8_AddRef,
392 IDirectSoundFullDuplex_IDirectSound8_Release,
393 IDirectSoundFullDuplex_IDirectSound8_CreateSoundBuffer,
394 IDirectSoundFullDuplex_IDirectSound8_GetCaps,
395 IDirectSoundFullDuplex_IDirectSound8_DuplicateSoundBuffer,
396 IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel,
397 IDirectSoundFullDuplex_IDirectSound8_Compact,
398 IDirectSoundFullDuplex_IDirectSound8_GetSpeakerConfig,
399 IDirectSoundFullDuplex_IDirectSound8_SetSpeakerConfig,
400 IDirectSoundFullDuplex_IDirectSound8_Initialize
403 HRESULT IDirectSoundFullDuplex_IDirectSound8_Create(
404 LPDIRECTSOUNDFULLDUPLEX pdsfd,
405 LPDIRECTSOUND8 * ppds8)
407 IDirectSoundFullDuplex_IDirectSound8 * pdsfdds8;
408 TRACE("(%p,%p)\n",pdsfd,ppds8);
411 ERR("invalid parameter: pdsfd == NULL\n");
412 return DSERR_INVALIDPARAM;
416 ERR("invalid parameter: ppds8 == NULL\n");
417 return DSERR_INVALIDPARAM;
420 pdsfdds8 = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdds8));
421 if (pdsfdds8 == NULL) {
422 WARN("out of memory\n");
424 return DSERR_OUTOFMEMORY;
427 pdsfdds8->lpVtbl = &DirectSoundFullDuplex_DirectSound8_Vtbl;
429 pdsfdds8->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
431 *ppds8 = (LPDIRECTSOUND8)pdsfdds8;
436 /*******************************************************************************
437 * IDirectSoundFullDuplex_IDirectSoundCapture
439 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface(
440 LPDIRECTSOUNDCAPTURE iface,
444 IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
445 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
446 return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
449 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(
450 LPDIRECTSOUNDCAPTURE iface)
452 IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
453 ULONG ref = InterlockedIncrement(&(This->ref));
454 TRACE("(%p) ref was %ld\n", This, ref - 1);
458 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_Release(
459 LPDIRECTSOUNDCAPTURE iface)
461 IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
462 ULONG ref = InterlockedDecrement(&(This->ref));
463 TRACE("(%p) ref was %ld\n", This, ref + 1);
465 IDirectSoundCapture_Release(This->pdsfd->pDSC);
466 HeapFree(GetProcessHeap(), 0, This);
467 TRACE("(%p) released\n", This);
472 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_CreateCaptureBuffer(
473 LPDIRECTSOUNDCAPTURE iface,
474 LPCDSCBUFFERDESC lpcDSCBufferDesc,
475 LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
478 IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
479 TRACE("(%p,%p,%p,%p)\n",This,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
480 return IDirectSoundCaptureImpl_CreateCaptureBuffer(This->pdsfd->pDSC,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
483 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_GetCaps(
484 LPDIRECTSOUNDCAPTURE iface,
487 IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
488 TRACE("(%p,%p)\n",This,lpDSCCaps);
489 return IDirectSoundCaptureImpl_GetCaps(This->pdsfd->pDSC, lpDSCCaps);
492 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_Initialize(
493 LPDIRECTSOUNDCAPTURE iface,
496 IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
497 TRACE("(%p, %s)\n", This, debugstr_guid(lpcGUID));
498 return IDirectSoundCaptureImpl_Initialize(This->pdsfd->pDSC,lpcGUID);
501 static const IDirectSoundCaptureVtbl DirectSoundFullDuplex_DirectSoundCapture_Vtbl =
503 IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface,
504 IDirectSoundFullDuplex_IDirectSoundCapture_AddRef,
505 IDirectSoundFullDuplex_IDirectSoundCapture_Release,
506 IDirectSoundFullDuplex_IDirectSoundCapture_CreateCaptureBuffer,
507 IDirectSoundFullDuplex_IDirectSoundCapture_GetCaps,
508 IDirectSoundFullDuplex_IDirectSoundCapture_Initialize
511 HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create(
512 LPDIRECTSOUNDFULLDUPLEX pdsfd,
513 LPDIRECTSOUNDCAPTURE8 * ppdsc8)
515 IDirectSoundFullDuplex_IDirectSoundCapture * pdsfddsc;
516 TRACE("(%p,%p)\n",pdsfd,ppdsc8);
519 ERR("invalid parameter: pdsfd == NULL\n");
520 return DSERR_INVALIDPARAM;
523 if (ppdsc8 == NULL) {
524 ERR("invalid parameter: ppdsc8 == NULL\n");
525 return DSERR_INVALIDPARAM;
528 pdsfddsc = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfddsc));
529 if (pdsfddsc == NULL) {
530 WARN("out of memory\n");
532 return DSERR_OUTOFMEMORY;
535 pdsfddsc->lpVtbl = &DirectSoundFullDuplex_DirectSoundCapture_Vtbl;
537 pdsfddsc->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
539 *ppdsc8 = (LPDIRECTSOUNDCAPTURE)pdsfddsc;
544 /***************************************************************************
545 * IDirectSoundFullDuplexImpl
548 IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface )
550 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
551 ULONG ref = InterlockedIncrement(&(This->ref));
552 TRACE("(%p) ref was %ld\n", This, ref - 1);
556 static HRESULT WINAPI
557 IDirectSoundFullDuplexImpl_QueryInterface(
558 LPDIRECTSOUNDFULLDUPLEX iface,
562 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
563 TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
566 WARN("invalid parameter\n");
572 if (IsEqualIID(riid, &IID_IUnknown)) {
573 if (!This->pUnknown) {
574 IDirectSoundFullDuplex_IUnknown_Create(iface, &This->pUnknown);
575 if (!This->pUnknown) {
576 WARN("IDirectSoundFullDuplex_IUnknown_Create() failed\n");
578 return E_NOINTERFACE;
581 IDirectSoundFullDuplex_IUnknown_AddRef(This->pUnknown);
582 *ppobj = This->pUnknown;
584 } else if (IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) {
585 IDirectSoundFullDuplexImpl_AddRef(iface);
588 } else if (IsEqualIID(riid, &IID_IDirectSound)) {
590 IDirectSoundFullDuplex_IDirectSound_Create(iface, &This->pDS);
592 WARN("IDirectSoundFullDuplex_IDirectSound_Create() failed\n");
594 return E_NOINTERFACE;
597 IDirectSoundFullDuplex_IDirectSound_AddRef(This->pDS);
600 } else if (IsEqualIID(riid, &IID_IDirectSound8)) {
602 IDirectSoundFullDuplex_IDirectSound8_Create(iface, &This->pDS8);
604 WARN("IDirectSoundFullDuplex_IDirectSound8_Create() failed\n");
606 return E_NOINTERFACE;
609 IDirectSoundFullDuplex_IDirectSound8_AddRef(This->pDS8);
612 } else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) {
614 IDirectSoundFullDuplex_IDirectSoundCapture_Create(iface, &This->pDSC);
616 WARN("IDirectSoundFullDuplex_IDirectSoundCapture_Create() failed\n");
618 return E_NOINTERFACE;
621 IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(This->pDSC);
626 return E_NOINTERFACE;
630 IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
632 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
633 ULONG ref = InterlockedDecrement(&(This->ref));
634 TRACE("(%p) ref was %ld\n", This, ref - 1);
637 if (This->capture_device)
638 DirectSoundCaptureDevice_Release(This->capture_device);
639 if (This->renderer_device)
640 DirectSoundDevice_Release(This->renderer_device);
641 HeapFree( GetProcessHeap(), 0, This );
642 TRACE("(%p) released\n", This);
647 static HRESULT WINAPI
648 IDirectSoundFullDuplexImpl_Initialize(
649 LPDIRECTSOUNDFULLDUPLEX iface,
650 LPCGUID pCaptureGuid,
651 LPCGUID pRendererGuid,
652 LPCDSCBUFFERDESC lpDscBufferDesc,
653 LPCDSBUFFERDESC lpDsBufferDesc,
656 LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8,
657 LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 )
660 IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
661 IDirectSoundBufferImpl * dsb;
663 TRACE("(%p,%s,%s,%p,%p,%lx,%lx,%p,%p)\n", This,
664 debugstr_guid(pCaptureGuid), debugstr_guid(pRendererGuid),
665 lpDscBufferDesc, lpDsBufferDesc, (DWORD)hWnd, dwLevel,
666 lplpDirectSoundCaptureBuffer8, lplpDirectSoundBuffer8);
668 if (This->renderer_device != NULL || This->capture_device != NULL) {
669 WARN("already initialized\n");
670 *lplpDirectSoundCaptureBuffer8 = NULL;
671 *lplpDirectSoundBuffer8 = NULL;
672 return DSERR_ALREADYINITIALIZED;
675 hr = DirectSoundDevice_Initialize(&This->renderer_device, pRendererGuid);
677 WARN("DirectSoundDevice_Initialize() failed\n");
678 *lplpDirectSoundCaptureBuffer8 = NULL;
679 *lplpDirectSoundBuffer8 = NULL;
683 if (dwLevel==DSSCL_PRIORITY || dwLevel==DSSCL_EXCLUSIVE) {
684 WARN("level=%s not fully supported\n",
685 dwLevel==DSSCL_PRIORITY ? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
687 This->renderer_device->priolevel = dwLevel;
689 hr = DSOUND_PrimarySetFormat(This->renderer_device, lpDsBufferDesc->lpwfxFormat);
691 WARN("DSOUND_PrimarySetFormat() failed\n");
692 *lplpDirectSoundCaptureBuffer8 = NULL;
693 *lplpDirectSoundBuffer8 = NULL;
696 hr = IDirectSoundBufferImpl_Create(This->renderer_device, &dsb, lpDsBufferDesc);
698 WARN("IDirectSoundBufferImpl_Create() failed\n");
699 *lplpDirectSoundCaptureBuffer8 = NULL;
700 *lplpDirectSoundBuffer8 = NULL;
704 hr = SecondaryBufferImpl_Create(dsb, (SecondaryBufferImpl **)lplpDirectSoundBuffer8);
706 WARN("SecondaryBufferImpl_Create() failed\n");
707 *lplpDirectSoundCaptureBuffer8 = NULL;
708 *lplpDirectSoundBuffer8 = NULL;
711 IDirectSoundBuffer8_AddRef(*lplpDirectSoundBuffer8);
713 hr = DirectSoundCaptureDevice_Initialize(&This->capture_device, pCaptureGuid);
715 WARN("DirectSoundCaptureDevice_Initialize() failed\n");
716 *lplpDirectSoundCaptureBuffer8 = NULL;
717 *lplpDirectSoundBuffer8 = NULL;
721 hr = IDirectSoundCaptureBufferImpl_Create(This->capture_device,
722 (IDirectSoundCaptureBufferImpl **)lplpDirectSoundCaptureBuffer8,
725 WARN("IDirectSoundCaptureBufferImpl_Create() failed\n");
726 *lplpDirectSoundCaptureBuffer8 = NULL;
727 *lplpDirectSoundBuffer8 = NULL;
734 static const IDirectSoundFullDuplexVtbl dsfdvt =
736 /* IUnknown methods */
737 IDirectSoundFullDuplexImpl_QueryInterface,
738 IDirectSoundFullDuplexImpl_AddRef,
739 IDirectSoundFullDuplexImpl_Release,
741 /* IDirectSoundFullDuplex methods */
742 IDirectSoundFullDuplexImpl_Initialize
745 HRESULT DSOUND_FullDuplexCreate(LPDIRECTSOUNDFULLDUPLEX* ppDSFD, IUnknown *pUnkOuter)
747 IDirectSoundFullDuplexImpl *This = NULL;
750 WARN("pUnkOuter != 0\n");
752 return DSERR_NOAGGREGATION;
755 if (ppDSFD == NULL) {
756 WARN("invalid parameter: ppDSFD == NULL\n");
757 return DSERR_INVALIDPARAM;
760 /* Get dsound configuration */
761 setup_dsound_options();
763 This = HeapAlloc(GetProcessHeap(),
764 HEAP_ZERO_MEMORY, sizeof(IDirectSoundFullDuplexImpl));
767 WARN("out of memory\n");
769 return DSERR_OUTOFMEMORY;
772 This->lpVtbl = &dsfdvt;
774 This->capture_device = NULL;
775 This->renderer_device = NULL;
780 /***************************************************************************
781 * DirectSoundFullDuplexCreate [DSOUND.10]
783 * Create and initialize a DirectSoundFullDuplex interface.
786 * pcGuidCaptureDevice [I] Address of sound capture device GUID.
787 * pcGuidRenderDevice [I] Address of sound render device GUID.
788 * pcDSCBufferDesc [I] Address of capture buffer description.
789 * pcDSBufferDesc [I] Address of render buffer description.
790 * hWnd [I] Handle to application window.
791 * dwLevel [I] Cooperative level.
792 * ppDSFD [O] Address where full duplex interface returned.
793 * ppDSCBuffer8 [0] Address where capture buffer interface returned.
794 * ppDSBuffer8 [0] Address where render buffer interface returned.
795 * pUnkOuter [I] Must be NULL.
799 * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
800 * DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER
803 DirectSoundFullDuplexCreate(
804 LPCGUID pcGuidCaptureDevice,
805 LPCGUID pcGuidRenderDevice,
806 LPCDSCBUFFERDESC pcDSCBufferDesc,
807 LPCDSBUFFERDESC pcDSBufferDesc,
810 LPDIRECTSOUNDFULLDUPLEX *ppDSFD,
811 LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8,
812 LPDIRECTSOUNDBUFFER8 *ppDSBuffer8,
816 IDirectSoundFullDuplexImpl *This = NULL;
817 TRACE("(%s,%s,%p,%p,%p,%lx,%p,%p,%p,%p)\n",
818 debugstr_guid(pcGuidCaptureDevice), debugstr_guid(pcGuidRenderDevice),
819 pcDSCBufferDesc, pcDSBufferDesc, hWnd, dwLevel, ppDSFD, ppDSCBuffer8,
820 ppDSBuffer8, pUnkOuter);
823 WARN("pUnkOuter != 0\n");
825 return DSERR_NOAGGREGATION;
828 if (pcDSCBufferDesc == NULL) {
829 WARN("invalid parameter: pcDSCBufferDesc == NULL\n");
831 return DSERR_INVALIDPARAM;
834 if (pcDSBufferDesc == NULL) {
835 WARN("invalid parameter: pcDSBufferDesc == NULL\n");
837 return DSERR_INVALIDPARAM;
840 if (ppDSFD == NULL) {
841 WARN("invalid parameter: ppDSFD == NULL\n");
842 return DSERR_INVALIDPARAM;
845 if (ppDSCBuffer8 == NULL) {
846 WARN("invalid parameter: ppDSCBuffer8 == NULL\n");
848 return DSERR_INVALIDPARAM;
851 if (ppDSBuffer8 == NULL) {
852 WARN("invalid parameter: ppDSBuffer8 == NULL\n");
854 return DSERR_INVALIDPARAM;
857 /* Get dsound configuration */
858 setup_dsound_options();
860 This = HeapAlloc(GetProcessHeap(),
861 HEAP_ZERO_MEMORY, sizeof(IDirectSoundFullDuplexImpl));
864 WARN("out of memory\n");
866 return DSERR_OUTOFMEMORY;
869 This->lpVtbl = &dsfdvt;
871 This->capture_device = NULL;
872 This->renderer_device = NULL;
874 hres = IDirectSoundFullDuplexImpl_Initialize((LPDIRECTSOUNDFULLDUPLEX)This,
879 hWnd, dwLevel, ppDSCBuffer8,
882 HeapFree(GetProcessHeap(), 0, This);
883 WARN("IDirectSoundFullDuplexImpl_Initialize failed\n");
886 *ppDSFD = (LPDIRECTSOUNDFULLDUPLEX)This;
891 /*******************************************************************************
892 * DirectSoundFullDuplex ClassFactory
895 static HRESULT WINAPI
896 DSFDCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
898 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
900 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
901 return E_NOINTERFACE;
905 DSFDCF_AddRef(LPCLASSFACTORY iface)
907 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
908 TRACE("(%p) ref was %ld\n", This, This->ref);
909 return InterlockedIncrement(&(This->ref));
913 DSFDCF_Release(LPCLASSFACTORY iface)
915 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
916 /* static class, won't be freed */
917 TRACE("(%p) ref was %ld\n", This, This->ref);
918 return InterlockedDecrement(&(This->ref));
921 static HRESULT WINAPI
922 DSFDCF_CreateInstance(
923 LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj )
925 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
927 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
930 WARN("aggregation not supported\n");
931 return CLASS_E_NOAGGREGATION;
935 WARN("invalid parameter\n");
941 if ( IsEqualGUID( &IID_IDirectSoundFullDuplex, riid ) )
942 return DSOUND_FullDuplexCreate((LPDIRECTSOUNDFULLDUPLEX*)ppobj,pOuter);
944 WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
945 return E_NOINTERFACE;
948 static HRESULT WINAPI
949 DSFDCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
951 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
952 FIXME("(%p)->(%d),stub!\n",This,dolock);
956 static const IClassFactoryVtbl DSFDCF_Vtbl =
958 DSFDCF_QueryInterface,
961 DSFDCF_CreateInstance,
965 IClassFactoryImpl DSOUND_FULLDUPLEX_CF = { &DSFDCF_Vtbl, 1 };