Bug 1028458 - Don't try to use a resampler when resampling segments to graph rate if we haven't instanciated one yet. r=karlt

--HG--
extra : rebase_source : 3b7696b3e89c1be0e338893578d81088f7182a3b
This commit is contained in:
Paul Adenot 2014-06-26 14:01:01 +02:00
parent 43ed36fc07
commit 54c2895226
5 changed files with 39 additions and 8 deletions

View File

@ -114,15 +114,13 @@ DownmixAndInterleave(const nsTArray<const void*>& aChannelData,
aDuration, aVolume, aOutputChannels, aOutput);
}
void AudioSegment::ResampleChunks(SpeexResamplerState* aResampler)
void AudioSegment::ResampleChunks(SpeexResamplerState* aResampler, uint32_t aInRate, uint32_t aOutRate)
{
uint32_t inRate, outRate;
if (mChunks.IsEmpty()) {
return;
}
speex_resampler_get_rate(aResampler, &inRate, &outRate);
MOZ_ASSERT(aResampler || IsNull(), "We can only be here without a resampler if this segment is null.");
AudioSampleFormat format = AUDIO_FORMAT_SILENCE;
for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
@ -137,10 +135,10 @@ void AudioSegment::ResampleChunks(SpeexResamplerState* aResampler)
// the chunks duration.
case AUDIO_FORMAT_SILENCE:
case AUDIO_FORMAT_FLOAT32:
Resample<float>(aResampler, inRate, outRate);
Resample<float>(aResampler, aInRate, aOutRate);
break;
case AUDIO_FORMAT_S16:
Resample<int16_t>(aResampler, inRate, outRate);
Resample<int16_t>(aResampler, aInRate, aOutRate);
break;
default:
MOZ_ASSERT(false);

View File

@ -225,7 +225,9 @@ public:
}
}
void ResampleChunks(SpeexResamplerState* aResampler);
void ResampleChunks(SpeexResamplerState* aResampler,
uint32_t aInRate,
uint32_t aOutRate);
void AppendFrames(already_AddRefed<ThreadSharedObject> aBuffer,
const nsTArray<const float*>& aChannelData,
@ -287,6 +289,15 @@ public:
return 0;
}
bool IsNull() {
for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
if (!ci->IsNull()) {
return false;
}
}
return true;
}
static Type StaticType() { return AUDIO; }
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE

View File

@ -2296,7 +2296,7 @@ SourceMediaStream::ResampleAudioToGraphSampleRate(TrackData* aTrackData, MediaSe
#endif
}
}
segment->ResampleChunks(aTrackData->mResampler);
segment->ResampleChunks(aTrackData->mResampler, aTrackData->mInputRate, GraphImpl()->AudioSampleRate());
}
bool

View File

@ -0,0 +1,21 @@
<html class="reftest-wait">
<audio id="testAudio" controls></audio>
<script type="text/javascript">
navigator.mozGetUserMedia({audio: true}, function(stream) {
stream.getAudioTracks()[0].enabled = false;
var testAudio = document.getElementById('testAudio');
// Wait some time for good measure
var eventReceived = 0;
testAudio.addEventListener("timeupdate", function() {
if (++eventReceived == 3) {
document.querySelector("html").className = "";
}
})
testAudio.mozSrcObject = stream;
testAudio.play();
}, function(err) {
console.log(err);
});
</script>
</html>

View File

@ -72,3 +72,4 @@ skip-if(B2G) load oscillator-ended-1.html # intermittent B2G timeouts, bug 92033
skip-if(B2G) load oscillator-ended-2.html # intermittent B2G timeouts, bug 920338
load 1015662.html
include ../../mediasource/test/crashtests/crashtests.list
test-pref(media.navigator.permission.disabled,true) load 1028458.html