
#ifndef _SoundBuffer_H_
#define _SoundBuffer_H_

#include "SoundObject.h"
#include "SoundGlobal.h"
#include "STL.h"

/////////////////////////////////////////////////////////////////////////////////////////
//

class CSoundBuffer : public ISoundObject
{
protected:
	IDirectSoundBuffer8 *	m_pDSBuffer8;
	IDirectSoundBuffer **	m_apDSBuffer;
	IDirectSound3DBuffer**	m_ap3DBuffer;
	ISoundFile *			m_pSoundFile;
    DWORD					m_dwDSBufferSize;
    DWORD					m_dwNumBuffers;

private:
	CSoundBuffer( const CSoundBuffer & );												//사용하지 못하도록 막아놨음.		
	CSoundBuffer & operator=( const CSoundBuffer & );

protected:
	bool					Restore( IDirectSoundBuffer* );
	void					FillBufferWithSound( IDirectSoundBuffer * );
	IDirectSound3DBuffer *	Get3DBufferInterface( DWORD dwIndex );
	int						GetFreeBuffer();

public:
	CSoundBuffer();
	CSoundBuffer( IDirectSound8 *, ISoundFile *, bool b3DSound, DWORD dwNumBuffers = 10 );
	CSoundBuffer( IDirectSound8 *, const char *, bool b3DSound, DWORD dwNumBuffers = 10 );
	virtual ~CSoundBuffer();

	virtual void	Create( IDirectSound8 *, ISoundFile *, bool b3DSound, DWORD dwNumBuffers = 10, DWORD dwAddFlag = 0 );
	virtual void	Create( IDirectSound8 *, const char *, bool b3DSound, DWORD dwNumBuffers = 10, DWORD dwAddFlag = 0 );
	virtual void	Destroy();
	virtual int		Play( bool bLoop );
	virtual void	Play( DWORD dwIndex, bool bLoop );
	virtual void	Stop( unsigned );
	virtual void	StopAll();
	virtual void	Reset( unsigned );
	virtual void	ResetAll();
	virtual HANDLE	GetEventNotify() { return 0; }
	virtual void	HandleNotification() {}
	virtual bool	IsAllPlaying();
	virtual bool	IsAllFree();
	virtual bool	IsPlaying( unsigned );
	
	virtual	DWORD	GetMemoryUse();	
	virtual	bool	IsSameFile( const char * );
	virtual	const char *	GetFilename();

	virtual eSndObjType	GetType()	{ return SNDOBJTYPE_SOUNDBUFFER; }

	void			SetPosition( DWORD dwIndex, D3DVALUE x, D3DVALUE y, D3DVALUE z );
	void			SetDistance( DWORD dwIndex, D3DVALUE minDistance, D3DVALUE maxDistance );
};

/////////////////////////////////////////////////////////////////////////////////////////

#endif