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

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

Issue 10837350: Revert 152406 - Introduce shared_memory_support media target for PPAPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | media/audio/audio_output_device_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
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"
11 #include "media/audio/audio_output_controller.h" 11 #include "media/audio/audio_output_controller.h"
12 #include "media/audio/audio_util.h" 12 #include "media/audio/audio_util.h"
13 #include "media/audio/shared_memory_util.h"
14 13
15 namespace media { 14 namespace media {
16 15
17 // Takes care of invoking the render callback on the audio thread. 16 // Takes care of invoking the render callback on the audio thread.
18 // An instance of this class is created for each capture stream in 17 // An instance of this class is created for each capture stream in
19 // OnStreamCreated(). 18 // OnStreamCreated().
20 class AudioOutputDevice::AudioThreadCallback 19 class AudioOutputDevice::AudioThreadCallback
21 : public AudioDeviceThread::Callback { 20 : public AudioDeviceThread::Callback {
22 public: 21 public:
23 AudioThreadCallback(const AudioParameters& audio_parameters, 22 AudioThreadCallback(const AudioParameters& audio_parameters,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 246
248 AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() { 247 AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() {
249 } 248 }
250 249
251 void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() { 250 void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
252 shared_memory_.Map(TotalSharedMemorySizeInBytes(memory_length_)); 251 shared_memory_.Map(TotalSharedMemorySizeInBytes(memory_length_));
253 } 252 }
254 253
255 // Called whenever we receive notifications about pending data. 254 // Called whenever we receive notifications about pending data.
256 void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) { 255 void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) {
257 if (pending_data == kPauseMark) { 256 if (pending_data == AudioOutputController::kPauseMark) {
258 memset(shared_memory_.memory(), 0, memory_length_); 257 memset(shared_memory_.memory(), 0, memory_length_);
259 SetActualDataSizeInBytes(&shared_memory_, memory_length_, 0); 258 SetActualDataSizeInBytes(&shared_memory_, memory_length_, 0);
260 return; 259 return;
261 } 260 }
262 261
263 // Convert the number of pending bytes in the render buffer 262 // Convert the number of pending bytes in the render buffer
264 // into milliseconds. 263 // into milliseconds.
265 int audio_delay_milliseconds = pending_data / bytes_per_ms_; 264 int audio_delay_milliseconds = pending_data / bytes_per_ms_;
266 265
267 TRACE_EVENT0("audio", "AudioOutputDevice::FireRenderCallback"); 266 TRACE_EVENT0("audio", "AudioOutputDevice::FireRenderCallback");
268 267
269 // Update the audio-delay measurement then ask client to render audio. 268 // Update the audio-delay measurement then ask client to render audio.
270 size_t num_frames = render_callback_->Render( 269 size_t num_frames = render_callback_->Render(
271 audio_bus_.get(), audio_delay_milliseconds); 270 audio_bus_.get(), audio_delay_milliseconds);
272 271
273 // Interleave, scale, and clip to int. 272 // Interleave, scale, and clip to int.
274 // TODO(dalecurtis): Remove this when we have float everywhere. 273 // TODO(dalecurtis): Remove this when we have float everywhere.
275 InterleaveFloatToInt( 274 InterleaveFloatToInt(
276 audio_bus_.get(), shared_memory_.memory(), num_frames, 275 audio_bus_.get(), shared_memory_.memory(), num_frames,
277 audio_parameters_.bits_per_sample() / 8); 276 audio_parameters_.bits_per_sample() / 8);
278 277
279 // Let the host know we are done. 278 // Let the host know we are done.
280 SetActualDataSizeInBytes( 279 SetActualDataSizeInBytes(
281 &shared_memory_, memory_length_, 280 &shared_memory_, memory_length_,
282 num_frames * audio_parameters_.GetBytesPerFrame()); 281 num_frames * audio_parameters_.GetBytesPerFrame());
283 } 282 }
284 283
285 } // namespace media. 284 } // namespace media.
OLDNEW
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | media/audio/audio_output_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698