www.pudn.com > DirectDraw.rar > DSoundCapture.h, change:2007-09-28,size:2053b


// DSoundCapture.h: interface for the CDSoundCapture class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_DSOUNDCAPTURE_H__EC1F41EB_1342_48FC_A762_6798D1BE8E4F__INCLUDED_) 
#define AFX_DSOUNDCAPTURE_H__EC1F41EB_1342_48FC_A762_6798D1BE8E4F__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#define NUM_REC_NOTIFICATIONS  25 
#define MAX(a,b)        ( (a) > (b) ? (a) : (b) ) 
 
#define SAFE_DELETE(p)  { if(p) { delete (p);     (p)=NULL; } } 
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } 
 
#include <mmsystem.h> 
#include <dsound.h> 
#ifdef _TESTREC 
#include "../WaveFile.h" 
#endif 
 
typedef void (CALLBACK *CapSoundCallback)(WAVEFORMATEX *pwfx,LPVOID pBuf,DWORD nBufSize,LPVOID pcontext); 
 
class CDSoundCapture   
{ 
public: 
	CDSoundCapture(GUID *pGuid = NULL); 
	virtual ~CDSoundCapture(); 
public: 
	BOOL SetAudioFormat(DWORD dwSamples,WORD wChannels = 1,WORD wBitsPerSample = 16); 
	BOOL StartCapture(CapSoundCallback pCallback,LPVOID	pcontext); 
	BOOL StopCapture(); 
 
	LPDIRECTSOUNDCAPTURE GetDSoundCap(){return m_pDSCapture;} 
	LPDIRECTSOUNDCAPTUREBUFFER GetDSoundCapBuffer(){return m_pDSCBuffer;} 
private: 
	static DWORD WINAPI CaptureSoundProc(LPVOID Para); 
	BOOL InitDirectSound(); 
	void FreeDirectSound(); 
	BOOL CreateCaptureBuffer(); 
	BOOL InitNotifications(); 
	BOOL ReadCapturedData(); 
	BOOL StartThread(); 
	void ReleaseThread(); 
	CapSoundCallback m_pCapCallback; 
	LPVOID	m_pCapCallbackcontext; 
#ifdef _TESTREC 
	CWaveFile *m_pWaveFile; 
#endif 
	WAVEFORMATEX m_wfx; 
	DWORD   m_dwCaptureBufferSize; 
	DWORD	m_dwNotifySize; 
	DWORD	m_dwNextCaptureOffset; 
	HANDLE	m_hNotificationEvent; 
	HANDLE	m_hThread; 
	BOOL	m_bThreadEnd; 
	LPDIRECTSOUNDCAPTURE		m_pDSCapture; 
	LPDIRECTSOUNDCAPTUREBUFFER	m_pDSCBuffer; 
	LPDIRECTSOUNDNOTIFY			m_pDSNotify; 
	DSBPOSITIONNOTIFY			m_DSBPosNotify[NUM_REC_NOTIFICATIONS+1]; 
	GUID	*m_pDevGuid; 
}; 
 
#endif // !defined(AFX_DSOUNDCAPTURE_H__EC1F41EB_1342_48FC_A762_6798D1BE8E4F__INCLUDED_)