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

Side by Side Diff: content/renderer/media/audio_device.cc

Issue 8588030: Refactor the Get*Hardware* routines a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/audio_device.h ('k') | content/renderer/media/audio_hardware.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/renderer/media/audio_device.h" 5 #include "content/renderer/media/audio_device.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (callback_) { 226 if (callback_) {
227 // Update the audio-delay measurement then ask client to render audio. 227 // Update the audio-delay measurement then ask client to render audio.
228 callback_->Render(audio_data_, buffer_size_, audio_delay_milliseconds_); 228 callback_->Render(audio_data_, buffer_size_, audio_delay_milliseconds_);
229 229
230 // Interleave, scale, and clip to int16. 230 // Interleave, scale, and clip to int16.
231 media::InterleaveFloatToInt16(audio_data_, 231 media::InterleaveFloatToInt16(audio_data_,
232 static_cast<int16*>(shared_memory_data()), 232 static_cast<int16*>(shared_memory_data()),
233 buffer_size_); 233 buffer_size_);
234 } 234 }
235 } 235 }
236
237 double AudioDevice::GetAudioHardwareSampleRate() {
238 // Uses cached value if possible.
239 static double hardware_sample_rate = 0;
240 if (!hardware_sample_rate) {
241 RenderThreadImpl::current()->Send(
242 new ViewHostMsg_GetHardwareSampleRate(&hardware_sample_rate));
243 }
244 return hardware_sample_rate;
245 }
246
247 size_t AudioDevice::GetAudioHardwareBufferSize() {
248 // Uses cached value if possible.
249 static uint32 buffer_size = 0;
250
251 if (!buffer_size) {
252 RenderThreadImpl::current()->Send(
253 new ViewHostMsg_GetHardwareBufferSize(&buffer_size));
254 }
255
256 return static_cast<size_t>(buffer_size);
257 }
OLDNEW
« no previous file with comments | « content/renderer/media/audio_device.h ('k') | content/renderer/media/audio_hardware.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698