Game Development Reference
In-Depth Information
platform-agnostic design, an audio buffer is created from a sound resource, presum-
ably something loaded from a file or more likely a resource file.
IAudioBuffer *DirectSoundAudio::VInitAudioBuffer(shared_ptr<ResHandle> resHandle)
{
shared_ptr<SoundResourceExtraData> extra =
::static_pointer_cast<SoundResourceExtraData>(resHandle->GetExtra());
if( ! m_pDS )
return NULL;
switch(soundResource->GetSoundType())
{
case SOUND_TYPE_OGG:
case SOUND_TYPE_WAVE:
// We support WAVs and OGGs
break;
case SOUND_TYPE_MP3:
case SOUND_TYPE_MIDI:
// If it
s a midi file, then do nothing at this time...
// maybe we will support this in the future
GCC_ERROR(
'
MP3s and MIDI are not supported
);
return NULL;
break;
default:
GCC_ERROR(
Unknown sound type
);
return NULL;
}
LPDIRECTSOUNDBUFFER sampleHandle;
// Create the direct sound buffer, and only request the flags needed
// since each requires some overhead and limits if the buffer can
// be hardware accelerated
DSBUFFERDESC dsbd;
ZeroMemory( &dsbd, sizeof(DSBUFFERDESC) );
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_CTRLVOLUME;
dsbd.dwBufferBytes = resHandle->Size();
dsbd.guid3DAlgorithm = GUID_NULL;
dsbd.lpwfxFormat
= const_cast<WAVEFORMATEX *>(extra->GetFormat());
HRESULT hr;
if( FAILED( hr = m_pDS->CreateSoundBuffer( &dsbd, &sampleHandle, NULL ) ) )
Search WWH ::




Custom Search