зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1277198
. Part 1 - add AudioClock::GetInputRate/GetOutputRate. r=kinetik.
MozReview-Commit-ID: HsaiSq83MtD --HG-- extra : rebase_source : d578e00f15300fbcf1cc41fb5242868a4b31b57d
This commit is contained in:
Родитель
48f3ea793d
Коммит
51c02cde54
|
@ -162,7 +162,7 @@ nsresult AudioStream::EnsureTimeStretcherInitializedUnlocked()
|
|||
mMonitor.AssertCurrentThreadOwns();
|
||||
if (!mTimeStretcher) {
|
||||
mTimeStretcher = soundtouch::createSoundTouchObj();
|
||||
mTimeStretcher->setSampleRate(mInRate);
|
||||
mTimeStretcher->setSampleRate(mAudioClock.GetInputRate());
|
||||
mTimeStretcher->setChannels(mOutChannels);
|
||||
mTimeStretcher->setPitch(1.0);
|
||||
}
|
||||
|
@ -188,7 +188,6 @@ nsresult AudioStream::SetPlaybackRate(double aPlaybackRate)
|
|||
}
|
||||
|
||||
mAudioClock.SetPlaybackRate(aPlaybackRate);
|
||||
mOutRate = mInRate / aPlaybackRate;
|
||||
|
||||
if (mAudioClock.GetPreservesPitch()) {
|
||||
mTimeStretcher->setTempo(aPlaybackRate);
|
||||
|
@ -503,8 +502,8 @@ AudioStream::GetPositionInFramesUnlocked()
|
|||
bool
|
||||
AudioStream::IsValidAudioFormat(Chunk* aChunk)
|
||||
{
|
||||
if (aChunk->Rate() != mInRate) {
|
||||
LOGW("mismatched sample %u, mInRate=%u", aChunk->Rate(), mInRate);
|
||||
if (aChunk->Rate() != mAudioClock.GetInputRate()) {
|
||||
LOGW("mismatched sample %u, mInRate=%u", aChunk->Rate(), mAudioClock.GetInputRate());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -559,8 +558,8 @@ AudioStream::GetTimeStretched(AudioBufferWriter& aWriter)
|
|||
return;
|
||||
}
|
||||
|
||||
double playbackRate = static_cast<double>(mInRate) / mOutRate;
|
||||
uint32_t toPopFrames = ceil(aWriter.Available() * playbackRate);
|
||||
uint32_t toPopFrames =
|
||||
ceil(aWriter.Available() * mAudioClock.GetPlaybackRate());
|
||||
|
||||
while (mTimeStretcher->numSamples() < aWriter.Available()) {
|
||||
UniquePtr<Chunk> c = mDataSource.PopFrames(toPopFrames);
|
||||
|
@ -605,7 +604,7 @@ AudioStream::DataCallback(void* aBuffer, long aFrames)
|
|||
// NOTE: wasapi (others?) can call us back *after* stop()/Shutdown() (mState == SHUTDOWN)
|
||||
// Bug 996162
|
||||
|
||||
if (mInRate == mOutRate) {
|
||||
if (mAudioClock.GetInputRate() == mAudioClock.GetOutputRate()) {
|
||||
GetUnprocessed(writer);
|
||||
} else {
|
||||
GetTimeStretched(writer);
|
||||
|
|
|
@ -72,6 +72,9 @@ public:
|
|||
// Called on the audio thread.
|
||||
bool GetPreservesPitch() const;
|
||||
|
||||
uint32_t GetInputRate() const { return mInRate; }
|
||||
uint32_t GetOutputRate() const { return mOutRate; }
|
||||
|
||||
private:
|
||||
// Output rate in Hz (characteristic of the playback rate)
|
||||
uint32_t mOutRate;
|
||||
|
|
Загрузка…
Ссылка в новой задаче