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

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

Issue 12379071: Use multiple shared memory buffers cyclically for audio capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: address a missed comment Created 7 years, 9 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 | Annotate | Revision Log
« media/audio/audio_input_ipc.h ('K') | « media/audio/audio_input_ipc.h ('k') | no next file » | 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_output_device.h" 5 #include "media/audio/audio_output_device.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 // AudioOutputDevice::AudioThreadCallback 251 // AudioOutputDevice::AudioThreadCallback
252 252
253 AudioOutputDevice::AudioThreadCallback::AudioThreadCallback( 253 AudioOutputDevice::AudioThreadCallback::AudioThreadCallback(
254 const AudioParameters& audio_parameters, 254 const AudioParameters& audio_parameters,
255 base::SharedMemoryHandle memory, 255 base::SharedMemoryHandle memory,
256 int memory_length, 256 int memory_length,
257 AudioRendererSink::RenderCallback* render_callback) 257 AudioRendererSink::RenderCallback* render_callback)
258 : AudioDeviceThread::Callback(audio_parameters, 258 : AudioDeviceThread::Callback(audio_parameters,
259 memory, 259 memory,
260 memory_length), 260 memory_length,
261 1),
261 render_callback_(render_callback) { 262 render_callback_(render_callback) {
262 } 263 }
263 264
264 AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() { 265 AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() {
265 } 266 }
266 267
267 void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() { 268 void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
269 CHECK_EQ(1, total_segments_);
DaleCurtis 2013/03/07 02:04:37 TMYK: http://what-if.xkcd.com/3/
268 CHECK(shared_memory_.Map(TotalSharedMemorySizeInBytes(memory_length_))); 270 CHECK(shared_memory_.Map(TotalSharedMemorySizeInBytes(memory_length_)));
269 271
270 // Calculate output and input memory size. 272 // Calculate output and input memory size.
271 int output_memory_size = AudioBus::CalculateMemorySize(audio_parameters_); 273 int output_memory_size = AudioBus::CalculateMemorySize(audio_parameters_);
272 int input_channels = audio_parameters_.input_channels(); 274 int input_channels = audio_parameters_.input_channels();
273 int frames = audio_parameters_.frames_per_buffer(); 275 int frames = audio_parameters_.frames_per_buffer();
274 int input_memory_size = 276 int input_memory_size =
275 AudioBus::CalculateMemorySize(input_channels, frames); 277 AudioBus::CalculateMemorySize(input_channels, frames);
276 278
277 int io_size = output_memory_size + input_memory_size; 279 int io_size = output_memory_size + input_memory_size;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // TODO(dalecurtis): Technically this is not always correct. Due to channel 325 // TODO(dalecurtis): Technically this is not always correct. Due to channel
324 // padding for alignment, there may be more data available than this. We're 326 // padding for alignment, there may be more data available than this. We're
325 // relying on AudioSyncReader::Read() to parse this with that in mind. Rename 327 // relying on AudioSyncReader::Read() to parse this with that in mind. Rename
326 // these methods to Set/GetActualFrameCount(). 328 // these methods to Set/GetActualFrameCount().
327 SetActualDataSizeInBytes( 329 SetActualDataSizeInBytes(
328 &shared_memory_, memory_length_, 330 &shared_memory_, memory_length_,
329 num_frames * sizeof(*output_bus_->channel(0)) * output_bus_->channels()); 331 num_frames * sizeof(*output_bus_->channel(0)) * output_bus_->channels());
330 } 332 }
331 333
332 } // namespace media. 334 } // namespace media.
OLDNEW
« media/audio/audio_input_ipc.h ('K') | « media/audio/audio_input_ipc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698