OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/android/build_info.h" | 5 #include "base/android/build_info.h" |
6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 base::FilePath file_path = GetTestDataFilePath(name); | 170 base::FilePath file_path = GetTestDataFilePath(name); |
171 DVLOG(0) << "Reading from file: " << file_path.value().c_str(); | 171 DVLOG(0) << "Reading from file: " << file_path.value().c_str(); |
172 } | 172 } |
173 | 173 |
174 ~FileAudioSource() override {} | 174 ~FileAudioSource() override {} |
175 | 175 |
176 // AudioOutputStream::AudioSourceCallback implementation. | 176 // AudioOutputStream::AudioSourceCallback implementation. |
177 | 177 |
178 // Use samples read from a data file and fill up the audio buffer | 178 // Use samples read from a data file and fill up the audio buffer |
179 // provided to us in the callback. | 179 // provided to us in the callback. |
180 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override { | 180 int OnMoreData(AudioBus* audio_bus, |
| 181 uint32_t total_bytes_delay, |
| 182 uint32_t frames_skipped) override { |
181 bool stop_playing = false; | 183 bool stop_playing = false; |
182 int max_size = | 184 int max_size = |
183 audio_bus->frames() * audio_bus->channels() * kBytesPerSample; | 185 audio_bus->frames() * audio_bus->channels() * kBytesPerSample; |
184 | 186 |
185 // Adjust data size and prepare for end signal if file has ended. | 187 // Adjust data size and prepare for end signal if file has ended. |
186 if (pos_ + max_size > file_size()) { | 188 if (pos_ + max_size > file_size()) { |
187 stop_playing = true; | 189 stop_playing = true; |
188 max_size = file_size() - pos_; | 190 max_size = file_size() - pos_; |
189 } | 191 } |
190 | 192 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // was exceeded. Flush the FIFO when extended just in case. | 347 // was exceeded. Flush the FIFO when extended just in case. |
346 if (!fifo_->Append((const uint8*)interleaved.get(), size)) { | 348 if (!fifo_->Append((const uint8*)interleaved.get(), size)) { |
347 fifo_->set_forward_capacity(2 * fifo_->forward_capacity()); | 349 fifo_->set_forward_capacity(2 * fifo_->forward_capacity()); |
348 fifo_->Clear(); | 350 fifo_->Clear(); |
349 } | 351 } |
350 } | 352 } |
351 | 353 |
352 void OnError(AudioInputStream* stream) override {} | 354 void OnError(AudioInputStream* stream) override {} |
353 | 355 |
354 // AudioOutputStream::AudioSourceCallback implementation | 356 // AudioOutputStream::AudioSourceCallback implementation |
355 int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) override { | 357 int OnMoreData(AudioBus* dest, |
| 358 uint32_t total_bytes_delay, |
| 359 uint32_t frames_skipped) override { |
356 const int size_in_bytes = | 360 const int size_in_bytes = |
357 (params_.bits_per_sample() / 8) * dest->frames() * dest->channels(); | 361 (params_.bits_per_sample() / 8) * dest->frames() * dest->channels(); |
358 EXPECT_EQ(size_in_bytes, params_.GetBytesPerBuffer()); | 362 EXPECT_EQ(size_in_bytes, params_.GetBytesPerBuffer()); |
359 | 363 |
360 base::AutoLock lock(lock_); | 364 base::AutoLock lock(lock_); |
361 | 365 |
362 // We add an initial delay of ~1 second before loopback starts to ensure | 366 // We add an initial delay of ~1 second before loopback starts to ensure |
363 // a stable callback sequences and to avoid initial bursts which might add | 367 // a stable callback sequences and to avoid initial bursts which might add |
364 // to the extra FIFO delay. | 368 // to the extra FIFO delay. |
365 if (!started_) { | 369 if (!started_) { |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 949 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
946 printf("\n"); | 950 printf("\n"); |
947 StopAndCloseAudioOutputStreamOnAudioThread(); | 951 StopAndCloseAudioOutputStreamOnAudioThread(); |
948 StopAndCloseAudioInputStreamOnAudioThread(); | 952 StopAndCloseAudioInputStreamOnAudioThread(); |
949 } | 953 } |
950 | 954 |
951 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 955 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
952 testing::ValuesIn(RunAudioRecordInputPathTests())); | 956 testing::ValuesIn(RunAudioRecordInputPathTests())); |
953 | 957 |
954 } // namespace media | 958 } // namespace media |
OLD | NEW |