ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

duplex.c
Go to the documentation of this file.
00001 /*              DirectSoundFullDuplex
00002  *
00003  * Copyright 1998 Marcus Meissner
00004  * Copyright 1998 Rob Riggs
00005  * Copyright 2000-2001 TransGaming Technologies, Inc.
00006  * Copyright 2005 Robert Reif
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00021  */
00022 
00023 #include <stdarg.h>
00024 
00025 #define NONAMELESSSTRUCT
00026 #define NONAMELESSUNION
00027 #include "windef.h"
00028 #include "winbase.h"
00029 #include "winuser.h"
00030 #include "mmsystem.h"
00031 #include "mmddk.h"
00032 #include "winternl.h"
00033 #include "wine/debug.h"
00034 #include "dsound.h"
00035 #include "dsdriver.h"
00036 #include "dsound_private.h"
00037 
00038 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
00039 
00040 /*******************************************************************************
00041  * IUnknown
00042  */
00043 static HRESULT WINAPI IDirectSoundFullDuplex_IUnknown_QueryInterface(
00044     LPUNKNOWN iface,
00045     REFIID riid,
00046     LPVOID * ppobj)
00047 {
00048     IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
00049     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
00050     return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
00051 }
00052 
00053 static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_AddRef(
00054     LPUNKNOWN iface)
00055 {
00056     IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
00057     ULONG ref = InterlockedIncrement(&(This->ref));
00058     TRACE("(%p) ref was %d\n", This, ref - 1);
00059     return ref;
00060 }
00061 
00062 static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_Release(
00063     LPUNKNOWN iface)
00064 {
00065     IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
00066     ULONG ref = InterlockedDecrement(&(This->ref));
00067     TRACE("(%p) ref was %d\n", This, ref + 1);
00068     if (!ref) {
00069         IDirectSound_Release(This->pdsfd->pUnknown);
00070         HeapFree(GetProcessHeap(), 0, This);
00071         TRACE("(%p) released\n", This);
00072     }
00073     return ref;
00074 }
00075 
00076 static const IUnknownVtbl DirectSoundFullDuplex_Unknown_Vtbl =
00077 {
00078     IDirectSoundFullDuplex_IUnknown_QueryInterface,
00079     IDirectSoundFullDuplex_IUnknown_AddRef,
00080     IDirectSoundFullDuplex_IUnknown_Release
00081 };
00082 
00083 static HRESULT IDirectSoundFullDuplex_IUnknown_Create(
00084     LPDIRECTSOUNDFULLDUPLEX pdsfd,
00085     LPUNKNOWN * ppunk)
00086 {
00087     IDirectSoundFullDuplex_IUnknown * pdsfdunk;
00088     TRACE("(%p,%p)\n",pdsfd,ppunk);
00089 
00090     if (pdsfd == NULL) {
00091         ERR("invalid parameter: pdsfd == NULL\n");
00092         return DSERR_INVALIDPARAM;
00093     }
00094 
00095     if (ppunk == NULL) {
00096         ERR("invalid parameter: ppunk == NULL\n");
00097         return DSERR_INVALIDPARAM;
00098     }
00099 
00100     pdsfdunk = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdunk));
00101     if (pdsfdunk == NULL) {
00102         WARN("out of memory\n");
00103         *ppunk = NULL;
00104         return DSERR_OUTOFMEMORY;
00105     }
00106 
00107     pdsfdunk->lpVtbl = &DirectSoundFullDuplex_Unknown_Vtbl;
00108     pdsfdunk->ref = 0;
00109     pdsfdunk->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
00110 
00111     *ppunk = (LPUNKNOWN)pdsfdunk;
00112 
00113     return DS_OK;
00114 }
00115 
00116 /*******************************************************************************
00117  * IDirectSoundFullDuplex_IDirectSound
00118  */
00119 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_QueryInterface(
00120     LPDIRECTSOUND iface,
00121     REFIID riid,
00122     LPVOID * ppobj)
00123 {
00124     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00125     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
00126     return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
00127 }
00128 
00129 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound_AddRef(
00130     LPDIRECTSOUND iface)
00131 {
00132     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00133     ULONG ref = InterlockedIncrement(&(This->ref));
00134     TRACE("(%p) ref was %d\n", This, ref - 1);
00135     return ref;
00136 }
00137 
00138 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound_Release(
00139     LPDIRECTSOUND iface)
00140 {
00141     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00142     ULONG ref = InterlockedDecrement(&(This->ref));
00143     TRACE("(%p) ref was %d\n", This, ref + 1);
00144     if (!ref) {
00145         IDirectSound_Release(This->pdsfd->pDS);
00146         HeapFree(GetProcessHeap(), 0, This);
00147         TRACE("(%p) released\n", This);
00148     }
00149     return ref;
00150 }
00151 
00152 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_CreateSoundBuffer(
00153     LPDIRECTSOUND iface,
00154     LPCDSBUFFERDESC dsbd,
00155     LPLPDIRECTSOUNDBUFFER ppdsb,
00156     LPUNKNOWN lpunk)
00157 {
00158     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00159     TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
00160     return DirectSoundDevice_CreateSoundBuffer(This->pdsfd->renderer_device,dsbd,ppdsb,lpunk,FALSE);
00161 }
00162 
00163 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetCaps(
00164     LPDIRECTSOUND iface,
00165     LPDSCAPS lpDSCaps)
00166 {
00167     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00168     TRACE("(%p,%p)\n",This,lpDSCaps);
00169     return DirectSoundDevice_GetCaps(This->pdsfd->renderer_device, lpDSCaps);
00170 }
00171 
00172 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_DuplicateSoundBuffer(
00173     LPDIRECTSOUND iface,
00174     LPDIRECTSOUNDBUFFER psb,
00175     LPLPDIRECTSOUNDBUFFER ppdsb)
00176 {
00177     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00178     TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
00179     return DirectSoundDevice_DuplicateSoundBuffer(This->pdsfd->renderer_device,psb,ppdsb);
00180 }
00181 
00182 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetCooperativeLevel(
00183     LPDIRECTSOUND iface,
00184     HWND hwnd,
00185     DWORD level)
00186 {
00187     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00188     TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
00189     return DirectSoundDevice_SetCooperativeLevel(This->pdsfd->renderer_device,hwnd,level);
00190 }
00191 
00192 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Compact(
00193     LPDIRECTSOUND iface)
00194 {
00195     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00196     TRACE("(%p)\n", This);
00197     return DirectSoundDevice_Compact(This->pdsfd->renderer_device);
00198 }
00199 
00200 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetSpeakerConfig(
00201     LPDIRECTSOUND iface,
00202     LPDWORD lpdwSpeakerConfig)
00203 {
00204     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00205     TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
00206     return DirectSoundDevice_GetSpeakerConfig(This->pdsfd->renderer_device,lpdwSpeakerConfig);
00207 }
00208 
00209 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetSpeakerConfig(
00210     LPDIRECTSOUND iface,
00211     DWORD config)
00212 {
00213     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00214     TRACE("(%p,0x%08x)\n",This,config);
00215     return DirectSoundDevice_SetSpeakerConfig(This->pdsfd->renderer_device,config);
00216 }
00217 
00218 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Initialize(
00219     LPDIRECTSOUND iface,
00220     LPCGUID lpcGuid)
00221 {
00222     IDirectSoundFullDuplex_IDirectSound *This = (IDirectSoundFullDuplex_IDirectSound *)iface;
00223     TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
00224     return DirectSoundDevice_Initialize(&This->pdsfd->renderer_device,lpcGuid);
00225 }
00226 
00227 static const IDirectSoundVtbl DirectSoundFullDuplex_DirectSound_Vtbl =
00228 {
00229     IDirectSoundFullDuplex_IDirectSound_QueryInterface,
00230     IDirectSoundFullDuplex_IDirectSound_AddRef,
00231     IDirectSoundFullDuplex_IDirectSound_Release,
00232     IDirectSoundFullDuplex_IDirectSound_CreateSoundBuffer,
00233     IDirectSoundFullDuplex_IDirectSound_GetCaps,
00234     IDirectSoundFullDuplex_IDirectSound_DuplicateSoundBuffer,
00235     IDirectSoundFullDuplex_IDirectSound_SetCooperativeLevel,
00236     IDirectSoundFullDuplex_IDirectSound_Compact,
00237     IDirectSoundFullDuplex_IDirectSound_GetSpeakerConfig,
00238     IDirectSoundFullDuplex_IDirectSound_SetSpeakerConfig,
00239     IDirectSoundFullDuplex_IDirectSound_Initialize
00240 };
00241 
00242 static HRESULT IDirectSoundFullDuplex_IDirectSound_Create(
00243     LPDIRECTSOUNDFULLDUPLEX pdsfd,
00244     LPDIRECTSOUND * ppds)
00245 {
00246     IDirectSoundFullDuplex_IDirectSound * pdsfdds;
00247     TRACE("(%p,%p)\n",pdsfd,ppds);
00248 
00249     if (pdsfd == NULL) {
00250         ERR("invalid parameter: pdsfd == NULL\n");
00251         return DSERR_INVALIDPARAM;
00252     }
00253 
00254     if (ppds == NULL) {
00255         ERR("invalid parameter: ppds == NULL\n");
00256         return DSERR_INVALIDPARAM;
00257     }
00258 
00259     if (((IDirectSoundFullDuplexImpl*)pdsfd)->renderer_device == NULL) {
00260         WARN("not initialized\n");
00261         *ppds = NULL;
00262         return DSERR_UNINITIALIZED;
00263     }
00264 
00265     pdsfdds = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdds));
00266     if (pdsfdds == NULL) {
00267         WARN("out of memory\n");
00268         *ppds = NULL;
00269         return DSERR_OUTOFMEMORY;
00270     }
00271 
00272     pdsfdds->lpVtbl = &DirectSoundFullDuplex_DirectSound_Vtbl;
00273     pdsfdds->ref = 0;
00274     pdsfdds->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
00275 
00276     *ppds = (LPDIRECTSOUND)pdsfdds;
00277 
00278     return DS_OK;
00279 }
00280 
00281 /*******************************************************************************
00282  * IDirectSoundFullDuplex_IDirectSound8
00283  */
00284 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_QueryInterface(
00285     LPDIRECTSOUND8 iface,
00286     REFIID riid,
00287     LPVOID * ppobj)
00288 {
00289     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00290     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
00291     return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
00292 }
00293 
00294 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_AddRef(
00295     LPDIRECTSOUND8 iface)
00296 {
00297     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00298     ULONG ref = InterlockedIncrement(&(This->ref));
00299     TRACE("(%p) ref was %d\n", This, ref - 1);
00300     return ref;
00301 }
00302 
00303 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_Release(
00304     LPDIRECTSOUND8 iface)
00305 {
00306     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00307     ULONG ref = InterlockedDecrement(&(This->ref));
00308     TRACE("(%p) ref was %d\n", This, ref + 1);
00309     if (!ref) {
00310         IDirectSound_Release(This->pdsfd->pDS8);
00311         HeapFree(GetProcessHeap(), 0, This);
00312         TRACE("(%p) released\n", This);
00313     }
00314     return ref;
00315 }
00316 
00317 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_CreateSoundBuffer(
00318     LPDIRECTSOUND8 iface,
00319     LPCDSBUFFERDESC dsbd,
00320     LPLPDIRECTSOUNDBUFFER ppdsb,
00321     LPUNKNOWN lpunk)
00322 {
00323     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00324     TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
00325     return DirectSoundDevice_CreateSoundBuffer(This->pdsfd->renderer_device,dsbd,ppdsb,lpunk,TRUE);
00326 }
00327 
00328 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetCaps(
00329     LPDIRECTSOUND8 iface,
00330     LPDSCAPS lpDSCaps)
00331 {
00332     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00333     TRACE("(%p,%p)\n",This,lpDSCaps);
00334     return DirectSoundDevice_GetCaps(This->pdsfd->renderer_device, lpDSCaps);
00335 }
00336 
00337 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_DuplicateSoundBuffer(
00338     LPDIRECTSOUND8 iface,
00339     LPDIRECTSOUNDBUFFER psb,
00340     LPLPDIRECTSOUNDBUFFER ppdsb)
00341 {
00342     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00343     TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
00344     return DirectSoundDevice_DuplicateSoundBuffer(This->pdsfd->renderer_device,psb,ppdsb);
00345 }
00346 
00347 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel(
00348     LPDIRECTSOUND8 iface,
00349     HWND hwnd,
00350     DWORD level)
00351 {
00352     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00353     TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
00354     return DirectSoundDevice_SetCooperativeLevel(This->pdsfd->renderer_device,hwnd,level);
00355 }
00356 
00357 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Compact(
00358     LPDIRECTSOUND8 iface)
00359 {
00360     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00361     TRACE("(%p)\n", This);
00362     return DirectSoundDevice_Compact(This->pdsfd->renderer_device);
00363 }
00364 
00365 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetSpeakerConfig(
00366     LPDIRECTSOUND8 iface,
00367     LPDWORD lpdwSpeakerConfig)
00368 {
00369     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00370     TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
00371     return DirectSoundDevice_GetSpeakerConfig(This->pdsfd->renderer_device,lpdwSpeakerConfig);
00372 }
00373 
00374 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetSpeakerConfig(
00375     LPDIRECTSOUND8 iface,
00376     DWORD config)
00377 {
00378     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00379     TRACE("(%p,0x%08x)\n",This,config);
00380     return DirectSoundDevice_SetSpeakerConfig(This->pdsfd->renderer_device,config);
00381 }
00382 
00383 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Initialize(
00384     LPDIRECTSOUND8 iface,
00385     LPCGUID lpcGuid)
00386 {
00387     IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
00388     TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
00389     return DirectSoundDevice_Initialize(&This->pdsfd->renderer_device,lpcGuid);
00390 }
00391 
00392 static const IDirectSound8Vtbl DirectSoundFullDuplex_DirectSound8_Vtbl =
00393 {
00394     IDirectSoundFullDuplex_IDirectSound8_QueryInterface,
00395     IDirectSoundFullDuplex_IDirectSound8_AddRef,
00396     IDirectSoundFullDuplex_IDirectSound8_Release,
00397     IDirectSoundFullDuplex_IDirectSound8_CreateSoundBuffer,
00398     IDirectSoundFullDuplex_IDirectSound8_GetCaps,
00399     IDirectSoundFullDuplex_IDirectSound8_DuplicateSoundBuffer,
00400     IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel,
00401     IDirectSoundFullDuplex_IDirectSound8_Compact,
00402     IDirectSoundFullDuplex_IDirectSound8_GetSpeakerConfig,
00403     IDirectSoundFullDuplex_IDirectSound8_SetSpeakerConfig,
00404     IDirectSoundFullDuplex_IDirectSound8_Initialize
00405 };
00406 
00407 static HRESULT IDirectSoundFullDuplex_IDirectSound8_Create(
00408     LPDIRECTSOUNDFULLDUPLEX pdsfd,
00409     LPDIRECTSOUND8 * ppds8)
00410 {
00411     IDirectSoundFullDuplex_IDirectSound8 * pdsfdds8;
00412     TRACE("(%p,%p)\n",pdsfd,ppds8);
00413 
00414     if (pdsfd == NULL) {
00415         ERR("invalid parameter: pdsfd == NULL\n");
00416         return DSERR_INVALIDPARAM;
00417     }
00418 
00419     if (ppds8 == NULL) {
00420         ERR("invalid parameter: ppds8 == NULL\n");
00421         return DSERR_INVALIDPARAM;
00422     }
00423 
00424     if (((IDirectSoundFullDuplexImpl*)pdsfd)->renderer_device == NULL) {
00425         WARN("not initialized\n");
00426         *ppds8 = NULL;
00427         return DSERR_UNINITIALIZED;
00428     }
00429 
00430     pdsfdds8 = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdds8));
00431     if (pdsfdds8 == NULL) {
00432         WARN("out of memory\n");
00433         *ppds8 = NULL;
00434         return DSERR_OUTOFMEMORY;
00435     }
00436 
00437     pdsfdds8->lpVtbl = &DirectSoundFullDuplex_DirectSound8_Vtbl;
00438     pdsfdds8->ref = 0;
00439     pdsfdds8->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
00440 
00441     *ppds8 = (LPDIRECTSOUND8)pdsfdds8;
00442 
00443     return DS_OK;
00444 }
00445 
00446 /*******************************************************************************
00447  * IDirectSoundFullDuplex_IDirectSoundCapture
00448  */
00449 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface(
00450     LPDIRECTSOUNDCAPTURE iface,
00451     REFIID riid,
00452     LPVOID * ppobj)
00453 {
00454     IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
00455     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
00456     return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
00457 }
00458 
00459 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(
00460     LPDIRECTSOUNDCAPTURE iface)
00461 {
00462     IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
00463     ULONG ref = InterlockedIncrement(&(This->ref));
00464     TRACE("(%p) ref was %d\n", This, ref - 1);
00465     return ref;
00466 }
00467 
00468 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_Release(
00469     LPDIRECTSOUNDCAPTURE iface)
00470 {
00471     IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
00472     ULONG ref = InterlockedDecrement(&(This->ref));
00473     TRACE("(%p) ref was %d\n", This, ref + 1);
00474     if (!ref) {
00475         IDirectSoundCapture_Release(This->pdsfd->pDSC);
00476         HeapFree(GetProcessHeap(), 0, This);
00477         TRACE("(%p) released\n", This);
00478     }
00479     return ref;
00480 }
00481 
00482 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_CreateCaptureBuffer(
00483     LPDIRECTSOUNDCAPTURE iface,
00484     LPCDSCBUFFERDESC lpcDSCBufferDesc,
00485     LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
00486     LPUNKNOWN pUnk)
00487 {
00488     IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
00489     TRACE("(%p,%p,%p,%p)\n",This,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
00490     return IDirectSoundCaptureImpl_CreateCaptureBuffer(This->pdsfd->pDSC,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
00491 }
00492 
00493 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_GetCaps(
00494     LPDIRECTSOUNDCAPTURE iface,
00495     LPDSCCAPS lpDSCCaps)
00496 {
00497     IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
00498     TRACE("(%p,%p)\n",This,lpDSCCaps);
00499     return IDirectSoundCaptureImpl_GetCaps(This->pdsfd->pDSC, lpDSCCaps);
00500 }
00501 
00502 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_Initialize(
00503     LPDIRECTSOUNDCAPTURE iface,
00504     LPCGUID lpcGUID)
00505 {
00506     IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
00507     TRACE("(%p, %s)\n", This, debugstr_guid(lpcGUID));
00508     return IDirectSoundCaptureImpl_Initialize(This->pdsfd->pDSC,lpcGUID);
00509 }
00510 
00511 static const IDirectSoundCaptureVtbl DirectSoundFullDuplex_DirectSoundCapture_Vtbl =
00512 {
00513     IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface,
00514     IDirectSoundFullDuplex_IDirectSoundCapture_AddRef,
00515     IDirectSoundFullDuplex_IDirectSoundCapture_Release,
00516     IDirectSoundFullDuplex_IDirectSoundCapture_CreateCaptureBuffer,
00517     IDirectSoundFullDuplex_IDirectSoundCapture_GetCaps,
00518     IDirectSoundFullDuplex_IDirectSoundCapture_Initialize
00519 };
00520 
00521 static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create(
00522     LPDIRECTSOUNDFULLDUPLEX pdsfd,
00523     LPDIRECTSOUNDCAPTURE8 * ppdsc8)
00524 {
00525     IDirectSoundFullDuplex_IDirectSoundCapture * pdsfddsc;
00526     TRACE("(%p,%p)\n",pdsfd,ppdsc8);
00527 
00528     if (pdsfd == NULL) {
00529         ERR("invalid parameter: pdsfd == NULL\n");
00530         return DSERR_INVALIDPARAM;
00531     }
00532 
00533     if (ppdsc8 == NULL) {
00534         ERR("invalid parameter: ppdsc8 == NULL\n");
00535         return DSERR_INVALIDPARAM;
00536     }
00537 
00538     if (((IDirectSoundFullDuplexImpl*)pdsfd)->capture_device == NULL) {
00539         WARN("not initialized\n");
00540         *ppdsc8 = NULL;
00541         return DSERR_UNINITIALIZED;
00542     }
00543 
00544     pdsfddsc = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfddsc));
00545     if (pdsfddsc == NULL) {
00546         WARN("out of memory\n");
00547         *ppdsc8 = NULL;
00548         return DSERR_OUTOFMEMORY;
00549     }
00550 
00551     pdsfddsc->lpVtbl = &DirectSoundFullDuplex_DirectSoundCapture_Vtbl;
00552     pdsfddsc->ref = 0;
00553     pdsfddsc->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
00554 
00555     *ppdsc8 = (LPDIRECTSOUNDCAPTURE)pdsfddsc;
00556 
00557     return DS_OK;
00558 }
00559 
00560 /***************************************************************************
00561  * IDirectSoundFullDuplexImpl
00562  */
00563 static ULONG WINAPI
00564 IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface )
00565 {
00566     IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
00567     ULONG ref = InterlockedIncrement(&(This->ref));
00568     TRACE("(%p) ref was %d\n", This, ref - 1);
00569     return ref;
00570 }
00571 
00572 static HRESULT WINAPI
00573 IDirectSoundFullDuplexImpl_QueryInterface(
00574     LPDIRECTSOUNDFULLDUPLEX iface,
00575     REFIID riid,
00576     LPVOID* ppobj )
00577 {
00578     IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
00579     TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
00580 
00581     if (ppobj == NULL) {
00582     WARN("invalid parameter\n");
00583     return E_INVALIDARG;
00584     }
00585 
00586     *ppobj = NULL;
00587 
00588     if (IsEqualIID(riid, &IID_IUnknown)) {
00589         if (!This->pUnknown) {
00590             IDirectSoundFullDuplex_IUnknown_Create(iface, &This->pUnknown);
00591             if (!This->pUnknown) {
00592                 WARN("IDirectSoundFullDuplex_IUnknown_Create() failed\n");
00593                 *ppobj = NULL;
00594                 return E_NOINTERFACE;
00595             }
00596         }
00597         IDirectSoundFullDuplex_IUnknown_AddRef(This->pUnknown);
00598         *ppobj = This->pUnknown;
00599         return S_OK;
00600     } else if (IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) {
00601         IDirectSoundFullDuplexImpl_AddRef(iface);
00602         *ppobj = This;
00603         return S_OK;
00604     } else if (IsEqualIID(riid, &IID_IDirectSound)) {
00605         if (!This->pDS) {
00606             IDirectSoundFullDuplex_IDirectSound_Create(iface, &This->pDS);
00607             if (!This->pDS) {
00608                 WARN("IDirectSoundFullDuplex_IDirectSound_Create() failed\n");
00609                 *ppobj = NULL;
00610                 return E_NOINTERFACE;
00611             }
00612         }
00613         IDirectSoundFullDuplex_IDirectSound_AddRef(This->pDS);
00614         *ppobj = This->pDS;
00615         return S_OK;
00616     } else if (IsEqualIID(riid, &IID_IDirectSound8)) {
00617         if (!This->pDS8) {
00618             IDirectSoundFullDuplex_IDirectSound8_Create(iface, &This->pDS8);
00619             if (!This->pDS8) {
00620                 WARN("IDirectSoundFullDuplex_IDirectSound8_Create() failed\n");
00621                 *ppobj = NULL;
00622                 return E_NOINTERFACE;
00623             }
00624         }
00625         IDirectSoundFullDuplex_IDirectSound8_AddRef(This->pDS8);
00626         *ppobj = This->pDS8;
00627         return S_OK;
00628     } else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) {
00629         if (!This->pDSC) {
00630             IDirectSoundFullDuplex_IDirectSoundCapture_Create(iface, &This->pDSC);
00631             if (!This->pDSC) {
00632                 WARN("IDirectSoundFullDuplex_IDirectSoundCapture_Create() failed\n");
00633                 *ppobj = NULL;
00634                 return E_NOINTERFACE;
00635             }
00636         }
00637         IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(This->pDSC);
00638         *ppobj = This->pDSC;
00639         return S_OK;
00640     }
00641 
00642     return E_NOINTERFACE;
00643 }
00644 
00645 static ULONG WINAPI
00646 IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
00647 {
00648     IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
00649     ULONG ref = InterlockedDecrement(&(This->ref));
00650     TRACE("(%p) ref was %d\n", This, ref - 1);
00651 
00652     if (!ref) {
00653         if (This->capture_device)
00654             DirectSoundCaptureDevice_Release(This->capture_device);
00655         if (This->renderer_device)
00656             DirectSoundDevice_Release(This->renderer_device);
00657         HeapFree( GetProcessHeap(), 0, This );
00658     TRACE("(%p) released\n", This);
00659     }
00660     return ref;
00661 }
00662 
00663 static HRESULT WINAPI
00664 IDirectSoundFullDuplexImpl_Initialize(
00665     LPDIRECTSOUNDFULLDUPLEX iface,
00666     LPCGUID pCaptureGuid,
00667     LPCGUID pRendererGuid,
00668     LPCDSCBUFFERDESC lpDscBufferDesc,
00669     LPCDSBUFFERDESC lpDsBufferDesc,
00670     HWND hWnd,
00671     DWORD dwLevel,
00672     LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8,
00673     LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 )
00674 {
00675     HRESULT hr;
00676     IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
00677     IDirectSoundBufferImpl * dsb;
00678 
00679     TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This,
00680         debugstr_guid(pCaptureGuid), debugstr_guid(pRendererGuid),
00681         lpDscBufferDesc, lpDsBufferDesc, hWnd, dwLevel,
00682         lplpDirectSoundCaptureBuffer8, lplpDirectSoundBuffer8);
00683 
00684     if (This->renderer_device != NULL || This->capture_device != NULL) {
00685         WARN("already initialized\n");
00686         *lplpDirectSoundCaptureBuffer8 = NULL;
00687         *lplpDirectSoundBuffer8 = NULL;
00688         return DSERR_ALREADYINITIALIZED;
00689     }
00690 
00691     hr = DirectSoundDevice_Initialize(&This->renderer_device, pRendererGuid);
00692     if (hr != DS_OK) {
00693         WARN("DirectSoundDevice_Initialize() failed\n");
00694         *lplpDirectSoundCaptureBuffer8 = NULL;
00695         *lplpDirectSoundBuffer8 = NULL;
00696         return hr;
00697     }
00698 
00699     if (dwLevel==DSSCL_PRIORITY || dwLevel==DSSCL_EXCLUSIVE) {
00700         WARN("level=%s not fully supported\n",
00701              dwLevel==DSSCL_PRIORITY ? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
00702     }
00703     This->renderer_device->priolevel = dwLevel;
00704 
00705     hr = DSOUND_PrimarySetFormat(This->renderer_device, lpDsBufferDesc->lpwfxFormat, dwLevel == DSSCL_EXCLUSIVE);
00706     if (hr != DS_OK) {
00707         WARN("DSOUND_PrimarySetFormat() failed\n");
00708         *lplpDirectSoundCaptureBuffer8 = NULL;
00709         *lplpDirectSoundBuffer8 = NULL;
00710         return hr;
00711     }
00712     hr = IDirectSoundBufferImpl_Create(This->renderer_device, &dsb, lpDsBufferDesc);
00713     if (hr != DS_OK) {
00714         WARN("IDirectSoundBufferImpl_Create() failed\n");
00715         *lplpDirectSoundCaptureBuffer8 = NULL;
00716         *lplpDirectSoundBuffer8 = NULL;
00717         return hr;
00718     }
00719 
00720     hr = SecondaryBufferImpl_Create(dsb, (SecondaryBufferImpl **)lplpDirectSoundBuffer8);
00721     if (hr != DS_OK) {
00722         WARN("SecondaryBufferImpl_Create() failed\n");
00723         *lplpDirectSoundCaptureBuffer8 = NULL;
00724         *lplpDirectSoundBuffer8 = NULL;
00725         return hr;
00726     }
00727     IDirectSoundBuffer8_AddRef(*lplpDirectSoundBuffer8);
00728 
00729     hr = DirectSoundCaptureDevice_Initialize(&This->capture_device, pCaptureGuid);
00730     if (hr != DS_OK) {
00731         WARN("DirectSoundCaptureDevice_Initialize() failed\n");
00732         *lplpDirectSoundCaptureBuffer8 = NULL;
00733         *lplpDirectSoundBuffer8 = NULL;
00734         return hr;
00735     }
00736 
00737     hr = IDirectSoundCaptureBufferImpl_Create(This->capture_device,
00738          (IDirectSoundCaptureBufferImpl **)lplpDirectSoundCaptureBuffer8,
00739          lpDscBufferDesc);
00740     if (hr != DS_OK) {
00741         WARN("IDirectSoundCaptureBufferImpl_Create() failed\n");
00742         *lplpDirectSoundCaptureBuffer8 = NULL;
00743         *lplpDirectSoundBuffer8 = NULL;
00744         return hr;
00745     }
00746 
00747     return hr;
00748 }
00749 
00750 static const IDirectSoundFullDuplexVtbl dsfdvt =
00751 {
00752     /* IUnknown methods */
00753     IDirectSoundFullDuplexImpl_QueryInterface,
00754     IDirectSoundFullDuplexImpl_AddRef,
00755     IDirectSoundFullDuplexImpl_Release,
00756 
00757     /* IDirectSoundFullDuplex methods */
00758     IDirectSoundFullDuplexImpl_Initialize
00759 };
00760 
00761 HRESULT DSOUND_FullDuplexCreate(
00762     REFIID riid,
00763     LPDIRECTSOUNDFULLDUPLEX* ppDSFD)
00764 {
00765     IDirectSoundFullDuplexImpl *This = NULL;
00766     TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSFD);
00767 
00768     if (ppDSFD == NULL) {
00769         WARN("invalid parameter: ppDSFD == NULL\n");
00770         return DSERR_INVALIDPARAM;
00771     }
00772 
00773     if (!IsEqualIID(riid, &IID_IUnknown) &&
00774         !IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) {
00775         *ppDSFD = 0;
00776         return E_NOINTERFACE;
00777     }
00778 
00779     /* Get dsound configuration */
00780     setup_dsound_options();
00781 
00782     This = HeapAlloc(GetProcessHeap(),
00783         HEAP_ZERO_MEMORY, sizeof(IDirectSoundFullDuplexImpl));
00784 
00785     if (This == NULL) {
00786         WARN("out of memory\n");
00787         *ppDSFD = NULL;
00788         return DSERR_OUTOFMEMORY;
00789     }
00790 
00791     This->lpVtbl = &dsfdvt;
00792     This->ref = 1;
00793     This->capture_device = NULL;
00794     This->renderer_device = NULL;
00795 
00796     *ppDSFD = (LPDIRECTSOUNDFULLDUPLEX)This;
00797 
00798     return DS_OK;
00799 }
00800 
00801 /***************************************************************************
00802  * DirectSoundFullDuplexCreate [DSOUND.10]
00803  *
00804  * Create and initialize a DirectSoundFullDuplex interface.
00805  *
00806  * PARAMS
00807  *    pcGuidCaptureDevice [I] Address of sound capture device GUID.
00808  *    pcGuidRenderDevice  [I] Address of sound render device GUID.
00809  *    pcDSCBufferDesc     [I] Address of capture buffer description.
00810  *    pcDSBufferDesc      [I] Address of  render buffer description.
00811  *    hWnd                [I] Handle to application window.
00812  *    dwLevel             [I] Cooperative level.
00813  *    ppDSFD              [O] Address where full duplex interface returned.
00814  *    ppDSCBuffer8        [0] Address where capture buffer interface returned.
00815  *    ppDSBuffer8         [0] Address where render buffer interface returned.
00816  *    pUnkOuter           [I] Must be NULL.
00817  *
00818  * RETURNS
00819  *    Success: DS_OK
00820  *    Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM,
00821  *             DSERR_OUTOFMEMORY DSERR_INVALIDCALL DSERR_NODRIVER
00822  */
00823 HRESULT WINAPI
00824 DirectSoundFullDuplexCreate(
00825     LPCGUID pcGuidCaptureDevice,
00826     LPCGUID pcGuidRenderDevice,
00827     LPCDSCBUFFERDESC pcDSCBufferDesc,
00828     LPCDSBUFFERDESC pcDSBufferDesc,
00829     HWND hWnd,
00830     DWORD dwLevel,
00831     LPDIRECTSOUNDFULLDUPLEX *ppDSFD,
00832     LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8,
00833     LPDIRECTSOUNDBUFFER8 *ppDSBuffer8,
00834     LPUNKNOWN pUnkOuter)
00835 {
00836     HRESULT hres;
00837     IDirectSoundFullDuplexImpl *This = NULL;
00838     TRACE("(%s,%s,%p,%p,%p,%x,%p,%p,%p,%p)\n",
00839         debugstr_guid(pcGuidCaptureDevice), debugstr_guid(pcGuidRenderDevice),
00840         pcDSCBufferDesc, pcDSBufferDesc, hWnd, dwLevel, ppDSFD, ppDSCBuffer8,
00841         ppDSBuffer8, pUnkOuter);
00842 
00843     if (pUnkOuter) {
00844         WARN("pUnkOuter != 0\n");
00845         *ppDSFD = NULL;
00846         return DSERR_NOAGGREGATION;
00847     }
00848 
00849     if (pcDSCBufferDesc == NULL) {
00850         WARN("invalid parameter: pcDSCBufferDesc == NULL\n");
00851         *ppDSFD = NULL;
00852         return DSERR_INVALIDPARAM;
00853     }
00854 
00855     if (pcDSBufferDesc == NULL) {
00856         WARN("invalid parameter: pcDSBufferDesc == NULL\n");
00857         *ppDSFD = NULL;
00858         return DSERR_INVALIDPARAM;
00859     }
00860 
00861     if (ppDSFD == NULL) {
00862         WARN("invalid parameter: ppDSFD == NULL\n");
00863         return DSERR_INVALIDPARAM;
00864     }
00865 
00866     if (ppDSCBuffer8 == NULL) {
00867         WARN("invalid parameter: ppDSCBuffer8 == NULL\n");
00868         *ppDSFD = NULL;
00869         return DSERR_INVALIDPARAM;
00870     }
00871 
00872     if (ppDSBuffer8 == NULL) {
00873         WARN("invalid parameter: ppDSBuffer8 == NULL\n");
00874         *ppDSFD = NULL;
00875         return DSERR_INVALIDPARAM;
00876     }
00877 
00878     /* Get dsound configuration */
00879     setup_dsound_options();
00880 
00881     This = HeapAlloc(GetProcessHeap(),
00882         HEAP_ZERO_MEMORY, sizeof(IDirectSoundFullDuplexImpl));
00883 
00884     if (This == NULL) {
00885         WARN("out of memory\n");
00886         *ppDSFD = NULL;
00887         return DSERR_OUTOFMEMORY;
00888     }
00889 
00890     This->lpVtbl = &dsfdvt;
00891     This->ref = 1;
00892     This->capture_device = NULL;
00893     This->renderer_device = NULL;
00894 
00895     hres = IDirectSoundFullDuplexImpl_Initialize((LPDIRECTSOUNDFULLDUPLEX)This,
00896                                                  pcGuidCaptureDevice,
00897                                                  pcGuidRenderDevice,
00898                                                  pcDSCBufferDesc,
00899                                                  pcDSBufferDesc,
00900                                                  hWnd, dwLevel, ppDSCBuffer8,
00901                                                  ppDSBuffer8);
00902     if (hres != DS_OK) {
00903         HeapFree(GetProcessHeap(), 0, This);
00904         WARN("IDirectSoundFullDuplexImpl_Initialize failed\n");
00905         *ppDSFD = NULL;
00906     } else
00907         *ppDSFD = (LPDIRECTSOUNDFULLDUPLEX)This;
00908 
00909     return hres;
00910 }

Generated on Sun May 27 2012 04:21:41 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.