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

dsound_private.h
Go to the documentation of this file.
00001 /*              DirectSound
00002  *
00003  * Copyright 1998 Marcus Meissner
00004  * Copyright 1998 Rob Riggs
00005  * Copyright 2000-2001 TransGaming Technologies, Inc.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00020  */
00021 
00022 /* Linux does not support better timing than 10ms */
00023 #define DS_TIME_RES 2  /* Resolution of multimedia timer */
00024 #define DS_TIME_DEL 10  /* Delay of multimedia timer callback, and duration of HEL fragment */
00025 
00026 #include "wine/list.h"
00027 
00028 /* direct sound hardware acceleration levels */
00029 #define DS_HW_ACCEL_FULL        0   /* default on Windows 98 */
00030 #define DS_HW_ACCEL_STANDARD    1   /* default on Windows 2000 */
00031 #define DS_HW_ACCEL_BASIC       2
00032 #define DS_HW_ACCEL_EMULATION   3
00033 
00034 extern int ds_emuldriver;
00035 extern int ds_hel_buflen;
00036 extern int ds_snd_queue_max;
00037 extern int ds_snd_queue_min;
00038 extern int ds_snd_shadow_maxsize;
00039 extern int ds_hw_accel;
00040 extern int ds_default_sample_rate;
00041 extern int ds_default_bits_per_sample;
00042 
00043 /*****************************************************************************
00044  * Predeclare the interface implementation structures
00045  */
00046 typedef struct IDirectSoundImpl              IDirectSoundImpl;
00047 typedef struct IDirectSound_IUnknown         IDirectSound_IUnknown;
00048 typedef struct IDirectSound_IDirectSound     IDirectSound_IDirectSound;
00049 typedef struct IDirectSound8_IUnknown        IDirectSound8_IUnknown;
00050 typedef struct IDirectSound8_IDirectSound    IDirectSound8_IDirectSound;
00051 typedef struct IDirectSound8_IDirectSound8   IDirectSound8_IDirectSound8;
00052 typedef struct IDirectSoundBufferImpl        IDirectSoundBufferImpl;
00053 typedef struct IDirectSoundCaptureImpl       IDirectSoundCaptureImpl;
00054 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
00055 typedef struct IDirectSoundFullDuplexImpl    IDirectSoundFullDuplexImpl;
00056 typedef struct IDirectSoundFullDuplex_IUnknown IDirectSoundFullDuplex_IUnknown;
00057 typedef struct IDirectSoundFullDuplex_IDirectSound IDirectSoundFullDuplex_IDirectSound;
00058 typedef struct IDirectSoundFullDuplex_IDirectSound8 IDirectSoundFullDuplex_IDirectSound8;
00059 typedef struct IDirectSoundFullDuplex_IDirectSoundCapture IDirectSoundFullDuplex_IDirectSoundCapture;
00060 typedef struct IDirectSoundNotifyImpl        IDirectSoundNotifyImpl;
00061 typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
00062 typedef struct IDirectSound3DListenerImpl    IDirectSound3DListenerImpl;
00063 typedef struct IDirectSound3DBufferImpl      IDirectSound3DBufferImpl;
00064 typedef struct IKsBufferPropertySetImpl      IKsBufferPropertySetImpl;
00065 typedef struct IKsPrivatePropertySetImpl     IKsPrivatePropertySetImpl;
00066 typedef struct PrimaryBufferImpl             PrimaryBufferImpl;
00067 typedef struct SecondaryBufferImpl           SecondaryBufferImpl;
00068 typedef struct DirectSoundDevice             DirectSoundDevice;
00069 typedef struct DirectSoundCaptureDevice      DirectSoundCaptureDevice;
00070 
00071 /* dsound_convert.h */
00072 typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
00073 extern const bitsconvertfunc convertbpp[4][4];
00074 typedef void (*mixfunc)(const void *, void *, unsigned);
00075 extern const mixfunc mixfunctions[4];
00076 typedef void (*normfunc)(const void *, void *, unsigned);
00077 extern const normfunc normfunctions[4];
00078 
00079 /*****************************************************************************
00080  * IDirectSoundDevice implementation structure
00081  */
00082 struct DirectSoundDevice
00083 {
00084     LONG                        ref;
00085 
00086     GUID                        guid;
00087     PIDSDRIVER                  driver;
00088     DSDRIVERDESC                drvdesc;
00089     DSDRIVERCAPS                drvcaps;
00090     DWORD                       priolevel;
00091     PWAVEFORMATEX               pwfx;
00092     HWAVEOUT                    hwo;
00093     LPWAVEHDR                   pwave;
00094     UINT                        timerID, pwplay, pwqueue, prebuf, helfrags;
00095     DWORD                       fraglen;
00096     PIDSDRIVERBUFFER            hwbuf;
00097     LPBYTE                      buffer;
00098     DWORD                       writelead, buflen, state, playpos, mixpos;
00099     int                         nrofbuffers;
00100     IDirectSoundBufferImpl**    buffers;
00101     RTL_RWLOCK                  buffer_list_lock;
00102     CRITICAL_SECTION            mixlock;
00103     PrimaryBufferImpl*          primary;
00104     DSBUFFERDESC                dsbd;
00105     DWORD                       speaker_config;
00106     LPBYTE                      tmp_buffer, mix_buffer;
00107     DWORD                       tmp_buffer_len, mix_buffer_len;
00108 
00109     DSVOLUMEPAN                 volpan;
00110 
00111     mixfunc mixfunction;
00112     normfunc normfunction;
00113 
00114     /* DirectSound3DListener fields */
00115     IDirectSound3DListenerImpl* listener;
00116     DS3DLISTENER                ds3dl;
00117     BOOL                        ds3dl_need_recalc;
00118 };
00119 
00120 /* reference counted buffer memory for duplicated buffer memory */
00121 typedef struct BufferMemory
00122 {
00123     LONG                        ref;
00124     LPBYTE                      memory;
00125     struct list buffers;
00126 } BufferMemory;
00127 
00128 ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
00129 HRESULT DirectSoundDevice_Initialize(
00130     DirectSoundDevice ** ppDevice,
00131     LPCGUID lpcGUID);
00132 HRESULT DirectSoundDevice_AddBuffer(
00133     DirectSoundDevice * device,
00134     IDirectSoundBufferImpl * pDSB);
00135 HRESULT DirectSoundDevice_RemoveBuffer(
00136     DirectSoundDevice * device,
00137     IDirectSoundBufferImpl * pDSB);
00138 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
00139 HRESULT DirectSoundDevice_CreateSoundBuffer(
00140     DirectSoundDevice * device,
00141     LPCDSBUFFERDESC dsbd,
00142     LPLPDIRECTSOUNDBUFFER ppdsb,
00143     LPUNKNOWN lpunk,
00144     BOOL from8);
00145 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
00146     DirectSoundDevice * device,
00147     LPDIRECTSOUNDBUFFER psb,
00148     LPLPDIRECTSOUNDBUFFER ppdsb);
00149 HRESULT DirectSoundDevice_SetCooperativeLevel(
00150     DirectSoundDevice * devcie,
00151     HWND hwnd,
00152     DWORD level);
00153 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
00154 HRESULT DirectSoundDevice_GetSpeakerConfig(
00155     DirectSoundDevice * device,
00156     LPDWORD lpdwSpeakerConfig);
00157 HRESULT DirectSoundDevice_SetSpeakerConfig(
00158     DirectSoundDevice * device,
00159     DWORD config);
00160 
00161 /*****************************************************************************
00162  * IDirectSoundBuffer implementation structure
00163  */
00164 struct IDirectSoundBufferImpl
00165 {
00166     /* FIXME: document */
00167     /* IUnknown fields */
00168     const IDirectSoundBuffer8Vtbl *lpVtbl;
00169     LONG                        ref;
00170     /* IDirectSoundBufferImpl fields */
00171     SecondaryBufferImpl*        secondary;
00172     DirectSoundDevice*          device;
00173     RTL_RWLOCK                  lock;
00174     PIDSDRIVERBUFFER            hwbuf;
00175     PWAVEFORMATEX               pwfx;
00176     BufferMemory*               buffer;
00177     LPBYTE                      tmp_buffer;
00178     DWORD                       playflags,state,leadin;
00179     DWORD                       writelead,buflen;
00180     DWORD                       nAvgBytesPerSec;
00181     DWORD                       freq, tmp_buffer_len, max_buffer_len;
00182     DSVOLUMEPAN                 volpan;
00183     DSBUFFERDESC                dsbd;
00184     /* used for frequency conversion (PerfectPitch) */
00185     ULONG                       freqneeded, freqAdjust, freqAcc, freqAccNext, resampleinmixer;
00186     /* used for mixing */
00187     DWORD                       primary_mixpos, buf_mixpos, sec_mixpos;
00188 
00189     /* IDirectSoundNotifyImpl fields */
00190     IDirectSoundNotifyImpl*     notify;
00191     LPDSBPOSITIONNOTIFY         notifies;
00192     int                         nrofnotifies;
00193     PIDSDRIVERNOTIFY            hwnotify;
00194 
00195     /* DirectSound3DBuffer fields */
00196     IDirectSound3DBufferImpl*   ds3db;
00197     DS3DBUFFER                  ds3db_ds3db;
00198     LONG                        ds3db_lVolume;
00199     BOOL                        ds3db_need_recalc;
00200 
00201     /* IKsPropertySet fields */
00202     IKsBufferPropertySetImpl*   iks;
00203     bitsconvertfunc convert;
00204     struct list entry;
00205 };
00206 
00207 HRESULT IDirectSoundBufferImpl_Create(
00208     DirectSoundDevice *device,
00209     IDirectSoundBufferImpl **ppdsb,
00210     LPCDSBUFFERDESC dsbd);
00211 HRESULT IDirectSoundBufferImpl_Destroy(
00212     IDirectSoundBufferImpl *pdsb);
00213 HRESULT IDirectSoundBufferImpl_Duplicate(
00214     DirectSoundDevice *device,
00215     IDirectSoundBufferImpl **ppdsb,
00216     IDirectSoundBufferImpl *pdsb);
00217 
00218 /*****************************************************************************
00219  * SecondaryBuffer implementation structure
00220  */
00221 struct SecondaryBufferImpl
00222 {
00223     const IDirectSoundBuffer8Vtbl *lpVtbl;
00224     LONG                        ref;
00225     IDirectSoundBufferImpl*     dsb;
00226 };
00227 
00228 HRESULT SecondaryBufferImpl_Create(
00229     IDirectSoundBufferImpl *dsb,
00230     SecondaryBufferImpl **pdsb);
00231 
00232 /*****************************************************************************
00233  * PrimaryBuffer implementation structure
00234  */
00235 struct PrimaryBufferImpl
00236 {
00237     const IDirectSoundBufferVtbl *lpVtbl;
00238     LONG                        ref;
00239     DirectSoundDevice*          device;
00240 };
00241 
00242 HRESULT PrimaryBufferImpl_Create(
00243     DirectSoundDevice * device,
00244     PrimaryBufferImpl **ppdsb,
00245     LPCDSBUFFERDESC dsbd);
00246 
00247 /*****************************************************************************
00248  * DirectSoundCaptureDevice implementation structure
00249  */
00250 struct DirectSoundCaptureDevice
00251 {
00252     /* IDirectSoundCaptureImpl fields */
00253     GUID                               guid;
00254     LONG                               ref;
00255 
00256     /* DirectSound driver stuff */
00257     PIDSCDRIVER                        driver;
00258     DSDRIVERDESC                       drvdesc;
00259     DSCDRIVERCAPS                      drvcaps;
00260     PIDSCDRIVERBUFFER                  hwbuf;
00261 
00262     /* wave driver info */
00263     HWAVEIN                            hwi;
00264 
00265     /* more stuff */
00266     LPBYTE                             buffer;
00267     DWORD                              buflen;
00268 
00269     PWAVEFORMATEX                      pwfx;
00270 
00271     IDirectSoundCaptureBufferImpl*     capture_buffer;
00272     DWORD                              state;
00273     LPWAVEHDR                          pwave;
00274     int                                nrofpwaves;
00275     int                                index;
00276     CRITICAL_SECTION                   lock;
00277 };
00278 
00279 HRESULT DirectSoundCaptureDevice_Initialize(
00280     DirectSoundCaptureDevice ** ppDevice,
00281     LPCGUID lpcGUID);
00282 ULONG DirectSoundCaptureDevice_Release(
00283     DirectSoundCaptureDevice * device);
00284 
00285 /*****************************************************************************
00286  * IDirectSoundCaptureBuffer implementation structure
00287  */
00288 struct IDirectSoundCaptureBufferImpl
00289 {
00290     /* IUnknown fields */
00291     const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
00292     LONG                                ref;
00293 
00294     /* IDirectSoundCaptureBufferImpl fields */
00295     DirectSoundCaptureDevice*           device;
00296     /* FIXME: don't need this */
00297     LPDSCBUFFERDESC                     pdscbd;
00298     DWORD                               flags;
00299 
00300     /* IDirectSoundCaptureNotifyImpl fields */
00301     IDirectSoundCaptureNotifyImpl*      notify;
00302     LPDSBPOSITIONNOTIFY                 notifies;
00303     int                                 nrofnotifies;
00304     PIDSDRIVERNOTIFY                    hwnotify;
00305 };
00306 
00307 HRESULT IDirectSoundCaptureBufferImpl_Create(
00308     DirectSoundCaptureDevice *device,
00309     IDirectSoundCaptureBufferImpl ** ppobj,
00310     LPCDSCBUFFERDESC lpcDSCBufferDesc);
00311 
00312 /*****************************************************************************
00313  * IDirectSoundFullDuplex implementation structure
00314  */
00315 struct IDirectSoundFullDuplexImpl
00316 {
00317     /* IUnknown fields */
00318     const IDirectSoundFullDuplexVtbl *lpVtbl;
00319     LONG                              ref;
00320 
00321     /* IDirectSoundFullDuplexImpl fields */
00322     DirectSoundDevice                *renderer_device;
00323     DirectSoundCaptureDevice         *capture_device;
00324 
00325     LPUNKNOWN                         pUnknown;
00326     LPDIRECTSOUND                     pDS;
00327     LPDIRECTSOUND8                    pDS8;
00328     LPDIRECTSOUNDCAPTURE              pDSC;
00329 };
00330 
00331 /*****************************************************************************
00332  * IDirectSoundFullDuplex COM components
00333  */
00334 struct IDirectSoundFullDuplex_IUnknown {
00335     const IUnknownVtbl         *lpVtbl;
00336     LONG                        ref;
00337     IDirectSoundFullDuplexImpl *pdsfd;
00338 };
00339 
00340 struct IDirectSoundFullDuplex_IDirectSound {
00341     const IDirectSoundVtbl     *lpVtbl;
00342     LONG                        ref;
00343     IDirectSoundFullDuplexImpl *pdsfd;
00344 };
00345 
00346 struct IDirectSoundFullDuplex_IDirectSound8 {
00347     const IDirectSound8Vtbl    *lpVtbl;
00348     LONG                        ref;
00349     IDirectSoundFullDuplexImpl *pdsfd;
00350 };
00351 
00352 struct IDirectSoundFullDuplex_IDirectSoundCapture {
00353     const IDirectSoundCaptureVtbl *lpVtbl;
00354     LONG                           ref;
00355     IDirectSoundFullDuplexImpl    *pdsfd;
00356 };
00357 
00358 /*****************************************************************************
00359  *  IDirectSound3DListener implementation structure
00360  */
00361 struct IDirectSound3DListenerImpl
00362 {
00363     /* IUnknown fields */
00364     const IDirectSound3DListenerVtbl *lpVtbl;
00365     LONG                        ref;
00366     /* IDirectSound3DListenerImpl fields */
00367     DirectSoundDevice*          device;
00368 };
00369 
00370 HRESULT IDirectSound3DListenerImpl_Create(
00371     DirectSoundDevice           *device,
00372     IDirectSound3DListenerImpl **pdsl);
00373 
00374 /*****************************************************************************
00375  *  IKsBufferPropertySet implementation structure
00376  */
00377 struct IKsBufferPropertySetImpl
00378 {
00379     /* IUnknown fields */
00380     const IKsPropertySetVtbl   *lpVtbl;
00381     LONG            ref;
00382     /* IKsPropertySetImpl fields */
00383     IDirectSoundBufferImpl* dsb;
00384 };
00385 
00386 HRESULT IKsBufferPropertySetImpl_Create(
00387     IDirectSoundBufferImpl *dsb,
00388     IKsBufferPropertySetImpl **piks);
00389 HRESULT IKsBufferPropertySetImpl_Destroy(
00390     IKsBufferPropertySetImpl *piks);
00391 
00392 /*****************************************************************************
00393  *  IKsPrivatePropertySet implementation structure
00394  */
00395 struct IKsPrivatePropertySetImpl
00396 {
00397     /* IUnknown fields */
00398     const IKsPropertySetVtbl   *lpVtbl;
00399     LONG            ref;
00400 };
00401 
00402 HRESULT IKsPrivatePropertySetImpl_Create(
00403     REFIID riid,
00404     IKsPrivatePropertySetImpl **piks);
00405 
00406 /*****************************************************************************
00407  * IDirectSound3DBuffer implementation structure
00408  */
00409 struct IDirectSound3DBufferImpl
00410 {
00411     /* IUnknown fields */
00412     const IDirectSound3DBufferVtbl *lpVtbl;
00413     LONG                        ref;
00414     /* IDirectSound3DBufferImpl fields */
00415     IDirectSoundBufferImpl*     dsb;
00416 };
00417 
00418 HRESULT IDirectSound3DBufferImpl_Create(
00419     IDirectSoundBufferImpl *dsb,
00420     IDirectSound3DBufferImpl **pds3db);
00421 HRESULT IDirectSound3DBufferImpl_Destroy(
00422     IDirectSound3DBufferImpl *pds3db);
00423 
00424 /*******************************************************************************
00425  */
00426 
00427 /* dsound.c */
00428 
00429 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS);
00430 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
00431 
00432 /* primary.c */
00433 
00434 DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign);
00435 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
00436 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
00437 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
00438 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
00439 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
00440 HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex, BOOL forced);
00441 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave);
00442 
00443 /* duplex.c */
00444  
00445 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD);
00446 
00447 /* mixer.c */
00448 DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos);
00449 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len);
00450 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
00451 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
00452 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
00453 void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer);
00454 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot);
00455 
00456 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
00457 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
00458 
00459 /* sound3d.c */
00460 
00461 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
00462 
00463 /* capture.c */
00464  
00465 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC);
00466 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
00467 HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
00468     LPDIRECTSOUNDCAPTURE iface,
00469     LPCDSCBUFFERDESC lpcDSCBufferDesc,
00470     LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
00471     LPUNKNOWN pUnk);
00472 HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
00473     LPDIRECTSOUNDCAPTURE iface,
00474     LPDSCCAPS lpDSCCaps);
00475 HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
00476     LPDIRECTSOUNDCAPTURE iface,
00477     LPCGUID lpcGUID);
00478 
00479 #define STATE_STOPPED   0
00480 #define STATE_STARTING  1
00481 #define STATE_PLAYING   2
00482 #define STATE_CAPTURING 2
00483 #define STATE_STOPPING  3
00484 
00485 #define DSOUND_FREQSHIFT (20)
00486 
00487 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
00488 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
00489 
00490 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
00491 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
00492 
00493 HRESULT mmErr(UINT err);
00494 void setup_dsound_options(void);
00495 const char * dumpCooperativeLevel(DWORD level);

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.