mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 14:30:43 +00:00
Bug 1149616 - Fix the calculation of slots count in Read/WriteBuffer. r=bechen
This commit is contained in:
parent
2143843975
commit
6f5a8818ad
@ -243,7 +243,10 @@ nsresult RtspTrackBuffer::ReadBuffer(uint8_t* aToBuffer, uint32_t aToBufferSize,
|
|||||||
aFrameSize = mBufferSlotData[mConsumerIdx].mLength;
|
aFrameSize = mBufferSlotData[mConsumerIdx].mLength;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint32_t slots = (mBufferSlotData[mConsumerIdx].mLength / mSlotSize) + 1;
|
uint32_t slots = mBufferSlotData[mConsumerIdx].mLength / mSlotSize;
|
||||||
|
if (mBufferSlotData[mConsumerIdx].mLength % mSlotSize > 0) {
|
||||||
|
slots++;
|
||||||
|
}
|
||||||
// we have data, copy to aToBuffer
|
// we have data, copy to aToBuffer
|
||||||
MOZ_ASSERT(mBufferSlotData[mConsumerIdx].mLength <=
|
MOZ_ASSERT(mBufferSlotData[mConsumerIdx].mLength <=
|
||||||
(int32_t)((BUFFER_SLOT_NUM - mConsumerIdx) * mSlotSize));
|
(int32_t)((BUFFER_SLOT_NUM - mConsumerIdx) * mSlotSize));
|
||||||
@ -335,13 +338,15 @@ void RtspTrackBuffer::WriteBuffer(const char *aFromBuffer, uint32_t aWriteCount,
|
|||||||
// The flag is true if the incoming data is larger than remainder free slots
|
// The flag is true if the incoming data is larger than remainder free slots
|
||||||
bool returnToHead = false;
|
bool returnToHead = false;
|
||||||
// Calculate how many slots the incoming data needed.
|
// Calculate how many slots the incoming data needed.
|
||||||
int32_t slots = 1;
|
int32_t slots = aWriteCount / mSlotSize;
|
||||||
|
if (aWriteCount % mSlotSize > 0) {
|
||||||
|
slots++;
|
||||||
|
}
|
||||||
int32_t i;
|
int32_t i;
|
||||||
RTSPMLOG("WriteBuffer mTrackIdx %d mProducerIdx %d mConsumerIdx %d",
|
RTSPMLOG("WriteBuffer mTrackIdx %d mProducerIdx %d mConsumerIdx %d",
|
||||||
mTrackIdx, mProducerIdx,mConsumerIdx);
|
mTrackIdx, mProducerIdx,mConsumerIdx);
|
||||||
if (aWriteCount > mSlotSize) {
|
if (aWriteCount > mSlotSize) {
|
||||||
isMultipleSlots = true;
|
isMultipleSlots = true;
|
||||||
slots = (aWriteCount / mSlotSize) + 1;
|
|
||||||
}
|
}
|
||||||
if (isMultipleSlots &&
|
if (isMultipleSlots &&
|
||||||
(aWriteCount > (BUFFER_SLOT_NUM - mProducerIdx) * mSlotSize)) {
|
(aWriteCount > (BUFFER_SLOT_NUM - mProducerIdx) * mSlotSize)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user