fix loadSound()
This commit is contained in:
parent
f78c42c8c8
commit
af88db267f
@ -631,21 +631,24 @@ int Engine::loadModel(const string & name, bool is_static, bool is_reference,
|
||||
|
||||
int Engine::loadSound(const string & name)
|
||||
{
|
||||
string nm = name;
|
||||
if (validatePath(nm))
|
||||
if (validatePath(name))
|
||||
{
|
||||
FileLoader::Path path("", nm);
|
||||
string nm = locateResource(name.c_str());
|
||||
|
||||
refptr<AV::Sound> avs = m_av.createSound();
|
||||
|
||||
if (avs->load(*m_fileLoader, path))
|
||||
unsigned int size;
|
||||
unsigned char *data = loadFile(nm.c_str(), &size);
|
||||
if (data != NULL)
|
||||
{
|
||||
return addSound(avs);
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "error loading sound '" << name << "'" << endl;
|
||||
if (avs->load(data, size))
|
||||
{
|
||||
/* TODO: memory leak, fix with buffer */
|
||||
return addSound(avs);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
cerr << "error loading sound '" << name << "'" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user