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

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

Issue 10580033: Allow AudioDevice to be constructed on any thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
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 "content/renderer/media/audio_device.h" 5 #include "content/renderer/media/audio_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 28 matching lines...) Expand all
39 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); 39 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
40 }; 40 };
41 41
42 AudioDevice::AudioDevice() 42 AudioDevice::AudioDevice()
43 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()), 43 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()),
44 callback_(NULL), 44 callback_(NULL),
45 volume_(1.0), 45 volume_(1.0),
46 stream_id_(0), 46 stream_id_(0),
47 play_on_start_(true), 47 play_on_start_(true),
48 is_started_(false) { 48 is_started_(false) {
49 filter_ = RenderThreadImpl::current()->audio_message_filter(); 49 filter_ = AudioMessageFilter::current();
henrika (OOO until Aug 14) 2012/06/20 12:33:52 By not injecting you make it much more difficult t
henrika (OOO until Aug 14) 2012/06/20 17:15:53 Bad example; sorry. I meant create the AD and perf
50 } 50 }
51 51
52 AudioDevice::AudioDevice(const media::AudioParameters& params, 52 AudioDevice::AudioDevice(const media::AudioParameters& params,
53 RenderCallback* callback) 53 RenderCallback* callback)
54 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()), 54 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()),
55 audio_parameters_(params), 55 audio_parameters_(params),
56 callback_(callback), 56 callback_(callback),
57 volume_(1.0), 57 volume_(1.0),
58 stream_id_(0), 58 stream_id_(0),
59 play_on_start_(true), 59 play_on_start_(true),
60 is_started_(false) { 60 is_started_(false) {
61 filter_ = RenderThreadImpl::current()->audio_message_filter(); 61 filter_ = AudioMessageFilter::current();
62 } 62 }
63 63
64 void AudioDevice::Initialize(const media::AudioParameters& params, 64 void AudioDevice::Initialize(const media::AudioParameters& params,
65 RenderCallback* callback) { 65 RenderCallback* callback) {
66 CHECK_EQ(0, stream_id_) << 66 CHECK_EQ(0, stream_id_) <<
67 "AudioDevice::Initialize() must be called before Start()"; 67 "AudioDevice::Initialize() must be called before Start()";
68 68
69 CHECK(!callback_); // Calling Initialize() twice? 69 CHECK(!callback_); // Calling Initialize() twice?
70 70
71 audio_parameters_ = params; 71 audio_parameters_ = params;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // TODO(crogers/vrk): Figure out a way to avoid the float -> int -> float 292 // TODO(crogers/vrk): Figure out a way to avoid the float -> int -> float
293 // conversions that happen in the <audio> and WebRTC scenarios. 293 // conversions that happen in the <audio> and WebRTC scenarios.
294 media::InterleaveFloatToInt(audio_data_, shared_memory_.memory(), 294 media::InterleaveFloatToInt(audio_data_, shared_memory_.memory(),
295 audio_parameters_.frames_per_buffer(), 295 audio_parameters_.frames_per_buffer(),
296 audio_parameters_.bits_per_sample() / 8); 296 audio_parameters_.bits_per_sample() / 8);
297 297
298 // Let the host know we are done. 298 // Let the host know we are done.
299 media::SetActualDataSizeInBytes(&shared_memory_, memory_length_, 299 media::SetActualDataSizeInBytes(&shared_memory_, memory_length_,
300 num_frames * audio_parameters_.GetBytesPerFrame()); 300 num_frames * audio_parameters_.GetBytesPerFrame());
301 } 301 }
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/audio_message_filter.h » ('j') | content/renderer/media/audio_message_filter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698