forked from mirrors/gecko-dev
Bug 1404997 - P23. Strongly enforced that our destination buffer is big enough. r=padenot
MozReview-Commit-ID: A1kLsH75SzX --HG-- extra : rebase_source : bcc4460507638ef36986ad519e48ba2d4596f4cf
This commit is contained in:
parent
485b10a8b0
commit
1769747959
3 changed files with 10 additions and 9 deletions
|
|
@ -715,7 +715,6 @@ WebrtcAudioConduit::GetAudioFrame(int16_t speechData[],
|
|||
{
|
||||
|
||||
CSFLogDebug(LOGTAG, "%s ", __FUNCTION__);
|
||||
unsigned int numSamples = 0;
|
||||
|
||||
//validate params
|
||||
if(!speechData )
|
||||
|
|
@ -726,7 +725,7 @@ WebrtcAudioConduit::GetAudioFrame(int16_t speechData[],
|
|||
}
|
||||
|
||||
// Validate sample length
|
||||
if((numSamples = GetNum10msSamplesForFrequency(samplingFreqHz)) == 0 )
|
||||
if(GetNum10msSamplesForFrequency(samplingFreqHz) == 0)
|
||||
{
|
||||
CSFLogError(LOGTAG,"%s Invalid Sampling Frequency ", __FUNCTION__);
|
||||
MOZ_ASSERT(PR_FALSE);
|
||||
|
|
@ -749,7 +748,7 @@ WebrtcAudioConduit::GetAudioFrame(int16_t speechData[],
|
|||
return kMediaConduitSessionNotInited;
|
||||
}
|
||||
|
||||
|
||||
int lengthSamplesAllowed = lengthSamples;
|
||||
lengthSamples = 0; //output paramter
|
||||
|
||||
if (mPtrVoEXmedia->GetAudioFrame(mChannel,
|
||||
|
|
@ -766,8 +765,8 @@ WebrtcAudioConduit::GetAudioFrame(int16_t speechData[],
|
|||
|
||||
// XXX Annoying, have to copy to our buffers -- refactor?
|
||||
lengthSamples = mAudioFrame.samples_per_channel_ * mAudioFrame.num_channels_;
|
||||
PodCopy(speechData, mAudioFrame.data_,
|
||||
lengthSamples);
|
||||
MOZ_RELEASE_ASSERT(lengthSamples <= lengthSamplesAllowed);
|
||||
PodCopy(speechData, mAudioFrame.data_, lengthSamples);
|
||||
|
||||
// Not #ifdef DEBUG or on a log module so we can use it for about:webrtc/etc
|
||||
mSamples += lengthSamples;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ public:
|
|||
* @param speechData [in]: Pointer to a array to which a 10ms frame of audio will be copied
|
||||
* @param samplingFreqHz [in]: Frequency of the sampling for playback in Hertz (16000, 32000,..)
|
||||
* @param capture_delay [in]: Estimated Time between reading of the samples to rendering/playback
|
||||
* @param lengthSamples [in]: Contain maximum length of speechData array.
|
||||
* @param lengthSamples [out]: Will contain length of the audio frame in samples at return.
|
||||
Ex: A value of 160 implies 160 samples each of 16-bits was copied
|
||||
into speechData
|
||||
|
|
|
|||
|
|
@ -2221,9 +2221,11 @@ private:
|
|||
TrackTicks framesNeeded = aDesiredTime - mPlayedTicks;
|
||||
|
||||
while (framesNeeded >= 0) {
|
||||
int16_t scratchBuffer[AUDIO_SAMPLE_BUFFER_MAX_BYTES / sizeof(int16_t)];
|
||||
const int scratchBufferLength =
|
||||
AUDIO_SAMPLE_BUFFER_MAX_BYTES / sizeof(int16_t);
|
||||
int16_t scratchBuffer[scratchBufferLength];
|
||||
|
||||
int samplesLength;
|
||||
int samplesLength = scratchBufferLength;
|
||||
|
||||
// This fetches 10ms of data, either mono or stereo
|
||||
MediaConduitErrorCode err =
|
||||
|
|
@ -2248,8 +2250,7 @@ private:
|
|||
PodArrayZero(scratchBuffer);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(samplesLength * sizeof(uint16_t) <=
|
||||
AUDIO_SAMPLE_BUFFER_MAX_BYTES);
|
||||
MOZ_RELEASE_ASSERT(samplesLength <= scratchBufferLength);
|
||||
|
||||
CSFLogDebug(
|
||||
LOGTAG, "Audio conduit returned buffer of length %u", samplesLength);
|
||||
|
|
|
|||
Loading…
Reference in a new issue