Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: media/base/audio_splicer.cc

Issue 220103002: Fix unit test failures with estimated durations and splice frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix removal of old buffers. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/audio_splicer.h" 5 #include "media/base/audio_splicer.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 26 matching lines...) Expand all
37 buffer->set_timestamp(timestamp_helper.GetTimestamp()); 37 buffer->set_timestamp(timestamp_helper.GetTimestamp());
38 buffer->set_duration( 38 buffer->set_duration(
39 timestamp_helper.GetFrameDuration(buffer->frame_count())); 39 timestamp_helper.GetFrameDuration(buffer->frame_count()));
40 } 40 }
41 41
42 // AudioBuffer::TrimEnd() is not as accurate as the timestamp helper, so 42 // AudioBuffer::TrimEnd() is not as accurate as the timestamp helper, so
43 // manually adjust the duration after trimming. 43 // manually adjust the duration after trimming.
44 static void AccurateTrimEnd(int frames_to_trim, 44 static void AccurateTrimEnd(int frames_to_trim,
45 const scoped_refptr<AudioBuffer> buffer, 45 const scoped_refptr<AudioBuffer> buffer,
46 const AudioTimestampHelper& timestamp_helper) { 46 const AudioTimestampHelper& timestamp_helper) {
47 DCHECK(buffer->timestamp() == timestamp_helper.GetTimestamp()); 47 DCHECK_LT(std::abs(timestamp_helper.GetFramesToTarget(buffer->timestamp())),
48 kMinGapSize);
48 buffer->TrimEnd(frames_to_trim); 49 buffer->TrimEnd(frames_to_trim);
49 buffer->set_duration( 50 buffer->set_duration(
50 timestamp_helper.GetFrameDuration(buffer->frame_count())); 51 timestamp_helper.GetFrameDuration(buffer->frame_count()));
51 } 52 }
52 53
53 // Returns an AudioBus whose frame buffer is backed by the provided AudioBuffer. 54 // Returns an AudioBus whose frame buffer is backed by the provided AudioBuffer.
54 static scoped_ptr<AudioBus> CreateAudioBufferWrapper( 55 static scoped_ptr<AudioBus> CreateAudioBufferWrapper(
55 const scoped_refptr<AudioBuffer>& buffer) { 56 const scoped_refptr<AudioBuffer>& buffer) {
56 scoped_ptr<AudioBus> wrapper = 57 scoped_ptr<AudioBus> wrapper =
57 AudioBus::CreateWrapper(buffer->channel_count()); 58 AudioBus::CreateWrapper(buffer->channel_count());
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 AccurateTrimStart(frames_to_trim, remainder, output_ts_helper); 511 AccurateTrimStart(frames_to_trim, remainder, output_ts_helper);
511 CHECK(output_sanitizer_->AddInput(remainder)); 512 CHECK(output_sanitizer_->AddInput(remainder));
512 } 513 }
513 514
514 // Transfer all remaining buffers out and reset once empty. 515 // Transfer all remaining buffers out and reset once empty.
515 CHECK(post_splice_sanitizer_->DrainInto(output_sanitizer_.get())); 516 CHECK(post_splice_sanitizer_->DrainInto(output_sanitizer_.get()));
516 post_splice_sanitizer_->Reset(); 517 post_splice_sanitizer_->Reset();
517 } 518 }
518 519
519 } // namespace media 520 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698