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

Side by Side Diff: media/audio/audio_low_latency_input_output_unittest.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix Mac CQ errors. Created 4 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm>
8 #include <memory> 9 #include <memory>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/environment.h" 12 #include "base/environment.h"
12 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Double the buffer capacity to ensure that we have a buffer large 219 // Double the buffer capacity to ensure that we have a buffer large
219 // enough to handle the current sample test scenario. 220 // enough to handle the current sample test scenario.
220 // buffer_->set_forward_capacity(2 * buffer_->forward_capacity()); 221 // buffer_->set_forward_capacity(2 * buffer_->forward_capacity());
221 // buffer_->Clear(); 222 // buffer_->Clear();
222 // } 223 // }
223 } 224 }
224 225
225 void OnError(AudioInputStream* stream) override {} 226 void OnError(AudioInputStream* stream) override {}
226 227
227 // AudioOutputStream::AudioSourceCallback. 228 // AudioOutputStream::AudioSourceCallback.
228 int OnMoreData(AudioBus* audio_bus, 229 int OnMoreData(base::TimeDelta delay,
229 uint32_t total_bytes_delay, 230 base::TimeTicks /* delay_timestamp */,
230 uint32_t frames_skipped) override { 231 int /* prior_frames_skipped */,
232 AudioBus* dest) override {
231 base::AutoLock lock(lock_); 233 base::AutoLock lock(lock_);
232 234
233 // Update one component in the AudioDelayState for the packet 235 // Update one component in the AudioDelayState for the packet
234 // which is about to be played out. 236 // which is about to be played out.
235 if (output_elements_to_write_ < kMaxDelayMeasurements) { 237 if (output_elements_to_write_ < kMaxDelayMeasurements) {
236 delay_states_[output_elements_to_write_].output_delay_ms = 238 delay_states_[output_elements_to_write_].output_delay_ms =
237 BytesToMilliseconds(total_bytes_delay); 239 delay.InMilliseconds();
238 ++output_elements_to_write_; 240 ++output_elements_to_write_;
239 } 241 }
240 242
241 int size; 243 int size;
242 const uint8_t* source; 244 const uint8_t* source;
243 // Read the data from the seekable media buffer which contains 245 // Read the data from the seekable media buffer which contains
244 // captured data at the same size and sample rate as the output side. 246 // captured data at the same size and sample rate as the output side.
245 if (buffer_->GetCurrentChunk(&source, &size) && size > 0) { 247 if (buffer_->GetCurrentChunk(&source, &size) && size > 0) {
246 EXPECT_EQ(channels_, audio_bus->channels()); 248 EXPECT_EQ(channels_, dest->channels());
247 size = std::min(audio_bus->frames() * frame_size_, size); 249 size = std::min(dest->frames() * frame_size_, size);
248 EXPECT_EQ(static_cast<size_t>(size) % sizeof(*audio_bus->channel(0)), 0U); 250 EXPECT_EQ(static_cast<size_t>(size) % sizeof(*dest->channel(0)), 0U);
249 audio_bus->FromInterleaved( 251 dest->FromInterleaved(source, size / frame_size_,
250 source, size / frame_size_, frame_size_ / channels_); 252 frame_size_ / channels_);
251 buffer_->Seek(size); 253 buffer_->Seek(size);
252 return size / frame_size_; 254 return size / frame_size_;
253 } 255 }
254 256
255 return 0; 257 return 0;
256 } 258 }
257 259
258 void OnError(AudioOutputStream* stream) override {} 260 void OnError(AudioOutputStream* stream) override {}
259 261
260 protected: 262 protected:
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 443
442 // All Close() operations that run on the mocked audio thread, 444 // All Close() operations that run on the mocked audio thread,
443 // should be synchronous and not post additional close tasks to 445 // should be synchronous and not post additional close tasks to
444 // mocked the audio thread. Hence, there is no need to call 446 // mocked the audio thread. Hence, there is no need to call
445 // message_loop()->RunUntilIdle() after the Close() methods. 447 // message_loop()->RunUntilIdle() after the Close() methods.
446 aos->Close(); 448 aos->Close();
447 ais->Close(); 449 ais->Close();
448 } 450 }
449 451
450 } // namespace media 452 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698