fixed AV::Sound::load's temporary FileLoader::Buffer being destroyed

git-svn-id: svn://anubis/anaglym/trunk@282 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2010-06-22 03:13:19 +00:00
parent a7ce3ff6b9
commit f782e5dc77
2 changed files with 8 additions and 6 deletions

13
AV.cc
View File

@ -141,7 +141,7 @@ void AV::playSound(AV::Sound * s)
void AV::playCallback(Uint8 * stream, int len)
{
memset(stream, 0, len);
for (std::set<Sound *>::const_iterator it = m_active_sounds.begin();
for (std::set<Sound *>::iterator it = m_active_sounds.begin();
it != m_active_sounds.end();
it++)
{
@ -157,7 +157,8 @@ void AV::playCallback(Uint8 * stream, int len)
}
AV::Sound::Sound(AV & av)
: m_av(av)
: m_av(av),
m_buff(1)
{
m_rwops = NULL;
m_ss = NULL;
@ -173,12 +174,12 @@ AV::Sound::~Sound()
bool AV::Sound::load(FileLoader & fileLoader, const FileLoader::Path & path)
{
FileLoader::Buffer buff = fileLoader.load(path);
if (buff.size > 0)
m_buff = fileLoader.load(path);
if (m_buff.size > 0)
{
m_rwops = SDL_RWFromMem(buff.data, buff.size);
m_rwops = SDL_RWFromMem(m_buff.data, m_buff.size);
Sound_AudioInfo desired;
desired.channels = 2;
desired.channels = CHANNELS;
desired.format = AUDIO_S16SYS;
desired.rate = SOUND_RATE;
m_ss = Sound_NewSample(m_rwops, NULL, &desired,

1
AV.h
View File

@ -28,6 +28,7 @@ class AV
AV & m_av;
SDL_RWops * m_rwops;
Sound_Sample * m_ss;
FileLoader::Buffer m_buff;
};
AV();