Bug 892492 - Fix automation on AudioBufferSourceNode.playbackRate. r=ehsan

This commit is contained in:
Paul Adenot 2013-07-12 11:23:21 +02:00
parent 5d8d3ba243
commit aacae3cd50
2 changed files with 13 additions and 13 deletions

View File

@ -70,6 +70,11 @@ public:
}
}
void SetSourceStream(AudioNodeStream* aSource)
{
mSource = aSource;
}
virtual void SetTimelineParameter(uint32_t aIndex,
const dom::AudioParamTimeline& aValue,
TrackRate aSampleRate) MOZ_OVERRIDE
@ -86,7 +91,7 @@ public:
speex_resampler_destroy(mResampler);
mResampler = nullptr;
}
WebAudioUtils::ConvertAudioParamToTicks(mPlaybackRateTimeline, nullptr, mDestination);
WebAudioUtils::ConvertAudioParamToTicks(mPlaybackRateTimeline, mSource, mDestination);
break;
default:
NS_ERROR("Bad AudioBufferSourceNodeEngine TimelineParameter");
@ -425,6 +430,7 @@ public:
float mPlaybackRate;
float mDopplerShift;
AudioNodeStream* mDestination;
AudioNodeStream* mSource;
AudioParamTimeline mPlaybackRateTimeline;
bool mLoop;
};
@ -444,9 +450,9 @@ AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* aContext)
, mStartCalled(false)
, mStopped(false)
{
mStream = aContext->Graph()->CreateAudioNodeStream(
new AudioBufferSourceNodeEngine(this, aContext->Destination()),
MediaStreamGraph::SOURCE_STREAM);
AudioBufferSourceNodeEngine* engine = new AudioBufferSourceNodeEngine(this, aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::SOURCE_STREAM);
engine->SetSourceStream(static_cast<AudioNodeStream*>(mStream.get()));
mStream->AddMainThreadListener(this);
}

View File

@ -19,15 +19,9 @@ struct ConvertTimeToTickHelper
static int64_t Convert(double aTime, void* aClosure)
{
ConvertTimeToTickHelper* This = static_cast<ConvertTimeToTickHelper*> (aClosure);
if (This->mSourceStream) {
MOZ_ASSERT(This->mSourceStream->SampleRate() == This->mDestinationStream->SampleRate());
return WebAudioUtils::ConvertDestinationStreamTimeToSourceStreamTime(
aTime, This->mSourceStream, This->mDestinationStream);
} else {
StreamTime streamTime = This->mDestinationStream->GetCurrentPosition();
TrackRate sampleRate = This->mDestinationStream->SampleRate();
return TimeToTicksRoundUp(sampleRate, streamTime + SecondsToMediaTime(aTime));
}
MOZ_ASSERT(This->mSourceStream->SampleRate() == This->mDestinationStream->SampleRate());
return WebAudioUtils::ConvertDestinationStreamTimeToSourceStreamTime(
aTime, This->mSourceStream, This->mDestinationStream);
}
};