diff options
Diffstat (limited to 'media/base/audio_splicer.cc')
-rw-r--r-- | media/base/audio_splicer.cc | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/media/base/audio_splicer.cc b/media/base/audio_splicer.cc index b83765e..9fae417 100644 --- a/media/base/audio_splicer.cc +++ b/media/base/audio_splicer.cc @@ -35,20 +35,6 @@ static void AccurateTrimStart(int frames_to_trim, const AudioTimestampHelper& timestamp_helper) { buffer->TrimStart(frames_to_trim); buffer->set_timestamp(timestamp_helper.GetTimestamp()); - buffer->set_duration( - timestamp_helper.GetFrameDuration(buffer->frame_count())); -} - -// AudioBuffer::TrimEnd() is not as accurate as the timestamp helper, so -// manually adjust the duration after trimming. -static void AccurateTrimEnd(int frames_to_trim, - const scoped_refptr<AudioBuffer> buffer, - const AudioTimestampHelper& timestamp_helper) { - DCHECK_LT(std::abs(timestamp_helper.GetFramesToTarget(buffer->timestamp())), - kMinGapSize); - buffer->TrimEnd(frames_to_trim); - buffer->set_duration( - timestamp_helper.GetFrameDuration(buffer->frame_count())); } // Returns an AudioBus whose frame buffer is backed by the provided AudioBuffer. @@ -177,13 +163,12 @@ bool AudioStreamSanitizer::AddInput(const scoped_refptr<AudioBuffer>& input) { // Create a buffer with enough silence samples to fill the gap and // add it to the output buffer. - scoped_refptr<AudioBuffer> gap = AudioBuffer::CreateEmptyBuffer( - input->channel_layout(), - input->channel_count(), - input->sample_rate(), - frames_to_fill, - expected_timestamp, - output_timestamp_helper_.GetFrameDuration(frames_to_fill)); + scoped_refptr<AudioBuffer> gap = + AudioBuffer::CreateEmptyBuffer(input->channel_layout(), + input->channel_count(), + input->sample_rate(), + frames_to_fill, + expected_timestamp); AddOutputBuffer(gap); // Add the input buffer now that the gap has been filled. @@ -443,9 +428,7 @@ scoped_ptr<AudioBus> AudioSplicer::ExtractCrossfadeFromPreSplice( // If only part of the buffer was consumed, trim it appropriately and stick // it into the output queue. if (frames_before_splice) { - AccurateTrimEnd(preroll->frame_count() - frames_before_splice, - preroll, - output_ts_helper); + preroll->TrimEnd(preroll->frame_count() - frames_before_splice); CHECK(output_sanitizer_->AddInput(preroll)); frames_before_splice = 0; } @@ -466,8 +449,6 @@ void AudioSplicer::CrossfadePostSplice( const AudioTimestampHelper& output_ts_helper = output_sanitizer_->timestamp_helper(); crossfade_buffer->set_timestamp(output_ts_helper.GetTimestamp()); - crossfade_buffer->set_duration( - output_ts_helper.GetFrameDuration(pre_splice_bus->frames())); // AudioBuffer::ReadFrames() only allows output into an AudioBus, so wrap // our AudioBuffer in one so we can avoid extra data copies. |