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

Side by Side Diff: components/audio_modem/audio_player_impl.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/audio_modem/audio_player_impl.h" 5 #include "components/audio_modem/audio_player_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 void AudioPlayerImpl::FinalizeOnAudioThread() { 128 void AudioPlayerImpl::FinalizeOnAudioThread() {
129 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); 129 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
130 StopAndCloseOnAudioThread(); 130 StopAndCloseOnAudioThread();
131 delete this; 131 delete this;
132 } 132 }
133 133
134 int AudioPlayerImpl::OnMoreData(media::AudioBus* dest, 134 int AudioPlayerImpl::OnMoreData(media::AudioBus* dest,
135 uint32_t /* total_bytes_delay */, 135 uint32_t /* total_bytes_delay */,
136 base::TimeDelta /* delay_timestamp */,
136 uint32_t /* frames_skipped */) { 137 uint32_t /* frames_skipped */) {
137 base::AutoLock al(state_lock_); 138 base::AutoLock al(state_lock_);
138 // Continuously play our samples till explicitly told to stop. 139 // Continuously play our samples till explicitly told to stop.
139 const int leftover_frames = samples_->frames() - frame_index_; 140 const int leftover_frames = samples_->frames() - frame_index_;
140 const int frames_to_copy = std::min(dest->frames(), leftover_frames); 141 const int frames_to_copy = std::min(dest->frames(), leftover_frames);
141 142
142 samples_->CopyPartialFramesTo(frame_index_, frames_to_copy, 0, dest); 143 samples_->CopyPartialFramesTo(frame_index_, frames_to_copy, 0, dest);
143 frame_index_ += frames_to_copy; 144 frame_index_ += frames_to_copy;
144 145
145 // If we didn't fill the destination audio bus, wrap around and fill the rest. 146 // If we didn't fill the destination audio bus, wrap around and fill the rest.
146 if (leftover_frames <= dest->frames()) { 147 if (leftover_frames <= dest->frames()) {
147 samples_->CopyPartialFramesTo( 148 samples_->CopyPartialFramesTo(
148 0, dest->frames() - frames_to_copy, frames_to_copy, dest); 149 0, dest->frames() - frames_to_copy, frames_to_copy, dest);
149 frame_index_ = dest->frames() - frames_to_copy; 150 frame_index_ = dest->frames() - frames_to_copy;
150 } 151 }
151 152
152 return dest->frames(); 153 return dest->frames();
153 } 154 }
154 155
155 void AudioPlayerImpl::OnError(media::AudioOutputStream* /* stream */) { 156 void AudioPlayerImpl::OnError(media::AudioOutputStream* /* stream */) {
156 LOG(ERROR) << "Error during system sound reproduction."; 157 LOG(ERROR) << "Error during system sound reproduction.";
157 media::AudioManager::Get()->GetTaskRunner()->PostTask( 158 media::AudioManager::Get()->GetTaskRunner()->PostTask(
158 FROM_HERE, 159 FROM_HERE,
159 base::Bind(&AudioPlayerImpl::StopAndCloseOnAudioThread, 160 base::Bind(&AudioPlayerImpl::StopAndCloseOnAudioThread,
160 base::Unretained(this))); 161 base::Unretained(this)));
161 } 162 }
162 163
163 } // namespace audio_modem 164 } // namespace audio_modem
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698