// WaveFileSouce.h: interface for the WaveFileSouce class. // ////////////////////////////////////////////////////////////////////// #ifndef AFX_WAVEFILESOURCE_H__79D1D906_37F1_4F0C_BE82_8B23848FE677__INCLUDED_ #define AFX_WAVEFILESOURCE_H__79D1D906_37F1_4F0C_BE82_8B23848FE677__INCLUDED_ #include "AudioSource.h" #include "Parameters.h" #include "EventSource.h" #include enum WaveFileSourceEvents { FILE_STARTED = 0, FILE_STOPPED = 1 }; class WaveFileSourceListener; class WaveFileSource : public AudioSource, public EventSource { class FireEventThreadParams { public: WaveFileSource *waveFileSource; int eventType; char waveFileName[1024]; }; public: WaveFileSource(); virtual ~WaveFileSource(); int SourceStarted(); int SourceStopped(); int SourceThreadStarted(HANDLE sourceThreadHandle, DWORD sourceThreadID); int SourceThreadStopped(HANDLE sourceThreadHandle, DWORD sourceThreadID); int OpenWaveFile(const char *inputFileName); int GetFormat(WAVEFORMATEX *wfx); int SetBufferDuration(int bufferDurationMillisec); int AddFilePlayListener(WaveFileSourceListener *waveFileSourceListener); int RemoveFilePlayListener(WaveFileSourceListener *waveFileSourceListener); int PlayInLoop(); int PlayOnce(); protected: virtual int GenerateData(AudioSample **ppAudioSample); virtual int SetTraceLevel(); private: int FireEvent(int eventType, char *waveFileName); int CloseMMIO(); static DWORD WINAPI FireEventThread(LPVOID param); private: char szFileName[128]; // filename of file to open HMMIO hmmio; // file handle for open file MMCKINFO mmckinfoParent; // parent chunk information MMCKINFO mmckinfoSubchunk; // subchunk information structure DWORD dwFmtSize; // size of "FMT" chunk DWORD dwDataSize; // size of "DATA" chunk WAVEFORMATEX *pFormat; // address of "FMT" chunk HPSTR lpData; // address of "DATA" chunk int bufferDuration; // duration of audio to put in each buffer bool bRunning; // whether the filter is running LONG dataStartPosition; // start file position of the data part (for looping playback) bool looping; // whether the file is to be played in a loop CRITICAL_SECTION filterMutex; // mutex for the filter }; class WaveFileSourceListener { public: virtual void FilePlayStarted(WaveFileSource *waveFileSource, char *waveFileName); virtual void FilePlayStopped(WaveFileSource *waveFileSource, char *waveFileName); }; #endif // !defined(AFX_WAVEFILESOUCE_H__79D1D906_37F1_4F0C_BE82_8B23848FE677__INCLUDED_)