Bug 960873: Part 7: Reduce apple mp3 MAX_AUDIO_FRAMES to minimize alloc slop. r=cpearce

This commit is contained in:
Ben Kelly 2014-02-04 23:10:43 -05:00
Родитель 13e6e8f7be
Коммит 41fc4101cf
1 изменённых файлов: 16 добавлений и 3 удалений

Просмотреть файл

@ -12,8 +12,12 @@
#define AUDIO_READ_BYTES 4096
// Maximum number of audio frames we will accept from the audio decoder in one
// go.
#define MAX_AUDIO_FRAMES 4096
// go. Carefully select this to work well with both the mp3 1152 max frames
// per block and power-of-2 allocation sizes. Since we must pre-allocate the
// buffer we cannot use AudioCompactor without paying for an additional
// allocation and copy. Therefore, choosing a value that divides exactly into
// 1152 is most memory efficient.
#define MAX_AUDIO_FRAMES 128
namespace mozilla {
@ -201,7 +205,8 @@ AppleMP3Reader::AudioSampleCallback(UInt32 aNumBytes,
LOGD("got %u bytes, %u packets\n", aNumBytes, aNumPackets);
// 1 frame per packet * num channels * 32-bit float
uint32_t decodedSize = MAX_AUDIO_FRAMES * mAudioChannels * 4;
uint32_t decodedSize = MAX_AUDIO_FRAMES * mAudioChannels *
sizeof(AudioDataValue);
// descriptions for _decompressed_ audio packets. ignored.
nsAutoArrayPtr<AudioStreamPacketDescription>
@ -238,6 +243,14 @@ AppleMP3Reader::AudioSampleCallback(UInt32 aNumBytes,
break;
}
// If we decoded zero frames then AudiOConverterFillComplexBuffer is out
// of data to provide. We drained its internal buffer completely on the
// last pass.
if (numFrames == 0 && rv == kNeedMoreData) {
LOGD("FillComplexBuffer out of data exactly\n");
break;
}
int64_t time = FramesToUsecs(mCurrentAudioFrame, mAudioSampleRate).value();
int64_t duration = FramesToUsecs(numFrames, mAudioSampleRate).value();