// WaveOutDev.h: interface for the CWaveOutDev class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WAVEOUTDEV_H__1B4452E4_62C7_11D2_BB3F_00805F9E3135__INCLUDED_)
#define AFX_WAVEOUTDEV_H__1B4452E4_62C7_11D2_BB3F_00805F9E3135__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

typedef CTypedPtrArray<CPtrArray, WAVEHDR*> CWaveHdrPtrArray;

class CWaveOutDev : public CObject  
{
public:
	CWaveOutDev();
	virtual ~CWaveOutDev();

   BOOL FindCompatibleDev();

   enum
   {
      WOD_OPEN_STATUS_SUCCESS = 0,
      WOD_OPEN_STATUS_IN_USE,
      WOD_OPEN_STATUS_ERROR,
   };

   BOOL Open(int * const peStatus =NULL, BOOL const fStereo =FALSE);
   void Close();

   BOOL Write(BYTE const * const pbData, DWORD const cbData);

   BOOL GetCaps(WAVEOUTCAPS & woCaps);
   CString GetName();

protected:
   UINT m_nId;
   HWAVEOUT m_hOut;
   WAVEOUTCAPS m_woCaps;

   WAVEFORMATEX m_wfxWaveFormat;

   CWinThread * m_pWorkerThread;

   CEvent m_evThereIsWorkToBeDone;
   CEvent m_evExitWorkerThread;

   CCriticalSection m_csPendingWaveHdrArray;
   CWaveHdrPtrArray m_apPendingWaveHdrs;

   friend UINT WorkerThreadFunction(LPVOID pParam);
};

#endif // !defined(AFX_WAVEOUTDEV_H__1B4452E4_62C7_11D2_BB3F_00805F9E3135__INCLUDED_)
