Bug 1021328: ensure no paths lose far-end audio chunks in getUserMedia r=mccr8

This commit is contained in:
Randell Jesup 2014-06-07 00:11:42 -04:00
parent 861dfcddf0
commit 95cb2ee7a0
2 changed files with 14 additions and 11 deletions

View File

@ -43,7 +43,7 @@ private:
uint32_t mChunkSize;
// chunking to 10ms support
nsAutoPtr<FarEndAudioChunk> mSaved;
FarEndAudioChunk *mSaved; // can't be nsAutoPtr since we need to use moz_free()
uint32_t mSamplesSaved;
};

View File

@ -54,6 +54,7 @@ AudioOutputObserver::AudioOutputObserver()
: mPlayoutFreq(0)
, mPlayoutChannels(0)
, mChunkSize(0)
, mSaved(nullptr)
, mSamplesSaved(0)
{
// Buffers of 10ms chunks
@ -69,8 +70,9 @@ void
AudioOutputObserver::Clear()
{
while (mPlayoutFifo->size() > 0) {
(void) mPlayoutFifo->Pop();
moz_free(mPlayoutFifo->Pop());
}
moz_free(mSaved);
mSaved = nullptr;
}
@ -154,7 +156,8 @@ AudioOutputObserver::InsertFarEnd(const AudioDataValue *aBuffer, uint32_t aSampl
// thread safety issues.
break;
} else {
mPlayoutFifo->Push((int8_t *) mSaved.forget()); // takes ownership
mPlayoutFifo->Push((int8_t *) mSaved); // takes ownership
mSaved = nullptr;
mSamplesSaved = 0;
}
}
@ -517,8 +520,7 @@ MediaEngineWebRTCAudioSource::Process(int channel,
if (!mStarted) {
mStarted = true;
while (gFarendObserver->Size() > 1) {
FarEndAudioChunk *buffer = gFarendObserver->Pop(); // only call if size() > 0
free(buffer);
moz_free(gFarendObserver->Pop()); // only call if size() > 0
}
}
@ -526,15 +528,16 @@ MediaEngineWebRTCAudioSource::Process(int channel,
FarEndAudioChunk *buffer = gFarendObserver->Pop(); // only call if size() > 0
if (buffer) {
int length = buffer->mSamples;
if (mVoERender->ExternalPlayoutData(buffer->mData,
gFarendObserver->PlayoutFrequency(),
gFarendObserver->PlayoutChannels(),
mPlayoutDelay,
length) == -1) {
int res = mVoERender->ExternalPlayoutData(buffer->mData,
gFarendObserver->PlayoutFrequency(),
gFarendObserver->PlayoutChannels(),
mPlayoutDelay,
length);
moz_free(buffer);
if (res == -1) {
return;
}
}
free(buffer);
}
#ifdef PR_LOGGING