1 #include "FirstUiBuilder.h"
2 #include "UIDirectSoundSoundCanvas.h"
4 UIDirectSoundSoundCanvas::UIDirectSoundSoundCanvas()
10 hr
= DirectSoundCreate( 0, &mPlaybackDevice
, 0 );
13 UIDirectSoundSoundCanvas::~UIDirectSoundSoundCanvas()
15 for( UINamedSoundMap::iterator i
= mSoundMap
.begin(); i
!= mSoundMap
.end(); ++i
)
17 delete const_cast<char *>( i
->first
);
23 mPlaybackDevice
->Release();
26 void UIDirectSoundSoundCanvas::Play( const char *FileToPlay
)
28 static_cast<void> (FileToPlay
);
35 UINamedSoundMap::iterator CachedSound = mSoundMap.find( FileToPlay );
36 IDirectSoundBuffer *theSound;
38 if( CachedSound == mSoundMap.end() )
40 WAVEFORMATEX WaveFormat;
43 dsbd.dwSize = sizeof( dsbd );
45 dsbd.dwBufferBytes = 1000;
47 dsbd.lpwfxFormat = &WaveFormat;
48 dsbd.guid3DAlgorithm = GUID_NULL;
50 hr = mPlaybackDevice->CreateSoundBuffer( &dsbd, &theSound, 0 );
53 theSound = CachedSound->second;
55 theSound->SetCurrentPosition( 0 );
56 theSound->Play( 0, 0, 0 );