зеркало из https://github.com/mozilla/gecko-dev.git
b=972678 move stream time methods from WebAudioUtils to AudioNodeStream r=padenot
Trying to clear up which stream parameter is which. --HG-- extra : transplant_source : D%94%23%60M%82%7E%D8%FF%8A%D3%C8%9F%25%D6%7E%EA%19%80%E9
This commit is contained in:
Родитель
a658447db2
Коммит
9d91e4723c
|
@ -60,9 +60,7 @@ void
|
|||
AudioNodeStream::SetStreamTimeParameterImpl(uint32_t aIndex, MediaStream* aRelativeToStream,
|
||||
double aStreamTime)
|
||||
{
|
||||
TrackTicks ticks =
|
||||
WebAudioUtils::ConvertDestinationStreamTimeToSourceStreamTime(
|
||||
aStreamTime, this, aRelativeToStream);
|
||||
TrackTicks ticks = TicksFromDestinationTime(aRelativeToStream, aStreamTime);
|
||||
mEngine->SetStreamTimeParameter(aIndex, ticks);
|
||||
}
|
||||
|
||||
|
@ -517,4 +515,26 @@ AudioNodeStream::FinishOutput()
|
|||
}
|
||||
}
|
||||
|
||||
TrackTicks
|
||||
AudioNodeStream::TicksFromDestinationTime(MediaStream* aDestination,
|
||||
double aSeconds)
|
||||
{
|
||||
StreamTime streamTime = std::max<MediaTime>(0, SecondsToMediaTime(aSeconds));
|
||||
GraphTime graphTime = aDestination->StreamTimeToGraphTime(streamTime);
|
||||
StreamTime thisStreamTime = GraphTimeToStreamTimeOptimistic(graphTime);
|
||||
TrackTicks ticks = TimeToTicksRoundUp(SampleRate(), thisStreamTime);
|
||||
return ticks;
|
||||
}
|
||||
|
||||
double
|
||||
AudioNodeStream::DestinationTimeFromTicks(AudioNodeStream* aDestination,
|
||||
TrackTicks aPosition)
|
||||
{
|
||||
MOZ_ASSERT(SampleRate() == aDestination->SampleRate());
|
||||
StreamTime sourceTime = TicksToTimeRoundDown(SampleRate(), aPosition);
|
||||
GraphTime graphTime = StreamTimeToGraphTime(sourceTime);
|
||||
StreamTime destinationTime = aDestination->GraphTimeToStreamTimeOptimistic(graphTime);
|
||||
return MediaTimeToSeconds(destinationTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -128,6 +128,19 @@ public:
|
|||
AudioNodeEngine* Engine() { return mEngine; }
|
||||
TrackRate SampleRate() const { return mSampleRate; }
|
||||
|
||||
/**
|
||||
* Convert a time in seconds on the destination stream to TrackTicks
|
||||
* on this stream.
|
||||
*/
|
||||
TrackTicks TicksFromDestinationTime(MediaStream* aDestination,
|
||||
double aSeconds);
|
||||
/**
|
||||
* Get the destination stream time in seconds corresponding to a position on
|
||||
* this stream.
|
||||
*/
|
||||
double DestinationTimeFromTicks(AudioNodeStream* aDestination,
|
||||
TrackTicks aPosition);
|
||||
|
||||
protected:
|
||||
void AdvanceOutputSegment();
|
||||
void FinishOutput();
|
||||
|
|
|
@ -314,10 +314,9 @@ private:
|
|||
// Add the delay caused by the main thread
|
||||
playbackTick += mSharedBuffers->DelaySoFar();
|
||||
// Compute the playback time in the coordinate system of the destination
|
||||
// FIXME: bug 970773
|
||||
double playbackTime =
|
||||
WebAudioUtils::StreamPositionToDestinationTime(playbackTick,
|
||||
mSource,
|
||||
mDestination);
|
||||
mSource->DestinationTimeFromTicks(mDestination, playbackTick);
|
||||
|
||||
class Command : public nsRunnable
|
||||
{
|
||||
|
|
|
@ -23,35 +23,11 @@ struct ConvertTimeToTickHelper
|
|||
{
|
||||
ConvertTimeToTickHelper* This = static_cast<ConvertTimeToTickHelper*> (aClosure);
|
||||
MOZ_ASSERT(This->mSourceStream->SampleRate() == This->mDestinationStream->SampleRate());
|
||||
return WebAudioUtils::ConvertDestinationStreamTimeToSourceStreamTime(
|
||||
aTime, This->mSourceStream, This->mDestinationStream);
|
||||
return This->mSourceStream->
|
||||
TicksFromDestinationTime(This->mDestinationStream, aTime);
|
||||
}
|
||||
};
|
||||
|
||||
TrackTicks
|
||||
WebAudioUtils::ConvertDestinationStreamTimeToSourceStreamTime(double aTime,
|
||||
AudioNodeStream* aSource,
|
||||
MediaStream* aDestination)
|
||||
{
|
||||
StreamTime streamTime = std::max<MediaTime>(0, SecondsToMediaTime(aTime));
|
||||
GraphTime graphTime = aDestination->StreamTimeToGraphTime(streamTime);
|
||||
StreamTime thisStreamTime = aSource->GraphTimeToStreamTimeOptimistic(graphTime);
|
||||
TrackTicks ticks = TimeToTicksRoundUp(aSource->SampleRate(), thisStreamTime);
|
||||
return ticks;
|
||||
}
|
||||
|
||||
double
|
||||
WebAudioUtils::StreamPositionToDestinationTime(TrackTicks aSourcePosition,
|
||||
AudioNodeStream* aSource,
|
||||
AudioNodeStream* aDestination)
|
||||
{
|
||||
MOZ_ASSERT(aSource->SampleRate() == aDestination->SampleRate());
|
||||
StreamTime sourceTime = TicksToTimeRoundDown(aSource->SampleRate(), aSourcePosition);
|
||||
GraphTime graphTime = aSource->StreamTimeToGraphTime(sourceTime);
|
||||
StreamTime destinationTime = aDestination->GraphTimeToStreamTimeOptimistic(graphTime);
|
||||
return MediaTimeToSeconds(destinationTime);
|
||||
}
|
||||
|
||||
void
|
||||
WebAudioUtils::ConvertAudioParamToTicks(AudioParamTimeline& aParam,
|
||||
AudioNodeStream* aSource,
|
||||
|
|
|
@ -50,15 +50,6 @@ struct WebAudioUtils {
|
|||
return 1.0 - std::exp(-1.0 / (aDuration * aSampleRate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a time in second relative to the destination stream to
|
||||
* TrackTicks relative to the source stream.
|
||||
*/
|
||||
static TrackTicks
|
||||
ConvertDestinationStreamTimeToSourceStreamTime(double aTime,
|
||||
AudioNodeStream* aSource,
|
||||
MediaStream* aDestination);
|
||||
|
||||
/**
|
||||
* Converts AudioParamTimeline floating point time values to tick values
|
||||
* with respect to a source and a destination AudioNodeStream.
|
||||
|
@ -114,14 +105,6 @@ struct WebAudioUtils {
|
|||
return aTime >= 0 && aTime <= (MEDIA_TIME_MAX >> MEDIA_TIME_FRAC_BITS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a stream position into the time coordinate of the destination
|
||||
* stream.
|
||||
*/
|
||||
static double StreamPositionToDestinationTime(TrackTicks aSourcePosition,
|
||||
AudioNodeStream* aSource,
|
||||
AudioNodeStream* aDestination);
|
||||
|
||||
/**
|
||||
* Converts a floating point value to an integral type in a safe and
|
||||
* platform agnostic way. The following program demonstrates the kinds
|
||||
|
|
Загрузка…
Ссылка в новой задаче