Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.6 KiB

  1. #ifndef _WAVEDEV_H
  2. #define _WAVEDEV_H
  3. #include "WaveIo.h"
  4. class waveInDev
  5. {
  6. private:
  7. UINT m_devID;
  8. HWAVEIN m_hwi;
  9. BOOL m_bOpen; // is the device open ?
  10. WAVEFORMATEX m_waveFormat;
  11. BOOL m_fAllowMapper;
  12. HANDLE m_hEvent;
  13. public:
  14. waveInDev(UINT uDevId, HANDLE hEvent=NULL);
  15. ~waveInDev();
  16. MMRESULT Open(int hertz=8000, int bps=16);
  17. MMRESULT Reset();
  18. MMRESULT Close();
  19. MMRESULT PrepareHeader(WAVEHDR *pHdr);
  20. MMRESULT UnPrepareHeader(WAVEHDR *pHdr);
  21. MMRESULT Record(WAVEHDR *pHdr);
  22. void AllowMapper(BOOL fAllow);
  23. };
  24. // waveOutDev works in blocking/synchronous mode and
  25. // non-blocking async mode. If a window handle is passed
  26. // as the second argument to the contructor, then the window
  27. // will receive message from the waveOut device and the calls
  28. // are non-blocking. Otherwise, Play() and PlayFile are blocking.
  29. class waveOutDev
  30. {
  31. private:
  32. UINT m_devID;
  33. HWAVEOUT m_hwo;
  34. BOOL m_bOpen; // is the device open
  35. HANDLE m_hWnd;
  36. HANDLE m_hEvent;
  37. WAVEFORMATEX m_waveFormat;
  38. BOOL m_fAllowMapper;
  39. // playfile needs a temporary buffer
  40. char *m_pfBuffer;
  41. WAVEHDR m_waveHdr;
  42. int m_nBufferSize;
  43. TCHAR m_szPlayFile[150];
  44. WAVEFORMATEX m_PlayFileWf;
  45. BOOL m_fFileBufferValid;
  46. public:
  47. waveOutDev(UINT uDevID, HWND hwnd=NULL);
  48. ~waveOutDev();
  49. MMRESULT Open(int hertz=8000, int bps=16);
  50. MMRESULT Open(WAVEFORMATEX *pWaveFormat);
  51. MMRESULT Close();
  52. MMRESULT PrepareHeader(WAVEHDR *pWhdr, SHORT *shBuffer=NULL, int numSamples=0);
  53. MMRESULT Play(WAVEHDR *pWhdr);
  54. MMRESULT UnprepareHeader(WAVEHDR *pWhdr);
  55. MMRESULT PlayFile(LPCTSTR szFileName);
  56. void AllowMapper(BOOL fAllow);
  57. };
  58. #endif