зеркало из https://github.com/mozilla/gecko-dev.git
Bug 849713 - Part 4: Refactor the logic for borrowing the output buffer from the input buffer; r=roc
This commit is contained in:
Родитель
72481e9809
Коммит
23fe293fd5
|
@ -74,6 +74,20 @@ public:
|
|||
mBuffer = aBuffer;
|
||||
}
|
||||
|
||||
void BorrowFromInputBuffer(AudioChunk* aOutput,
|
||||
uint32_t aChannels,
|
||||
uintptr_t aBufferOffset)
|
||||
{
|
||||
aOutput->mDuration = WEBAUDIO_BLOCK_SIZE;
|
||||
aOutput->mBuffer = mBuffer;
|
||||
aOutput->mChannelData.SetLength(aChannels);
|
||||
for (uint32_t i = 0; i < aChannels; ++i) {
|
||||
aOutput->mChannelData[i] = mBuffer->GetData(i) + aBufferOffset;
|
||||
}
|
||||
aOutput->mVolume = 1.0f;
|
||||
aOutput->mBufferFormat = AUDIO_FORMAT_FLOAT32;
|
||||
}
|
||||
|
||||
virtual void ProduceAudioBlock(AudioNodeStream* aStream,
|
||||
const AudioChunk& aInput,
|
||||
AudioChunk* aOutput,
|
||||
|
@ -106,15 +120,8 @@ public:
|
|||
if (currentPosition >= mStart &&
|
||||
currentPosition + WEBAUDIO_BLOCK_SIZE <= endTime) {
|
||||
// Data is entirely within the buffer. Avoid copying it.
|
||||
aOutput->mDuration = WEBAUDIO_BLOCK_SIZE;
|
||||
aOutput->mBuffer = mBuffer;
|
||||
aOutput->mChannelData.SetLength(channels);
|
||||
for (uint32_t i = 0; i < channels; ++i) {
|
||||
aOutput->mChannelData[i] =
|
||||
mBuffer->GetData(i) + uintptr_t(currentPosition - mStart + mOffset);
|
||||
}
|
||||
aOutput->mVolume = 1.0f;
|
||||
aOutput->mBufferFormat = AUDIO_FORMAT_FLOAT32;
|
||||
BorrowFromInputBuffer(aOutput, channels,
|
||||
uintptr_t(currentPosition - mStart + mOffset));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче