mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 06:45:33 +00:00
Bug 641718 - Round nsWaveReader's buffered ranges times to usecs. r=kinetik
This commit is contained in:
parent
73310e4cd6
commit
db70e38a67
@ -231,6 +231,7 @@ _TEST_FILES += \
|
||||
r16000_u8_c1_list.wav \
|
||||
wavedata_u8.wav \
|
||||
wavedata_s16.wav \
|
||||
audio.wav \
|
||||
$(NULL)
|
||||
|
||||
# Other files
|
||||
|
BIN
content/media/test/audio.wav
Normal file
BIN
content/media/test/audio.wav
Normal file
Binary file not shown.
@ -214,6 +214,7 @@ var gErrorTests = [
|
||||
// These are files that have nontrivial duration and are useful for seeking within.
|
||||
var gSeekTests = [
|
||||
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
|
||||
{ name:"audio.wav", type:"audio/x-wav", duration:0.031247 },
|
||||
{ name:"seek.ogv", type:"video/ogg", duration:3.966 },
|
||||
{ name:"320x240.ogv", type:"video/ogg", duration:0.233 },
|
||||
{ name:"seek.webm", type:"video/webm", duration:3.966 },
|
||||
|
@ -273,6 +273,10 @@ nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTim
|
||||
return mDecoder->GetCurrentStream()->Seek(nsISeekableStream::NS_SEEK_SET, position);
|
||||
}
|
||||
|
||||
static double RoundToUsecs(double aSeconds) {
|
||||
return floor(aSeconds * USECS_PER_S) / USECS_PER_S;
|
||||
}
|
||||
|
||||
nsresult nsWaveReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
|
||||
{
|
||||
PRInt64 startOffset = mDecoder->GetCurrentStream()->GetNextCachedData(mWavePCMOffset);
|
||||
@ -282,8 +286,11 @@ nsresult nsWaveReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
|
||||
NS_ASSERTION(startOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
|
||||
NS_ASSERTION(endOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
|
||||
|
||||
aBuffered->Add(BytesToTime(startOffset - mWavePCMOffset),
|
||||
BytesToTime(endOffset - mWavePCMOffset));
|
||||
// We need to round the buffered ranges' times to microseconds so that they
|
||||
// have the same precision as the currentTime and duration attribute on
|
||||
// the media element.
|
||||
aBuffered->Add(RoundToUsecs(BytesToTime(startOffset - mWavePCMOffset)),
|
||||
RoundToUsecs(BytesToTime(endOffset - mWavePCMOffset)));
|
||||
startOffset = mDecoder->GetCurrentStream()->GetNextCachedData(endOffset);
|
||||
}
|
||||
return NS_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user