Performance improvement on loading OGG samples to memory

This commit is contained in:
Joshua Granick
2013-12-13 18:36:35 -08:00
parent d2b0e20175
commit 8be4a99ed4

View File

@@ -201,7 +201,7 @@ namespace lime
//Get the file information //Get the file information
//vorbis data //vorbis data
vorbis_info *pInfo = ov_info(&oggFile, -1); vorbis_info *pInfo = ov_info(&oggFile, -1);
//Make sure this is a valid file //Make sure this is a valid file
if (pInfo == NULL) if (pInfo == NULL)
{ {
@@ -212,7 +212,7 @@ namespace lime
//The number of channels //The number of channels
*channels = pInfo->channels; *channels = pInfo->channels;
//default to 16? todo //default to 16? todo
*bitsPerSample = 16; *bitsPerSample = 16;
//Return the same rate as well //Return the same rate as well
*outSampleRate = pInfo->rate; *outSampleRate = pInfo->rate;
@@ -220,11 +220,13 @@ namespace lime
{ {
// Read up to a buffer's worth of decoded sound data // Read up to a buffer's worth of decoded sound data
bytes = ov_read(&oggFile, array, BUFFER_SIZE, endian, 2, 1, &bitStream); bytes = ov_read(&oggFile, array, BUFFER_SIZE, endian, 2, 1, &bitStream);
// Append to end of buffer if (bytes)
outBuffer.InsertAt(outBuffer.size(), (unsigned char*)array, bytes); {
outBuffer.Set((unsigned char*)array, bytes);
}
} }
ov_clear(&oggFile); ov_clear(&oggFile);
#undef BUFFER_SIZE #undef BUFFER_SIZE