| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "media/base/audio_buffer.h" | 6 #include "media/base/audio_buffer.h" |
| 7 #include "media/base/audio_bus.h" | 7 #include "media/base/audio_bus.h" |
| 8 #include "media/base/audio_splicer.h" | 8 #include "media/base/audio_splicer.h" |
| 9 #include "media/base/audio_timestamp_helper.h" | 9 #include "media/base/audio_timestamp_helper.h" |
| 10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value) { | 33 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value) { |
| 34 return GetNextInputBuffer(value, kDefaultBufferSize); | 34 return GetNextInputBuffer(value, kDefaultBufferSize); |
| 35 } | 35 } |
| 36 | 36 |
| 37 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value, int frame_size) { | 37 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value, int frame_size) { |
| 38 scoped_refptr<AudioBuffer> buffer = MakeAudioBuffer<float>( | 38 scoped_refptr<AudioBuffer> buffer = MakeAudioBuffer<float>( |
| 39 kSampleFormat, | 39 kSampleFormat, |
| 40 kChannelLayout, | 40 kChannelLayout, |
| 41 kChannels, |
| 41 kDefaultSampleRate, | 42 kDefaultSampleRate, |
| 42 value, | 43 value, |
| 43 0.0f, | 44 0.0f, |
| 44 frame_size, | 45 frame_size, |
| 45 input_timestamp_helper_.GetTimestamp(), | 46 input_timestamp_helper_.GetTimestamp(), |
| 46 input_timestamp_helper_.GetFrameDuration(frame_size)); | 47 input_timestamp_helper_.GetFrameDuration(frame_size)); |
| 47 input_timestamp_helper_.AddFrames(frame_size); | 48 input_timestamp_helper_.AddFrames(frame_size); |
| 48 return buffer; | 49 return buffer; |
| 49 } | 50 } |
| 50 | 51 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 124 |
| 124 bool AddInput(const scoped_refptr<AudioBuffer>& input) { | 125 bool AddInput(const scoped_refptr<AudioBuffer>& input) { |
| 125 // Since the splicer doesn't make copies it's working directly on the input | 126 // Since the splicer doesn't make copies it's working directly on the input |
| 126 // buffers. We must make a copy before adding to ensure the original buffer | 127 // buffers. We must make a copy before adding to ensure the original buffer |
| 127 // is not modified in unexpected ways. | 128 // is not modified in unexpected ways. |
| 128 scoped_refptr<AudioBuffer> buffer_copy = | 129 scoped_refptr<AudioBuffer> buffer_copy = |
| 129 input->end_of_stream() | 130 input->end_of_stream() |
| 130 ? AudioBuffer::CreateEOSBuffer() | 131 ? AudioBuffer::CreateEOSBuffer() |
| 131 : AudioBuffer::CopyFrom(kSampleFormat, | 132 : AudioBuffer::CopyFrom(kSampleFormat, |
| 132 input->channel_layout(), | 133 input->channel_layout(), |
| 134 input->channel_count(), |
| 133 input->sample_rate(), | 135 input->sample_rate(), |
| 134 input->frame_count(), | 136 input->frame_count(), |
| 135 &input->channel_data()[0], | 137 &input->channel_data()[0], |
| 136 input->timestamp(), | 138 input->timestamp(), |
| 137 input->duration()); | 139 input->duration()); |
| 138 return splicer_.AddInput(buffer_copy); | 140 return splicer_.AddInput(buffer_copy); |
| 139 } | 141 } |
| 140 | 142 |
| 141 base::TimeDelta max_crossfade_duration() { | 143 base::TimeDelta max_crossfade_duration() { |
| 142 return splicer_.max_crossfade_duration_; | 144 return splicer_.max_crossfade_duration_; |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 // now available. | 623 // now available. |
| 622 EXPECT_TRUE(AddInput(second_buffer)); | 624 EXPECT_TRUE(AddInput(second_buffer)); |
| 623 ASSERT_TRUE(splicer_.HasNextBuffer()); | 625 ASSERT_TRUE(splicer_.HasNextBuffer()); |
| 624 | 626 |
| 625 VerifyNextBuffer(first_buffer); | 627 VerifyNextBuffer(first_buffer); |
| 626 VerifyNextBuffer(second_buffer); | 628 VerifyNextBuffer(second_buffer); |
| 627 EXPECT_FALSE(splicer_.HasNextBuffer()); | 629 EXPECT_FALSE(splicer_.HasNextBuffer()); |
| 628 } | 630 } |
| 629 | 631 |
| 630 } // namespace media | 632 } // namespace media |
| OLD | NEW |