Game Development Reference
In-Depth Information
The second piece of this platform-dependent puzzle is the implementation of the
DirectSoundAudioBuffer , which picks up and defines the remaining unimple-
mented virtual functions from the IAudioBuffer interface.
class DirectSoundAudioBuffer : public AudioBuffer
{
protected:
LPDIRECTSOUNDBUFFER m_Sample;
public:
DirectSoundAudioBuffer(
LPDIRECTSOUNDBUFFER sample,
shared_ptr<ResHandle> resource);
virtual void *VGet();
virtual bool VRestore();
virtual bool VPlay(int volume, bool looping);
virtual bool VPause();
virtual bool VStop();
virtual bool VResume();
virtual bool VTogglePause();
virtual bool VIsPlaying();
virtual void VSetVolume(int volume);
private:
HRESULT FillBufferWithSound( );
HRESULT RestoreBuffer( BOOL* pbWasRestored );
};
The methods in this class are pretty easy C++ wrappers around IDirectSound
Buffer8 . The exceptions are FillBufferWithSound() and RestoreBuffer().
DirectSoundAudioBuffer::DirectSoundAudioBuffer(
LPDIRECTSOUNDBUFFER sample,
shared_ptr<CSoundResource> resource)
: AudioBuffer(resource)
{
m_Sample = sample;
FillBufferWithSound();
}
void *DirectSoundAudioBuffer::VGet()
{
if (!VRestore())
return NULL;
Search WWH ::




Custom Search