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

Side by Side Diff: media/audio/audio_output_stream_sink.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/audio/audio_output_stream_sink.h" 5 #include "media/audio/audio_output_stream_sink.h"
6 6
7 #include <algorithm>
7 #include <cmath> 8 #include <cmath>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "media/audio/audio_manager.h" 13 #include "media/audio/audio_manager.h"
14 #include "media/base/audio_timestamp_helper.h"
13 15
14 namespace media { 16 namespace media {
15 17
16 AudioOutputStreamSink::AudioOutputStreamSink() 18 AudioOutputStreamSink::AudioOutputStreamSink()
17 : initialized_(false), 19 : initialized_(false),
18 started_(false), 20 started_(false),
19 render_callback_(NULL), 21 render_callback_(NULL),
20 active_render_callback_(NULL), 22 active_render_callback_(NULL),
21 audio_task_runner_(AudioManager::Get()->GetTaskRunner()), 23 audio_task_runner_(AudioManager::Get()->GetTaskRunner()),
22 stream_(NULL) {} 24 stream_(NULL) {}
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 77
76 OutputDeviceInfo AudioOutputStreamSink::GetOutputDeviceInfo() { 78 OutputDeviceInfo AudioOutputStreamSink::GetOutputDeviceInfo() {
77 return OutputDeviceInfo(); 79 return OutputDeviceInfo();
78 } 80 }
79 81
80 bool AudioOutputStreamSink::CurrentThreadIsRenderingThread() { 82 bool AudioOutputStreamSink::CurrentThreadIsRenderingThread() {
81 NOTIMPLEMENTED(); 83 NOTIMPLEMENTED();
82 return false; 84 return false;
83 } 85 }
84 86
85 int AudioOutputStreamSink::OnMoreData(AudioBus* dest, 87 int AudioOutputStreamSink::OnMoreData(base::TimeDelta delay,
86 uint32_t total_bytes_delay, 88 base::TimeTicks /* delay_timestamp */,
87 uint32_t frames_skipped) { 89 int prior_frames_skipped,
90 AudioBus* dest) {
88 // Note: Runs on the audio thread created by the OS. 91 // Note: Runs on the audio thread created by the OS.
89 base::AutoLock al(callback_lock_); 92 base::AutoLock al(callback_lock_);
90 if (!active_render_callback_) 93 if (!active_render_callback_)
91 return 0; 94 return 0;
92 95
93 uint32_t frames_delayed = std::round(static_cast<double>(total_bytes_delay) / 96 uint32_t frames_delayed =
94 active_params_.GetBytesPerFrame()); 97 AudioTimestampHelper::TimeToFrames(delay, active_params_.sample_rate());
95 98
96 return active_render_callback_->Render(dest, frames_delayed, frames_skipped); 99 return active_render_callback_->Render(dest, frames_delayed,
100 prior_frames_skipped);
97 } 101 }
98 102
99 void AudioOutputStreamSink::OnError(AudioOutputStream* stream) { 103 void AudioOutputStreamSink::OnError(AudioOutputStream* stream) {
100 // Note: Runs on the audio thread created by the OS. 104 // Note: Runs on the audio thread created by the OS.
101 base::AutoLock al(callback_lock_); 105 base::AutoLock al(callback_lock_);
102 if (active_render_callback_) 106 if (active_render_callback_)
103 active_render_callback_->OnRenderError(); 107 active_render_callback_->OnRenderError();
104 } 108 }
105 109
106 void AudioOutputStreamSink::DoStart(const AudioParameters& params) { 110 void AudioOutputStreamSink::DoStart(const AudioParameters& params) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 void AudioOutputStreamSink::DoSetVolume(double volume) { 151 void AudioOutputStreamSink::DoSetVolume(double volume) {
148 DCHECK(audio_task_runner_->BelongsToCurrentThread()); 152 DCHECK(audio_task_runner_->BelongsToCurrentThread());
149 stream_->SetVolume(volume); 153 stream_->SetVolume(volume);
150 } 154 }
151 155
152 void AudioOutputStreamSink::ClearCallback() { 156 void AudioOutputStreamSink::ClearCallback() {
153 base::AutoLock al(callback_lock_); 157 base::AutoLock al(callback_lock_);
154 active_render_callback_ = NULL; 158 active_render_callback_ = NULL;
155 } 159 }
156 160
157 } // namepace media 161 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698