Bug 1271585 - Part 1 - Keep a buffer around instead of allocating for each packetizer packets for input data. r=jesup

This what was meant to happen, but it didn't work because `mInputBufferLen` was
never set. An nsTArray prevents this to happen.

MozReview-Commit-ID: PBFTluFcrs
This commit is contained in:
Paul Adenot 2016-05-30 15:24:17 +02:00
Родитель 12bffd32df
Коммит 209bdf8893
2 изменённых файлов: 5 добавлений и 11 удалений

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

@ -434,7 +434,7 @@ public:
, mSampleFrequency(MediaEngine::DEFAULT_SAMPLE_RATE)
, mPlayoutDelay(0)
, mNullTransport(nullptr)
, mInputBufferLen(0) {
{
MOZ_ASSERT(aVoiceEnginePtr);
MOZ_ASSERT(aAudioInput);
mDeviceName.Assign(NS_ConvertUTF8toUTF16(name));
@ -554,9 +554,7 @@ private:
NullTransport *mNullTransport;
// For full_duplex packetizer output
size_t mInputBufferLen;
UniquePtr<int16_t[]> mInputBuffer;
nsTArray<int16_t> mInputBuffer;
};
class MediaEngineWebRTC : public MediaEngine

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

@ -479,10 +479,10 @@ MediaEngineWebRTCMicrophoneSource::NotifyInputData(MediaStreamGraph* aGraph,
while (mPacketizer->PacketsAvailable()) {
uint32_t samplesPerPacket = mPacketizer->PacketSize() *
mPacketizer->Channels();
if (mInputBufferLen < samplesPerPacket) {
mInputBuffer = MakeUnique<int16_t[]>(samplesPerPacket);
if (mInputBuffer.Length() < samplesPerPacket) {
mInputBuffer.SetLength(samplesPerPacket);
}
int16_t *packet = mInputBuffer.get();
int16_t* packet = mInputBuffer.Elements();
mPacketizer->Output(packet);
mVoERender->ExternalRecordingInsertData(packet, samplesPerPacket, aRate, 0);
@ -516,10 +516,6 @@ do { \
} \
} while(0)
void
MediaEngineWebRTCMicrophoneSource::DeviceChanged() {
// Reset some processing