void UpdateSampleRateIfNeeded(uint32_t aChannels)
  {
    float playbackRate;

    if (mPlaybackRateTimeline.HasSimpleValue()) {
      playbackRate = mPlaybackRateTimeline.GetValue();
    } else {
      playbackRate = mPlaybackRateTimeline.GetValueAtTime(mSource->GetCurrentPosition());
    }
    if (playbackRate <= 0 || playbackRate != playbackRate) {
      playbackRate = 1.0f;
    }

    int32_t outRate = ComputeFinalOutSampleRate(playbackRate);
    UpdateResampler(outRate, aChannels);
  }
  void UpdateSampleRateIfNeeded(uint32_t aChannels, StreamTime aStreamPosition)
  {
    float playbackRate;
    float detune;

    if (mPlaybackRateTimeline.HasSimpleValue()) {
      playbackRate = mPlaybackRateTimeline.GetValue();
    } else {
      playbackRate = mPlaybackRateTimeline.GetValueAtTime(aStreamPosition);
    }
    if (mDetuneTimeline.HasSimpleValue()) {
      detune = mDetuneTimeline.GetValue();
    } else {
      detune = mDetuneTimeline.GetValueAtTime(aStreamPosition);
    }
    if (playbackRate <= 0 || mozilla::IsNaN(playbackRate)) {
      playbackRate = 1.0f;
    }

    detune = std::min(std::max(-1200.f, detune), 1200.f);

    int32_t outRate = ComputeFinalOutSampleRate(playbackRate, detune);
    UpdateResampler(outRate, aChannels);
  }