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

Side by Side Diff: media/audio/android/audio_android_unittest.cc

Issue 481193003: Remove AudioBuffersState usage in Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix audio muter build buster. Created 6 years, 2 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 | « media/audio/alsa/alsa_output_unittest.cc ('k') | media/audio/android/opensles_output.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 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/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 << "), label: " << it->device_name; 116 << "), label: " << it->device_name;
117 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), 117 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName),
118 it->device_name); 118 it->device_name);
119 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), 119 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId),
120 it->unique_id); 120 it->unique_id);
121 ++it; 121 ++it;
122 } 122 }
123 } 123 }
124 124
125 // We clear the data bus to ensure that the test does not cause noise. 125 // We clear the data bus to ensure that the test does not cause noise.
126 static int RealOnMoreData(AudioBus* dest, AudioBuffersState buffers_state) { 126 static int RealOnMoreData(AudioBus* dest, uint32 total_bytes_delay) {
127 dest->Zero(); 127 dest->Zero();
128 return dest->frames(); 128 return dest->frames();
129 } 129 }
130 130
131 std::ostream& operator<<(std::ostream& os, const AudioParameters& params) { 131 std::ostream& operator<<(std::ostream& os, const AudioParameters& params) {
132 using namespace std; 132 using namespace std;
133 os << endl << "format: " << FormatToString(params.format()) << endl 133 os << endl << "format: " << FormatToString(params.format()) << endl
134 << "channel layout: " << LayoutToString(params.channel_layout()) << endl 134 << "channel layout: " << LayoutToString(params.channel_layout()) << endl
135 << "sample rate: " << params.sample_rate() << endl 135 << "sample rate: " << params.sample_rate() << endl
136 << "bits per sample: " << params.bits_per_sample() << endl 136 << "bits per sample: " << params.bits_per_sample() << endl
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 VLOG(0) << "Reading from file: " << file_path.value().c_str(); 171 VLOG(0) << "Reading from file: " << file_path.value().c_str();
172 } 172 }
173 173
174 virtual ~FileAudioSource() {} 174 virtual ~FileAudioSource() {}
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 virtual int OnMoreData(AudioBus* audio_bus, 180 virtual int OnMoreData(AudioBus* audio_bus,
181 AudioBuffersState buffers_state) OVERRIDE { 181 uint32 total_bytes_delay) OVERRIDE {
182 bool stop_playing = false; 182 bool stop_playing = false;
183 int max_size = 183 int max_size =
184 audio_bus->frames() * audio_bus->channels() * kBytesPerSample; 184 audio_bus->frames() * audio_bus->channels() * kBytesPerSample;
185 185
186 // Adjust data size and prepare for end signal if file has ended. 186 // Adjust data size and prepare for end signal if file has ended.
187 if (pos_ + max_size > file_size()) { 187 if (pos_ + max_size > file_size()) {
188 stop_playing = true; 188 stop_playing = true;
189 max_size = file_size() - pos_; 189 max_size = file_size() - pos_;
190 } 190 }
191 191
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 if (!fifo_->Append((const uint8*)interleaved.get(), size)) { 347 if (!fifo_->Append((const uint8*)interleaved.get(), size)) {
348 fifo_->set_forward_capacity(2 * fifo_->forward_capacity()); 348 fifo_->set_forward_capacity(2 * fifo_->forward_capacity());
349 fifo_->Clear(); 349 fifo_->Clear();
350 } 350 }
351 } 351 }
352 352
353 virtual void OnError(AudioInputStream* stream) OVERRIDE {} 353 virtual void OnError(AudioInputStream* stream) OVERRIDE {}
354 354
355 // AudioOutputStream::AudioSourceCallback implementation 355 // AudioOutputStream::AudioSourceCallback implementation
356 virtual int OnMoreData(AudioBus* dest, 356 virtual int OnMoreData(AudioBus* dest,
357 AudioBuffersState buffers_state) OVERRIDE { 357 uint32 total_bytes_delay) OVERRIDE {
358 const int size_in_bytes = 358 const int size_in_bytes =
359 (params_.bits_per_sample() / 8) * dest->frames() * dest->channels(); 359 (params_.bits_per_sample() / 8) * dest->frames() * dest->channels();
360 EXPECT_EQ(size_in_bytes, params_.GetBytesPerBuffer()); 360 EXPECT_EQ(size_in_bytes, params_.GetBytesPerBuffer());
361 361
362 base::AutoLock lock(lock_); 362 base::AutoLock lock(lock_);
363 363
364 // We add an initial delay of ~1 second before loopback starts to ensure 364 // We add an initial delay of ~1 second before loopback starts to ensure
365 // a stable callback sequences and to avoid initial bursts which might add 365 // a stable callback sequences and to avoid initial bursts which might add
366 // to the extra FIFO delay. 366 // to the extra FIFO delay.
367 if (!started_) { 367 if (!started_) {
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); 982 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
983 printf("\n"); 983 printf("\n");
984 StopAndCloseAudioOutputStreamOnAudioThread(); 984 StopAndCloseAudioOutputStreamOnAudioThread();
985 StopAndCloseAudioInputStreamOnAudioThread(); 985 StopAndCloseAudioInputStreamOnAudioThread();
986 } 986 }
987 987
988 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, 988 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest,
989 testing::ValuesIn(RunAudioRecordInputPathTests())); 989 testing::ValuesIn(RunAudioRecordInputPathTests()));
990 990
991 } // namespace media 991 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/alsa/alsa_output_unittest.cc ('k') | media/audio/android/opensles_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698