dsound_wrapper.h

00001 #ifndef __DSOUND_WRAPPER_H
00002 #define __DSOUND_WRAPPER_H
00003 /*
00004  * $Id: dsound_wrapper.h 94 2003-05-13 10:54:17Z rene-cvs $
00005  * Simplified DirectSound interface.
00006  *
00007  * Author: Phil Burk & Robert Marsanyi
00008  *
00009  * For PortAudio Portable Real-Time Audio Library
00010  * For more information see: http://www.softsynth.com/portaudio/
00011  * DirectSound Implementation
00012  * Copyright (c) 1999-2000 Phil Burk & Robert Marsanyi
00013  *
00014  * Permission is hereby granted, free of charge, to any person obtaining
00015  * a copy of this software and associated documentation files
00016  * (the "Software"), to deal in the Software without restriction,
00017  * including without limitation the rights to use, copy, modify, merge,
00018  * publish, distribute, sublicense, and/or sell copies of the Software,
00019  * and to permit persons to whom the Software is furnished to do so,
00020  * subject to the following conditions:
00021  *
00022  * The above copyright notice and this permission notice shall be
00023  * included in all copies or substantial portions of the Software.
00024  *
00025  * Any person wishing to distribute modifications to the Software is
00026  * requested to send the modifications to the original developer so that
00027  * they can be incorporated into the canonical version.
00028  *
00029  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00030  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00031  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00032  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00033  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00034  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00035  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00036  *
00037  */
00038 #include <DSound.h>
00039 #if !defined(BOOL)
00040 #define BOOL short
00041 #endif
00042 #ifndef SUPPORT_AUDIO_CAPTURE
00043 #define SUPPORT_AUDIO_CAPTURE  (1)
00044 #endif
00045 
00046 #ifdef __cplusplus
00047 extern "C"
00048 {
00049 #endif /* __cplusplus */
00050 
00051 #define DSW_NUM_POSITIONS     (4)
00052 #define DSW_NUM_EVENTS        (5)
00053 #define DSW_TERMINATION_EVENT     (DSW_NUM_POSITIONS)
00054 
00055 typedef struct
00056 {
00057     /* Output */
00058     LPDIRECTSOUND        dsw_pDirectSound;
00059     LPDIRECTSOUNDBUFFER  dsw_OutputBuffer;
00060     DWORD                dsw_WriteOffset;     /* last write position */
00061     INT                  dsw_OutputSize;
00062     INT                  dsw_BytesPerFrame;
00063     /* Try to detect play buffer underflows. */
00064     LARGE_INTEGER        dsw_CounterTicksPerBuffer; /* counter ticks it should take to play a full buffer */
00065     LARGE_INTEGER        dsw_LastPlayTime;
00066     UINT                 dsw_LastPlayCursor;
00067     UINT                 dsw_OutputUnderflows;
00068     BOOL                 dsw_OutputRunning;
00069     /* use double which lets us can play for several thousand years with enough precision */
00070     double               dsw_FramesWritten;
00071     double               dsw_FramesPlayed;
00072 #if SUPPORT_AUDIO_CAPTURE
00073     /* Input */
00074     LPDIRECTSOUNDCAPTURE dsw_pDirectSoundCapture;
00075     LPDIRECTSOUNDCAPTUREBUFFER   dsw_InputBuffer;
00076     UINT                 dsw_ReadOffset;      /* last read position */
00077     UINT                 dsw_InputSize;
00078 #endif /* SUPPORT_AUDIO_CAPTURE */
00079 
00080 }
00081 DSoundWrapper;
00082 HRESULT DSW_Init( DSoundWrapper *dsw );
00083 void DSW_Term( DSoundWrapper *dsw );
00084 HRESULT DSW_InitOutputBuffer( DSoundWrapper *dsw, unsigned long nFrameRate,
00085                               int nChannels, int bufSize );
00086 HRESULT DSW_StartOutput( DSoundWrapper *dsw );
00087 HRESULT DSW_StopOutput( DSoundWrapper *dsw );
00088 DWORD   DSW_GetOutputStatus( DSoundWrapper *dsw );
00089 HRESULT DSW_WriteBlock( DSoundWrapper *dsw, char *buf, long numBytes );
00090 HRESULT DSW_ZeroEmptySpace( DSoundWrapper *dsw );
00091 HRESULT DSW_QueryOutputSpace( DSoundWrapper *dsw, long *bytesEmpty );
00092 HRESULT DSW_Enumerate( DSoundWrapper *dsw );
00093 
00094 #if SUPPORT_AUDIO_CAPTURE
00095 HRESULT DSW_InitInputBuffer( DSoundWrapper *dsw, unsigned long nFrameRate,
00096                              int nChannels, int bufSize );
00097 HRESULT DSW_StartInput( DSoundWrapper *dsw );
00098 HRESULT DSW_StopInput( DSoundWrapper *dsw );
00099 HRESULT DSW_ReadBlock( DSoundWrapper *dsw, char *buf, long numBytes );
00100 HRESULT DSW_QueryInputFilled( DSoundWrapper *dsw, long *bytesFilled );
00101 #endif /* SUPPORT_AUDIO_CAPTURE */
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif /* __cplusplus */
00106 #endif  /* __DSOUND_WRAPPER_H */

Generated on Mon Jun 5 10:20:43 2006 for Intelligence.kdevelop by  doxygen 1.4.6