mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6201 from iSevenDays/patch-6
Fix potential memory leak in SimpleAudioEngine::preloadEffect
This commit is contained in:
commit
a2fcc79ad0
|
@ -462,7 +462,7 @@ void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||||
{
|
{
|
||||||
ALuint buffer = AL_NONE;
|
ALuint buffer = AL_NONE;
|
||||||
ALuint source = AL_NONE;
|
ALuint source = AL_NONE;
|
||||||
soundData *data = new soundData;
|
|
||||||
|
|
||||||
checkALError("preloadEffect:init");
|
checkALError("preloadEffect:init");
|
||||||
OpenALFile file;
|
OpenALFile file;
|
||||||
|
@ -472,7 +472,7 @@ void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||||
fprintf(stderr, "Cannot read file: '%s'\n", fullPath.data());
|
fprintf(stderr, "Cannot read file: '%s'\n", fullPath.data());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
const std::vector<OpenALDecoder *> &decoders = OpenALDecoder::getDecoders();
|
const std::vector<OpenALDecoder *> &decoders = OpenALDecoder::getDecoders();
|
||||||
for (size_t i = 0, n = decoders.size(); !success && i < n; ++i)
|
for (size_t i = 0, n = decoders.size(); !success && i < n; ++i)
|
||||||
|
@ -489,7 +489,8 @@ void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||||
|
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, buffer);
|
||||||
checkALError("preloadEffect:alSourcei");
|
checkALError("preloadEffect:alSourcei");
|
||||||
|
|
||||||
|
soundData *data = new soundData;
|
||||||
data->isLooped = false;
|
data->isLooped = false;
|
||||||
data->buffer = buffer;
|
data->buffer = buffer;
|
||||||
data->source = source;
|
data->source = source;
|
||||||
|
|
Loading…
Reference in New Issue