| OLD | NEW |
| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Transfer all buffers into |output|. Returns false if AddInput() on the | 94 // Transfer all buffers into |output|. Returns false if AddInput() on the |
| 95 // |output| sanitizer fails for any buffer removed from |this|. | 95 // |output| sanitizer fails for any buffer removed from |this|. |
| 96 bool DrainInto(AudioStreamSanitizer* output); | 96 bool DrainInto(AudioStreamSanitizer* output); |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 void AddOutputBuffer(const scoped_refptr<AudioBuffer>& buffer); | 99 void AddOutputBuffer(const scoped_refptr<AudioBuffer>& buffer); |
| 100 | 100 |
| 101 AudioTimestampHelper output_timestamp_helper_; | 101 AudioTimestampHelper output_timestamp_helper_; |
| 102 bool received_end_of_stream_; | 102 bool received_end_of_stream_ = false; |
| 103 | 103 |
| 104 typedef std::deque<scoped_refptr<AudioBuffer> > BufferQueue; | 104 typedef std::deque<scoped_refptr<AudioBuffer> > BufferQueue; |
| 105 BufferQueue output_buffers_; | 105 BufferQueue output_buffers_; |
| 106 | 106 |
| 107 scoped_refptr<MediaLog> media_log_; | 107 scoped_refptr<MediaLog> media_log_; |
| 108 | 108 |
| 109 // To prevent log spam, counts the number of audio gap or overlaps warned in | 109 // To prevent log spam, counts the number of audio gap or overlaps warned in |
| 110 // logs. | 110 // logs. |
| 111 int num_warning_logs_; | 111 int num_warning_logs_ = 0; |
| 112 | 112 |
| 113 DISALLOW_ASSIGN(AudioStreamSanitizer); | 113 DISALLOW_ASSIGN(AudioStreamSanitizer); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 AudioStreamSanitizer::AudioStreamSanitizer( | 116 AudioStreamSanitizer::AudioStreamSanitizer( |
| 117 int samples_per_second, | 117 int samples_per_second, |
| 118 const scoped_refptr<MediaLog>& media_log) | 118 const scoped_refptr<MediaLog>& media_log) |
| 119 : output_timestamp_helper_(samples_per_second), | 119 : output_timestamp_helper_(samples_per_second), media_log_(media_log) {} |
| 120 received_end_of_stream_(false), | |
| 121 media_log_(media_log), | |
| 122 num_warning_logs_(0) { | |
| 123 } | |
| 124 | 120 |
| 125 AudioStreamSanitizer::~AudioStreamSanitizer() {} | 121 AudioStreamSanitizer::~AudioStreamSanitizer() {} |
| 126 | 122 |
| 127 void AudioStreamSanitizer::Reset() { | 123 void AudioStreamSanitizer::Reset() { |
| 128 ResetTimestampState(0, kNoTimestamp()); | 124 ResetTimestampState(0, kNoTimestamp()); |
| 129 } | 125 } |
| 130 | 126 |
| 131 void AudioStreamSanitizer::ResetTimestampState(int64 frame_count, | 127 void AudioStreamSanitizer::ResetTimestampState(int64 frame_count, |
| 132 base::TimeDelta base_timestamp) { | 128 base::TimeDelta base_timestamp) { |
| 133 output_buffers_.clear(); | 129 output_buffers_.clear(); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 AccurateTrimStart(frames_to_trim, remainder, output_ts_helper); | 546 AccurateTrimStart(frames_to_trim, remainder, output_ts_helper); |
| 551 CHECK(output_sanitizer_->AddInput(remainder)); | 547 CHECK(output_sanitizer_->AddInput(remainder)); |
| 552 } | 548 } |
| 553 | 549 |
| 554 // Transfer all remaining buffers out and reset once empty. | 550 // Transfer all remaining buffers out and reset once empty. |
| 555 CHECK(post_splice_sanitizer_->DrainInto(output_sanitizer_.get())); | 551 CHECK(post_splice_sanitizer_->DrainInto(output_sanitizer_.get())); |
| 556 post_splice_sanitizer_->Reset(); | 552 post_splice_sanitizer_->Reset(); |
| 557 } | 553 } |
| 558 | 554 |
| 559 } // namespace media | 555 } // namespace media |
| OLD | NEW |