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

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

Issue 687563004: Change parameter type on AudioDeviceThread::Callback::Process() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/audio/audio_input_device.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 (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 "media/audio/audio_device_thread.h" 5 #include "media/audio/audio_device_thread.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 void AudioDeviceThread::Thread::Run() { 165 void AudioDeviceThread::Thread::Run() {
166 uint32 buffer_index = 0; 166 uint32 buffer_index = 0;
167 while (true) { 167 while (true) {
168 uint32 pending_data = 0; 168 uint32 pending_data = 0;
169 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); 169 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data));
170 if (bytes_read != sizeof(pending_data)) 170 if (bytes_read != sizeof(pending_data))
171 break; 171 break;
172 172
173 { 173 {
174 base::AutoLock auto_lock(callback_lock_); 174 base::AutoLock auto_lock(callback_lock_);
175 if (callback_) { 175 if (callback_)
176 // TODO(acolwell): Update downstream code to use a uint32. 176 callback_->Process(pending_data);
177 // Under normal operation saturation should never occur here
178 // and even if it does, it would only cause a temporary loss
179 // of A/V sync which is much better than crashing or halting
180 // playback.
181 callback_->Process(base::saturated_cast<int>(pending_data));
182 }
183 } 177 }
184 178
185 // Let the other end know which buffer we just filled. The buffer index is 179 // Let the other end know which buffer we just filled. The buffer index is
186 // used to ensure the other end is getting the buffer it expects. For more 180 // used to ensure the other end is getting the buffer it expects. For more
187 // details on how this works see AudioSyncReader::WaitUntilDataIsReady(). 181 // details on how this works see AudioSyncReader::WaitUntilDataIsReady().
188 if (synchronized_buffers_) { 182 if (synchronized_buffers_) {
189 ++buffer_index; 183 ++buffer_index;
190 size_t bytes_sent = socket_.Send(&buffer_index, sizeof(buffer_index)); 184 size_t bytes_sent = socket_.Send(&buffer_index, sizeof(buffer_index));
191 if (bytes_sent != sizeof(buffer_index)) 185 if (bytes_sent != sizeof(buffer_index))
192 break; 186 break;
(...skipping 24 matching lines...) Expand all
217 } 211 }
218 212
219 AudioDeviceThread::Callback::~Callback() {} 213 AudioDeviceThread::Callback::~Callback() {}
220 214
221 void AudioDeviceThread::Callback::InitializeOnAudioThread() { 215 void AudioDeviceThread::Callback::InitializeOnAudioThread() {
222 MapSharedMemory(); 216 MapSharedMemory();
223 CHECK(shared_memory_.memory()); 217 CHECK(shared_memory_.memory());
224 } 218 }
225 219
226 } // namespace media. 220 } // namespace media.
OLDNEW
« no previous file with comments | « media/audio/audio_device_thread.h ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698