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

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

Issue 9805001: Move media/audio files into media namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix various compiler errors Created 8 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
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_input_device.h" 5 #include "content/renderer/media/audio_input_device.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.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 "content/common/child_process.h" 11 #include "content/common/child_process.h"
12 #include "content/common/media/audio_messages.h" 12 #include "content/common/media/audio_messages.h"
13 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
14 #include "content/renderer/render_thread_impl.h" 14 #include "content/renderer/render_thread_impl.h"
15 #include "media/audio/audio_manager_base.h" 15 #include "media/audio/audio_manager_base.h"
16 #include "media/audio/audio_util.h" 16 #include "media/audio/audio_util.h"
17 17
18 // Takes care of invoking the capture callback on the audio thread. 18 // Takes care of invoking the capture callback on the audio thread.
19 // An instance of this class is created for each capture stream in 19 // An instance of this class is created for each capture stream in
20 // OnLowLatencyCreated(). 20 // OnLowLatencyCreated().
21 class AudioInputDevice::AudioThreadCallback 21 class AudioInputDevice::AudioThreadCallback
22 : public AudioDeviceThread::Callback { 22 : public AudioDeviceThread::Callback {
23 public: 23 public:
24 AudioThreadCallback(const AudioParameters& audio_parameters, 24 AudioThreadCallback(const media::AudioParameters& audio_parameters,
25 base::SharedMemoryHandle memory, 25 base::SharedMemoryHandle memory,
26 int memory_length, 26 int memory_length,
27 CaptureCallback* capture_callback); 27 CaptureCallback* capture_callback);
28 virtual ~AudioThreadCallback(); 28 virtual ~AudioThreadCallback();
29 29
30 virtual void MapSharedMemory() OVERRIDE; 30 virtual void MapSharedMemory() OVERRIDE;
31 31
32 // Called whenever we receive notifications about pending data. 32 // Called whenever we receive notifications about pending data.
33 virtual void Process(int pending_data) OVERRIDE; 33 virtual void Process(int pending_data) OVERRIDE;
34 34
35 private: 35 private:
36 CaptureCallback* capture_callback_; 36 CaptureCallback* capture_callback_;
37 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); 37 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
38 }; 38 };
39 39
40 AudioInputDevice::AudioInputDevice(const AudioParameters& params, 40 AudioInputDevice::AudioInputDevice(const media::AudioParameters& params,
41 CaptureCallback* callback, 41 CaptureCallback* callback,
42 CaptureEventHandler* event_handler) 42 CaptureEventHandler* event_handler)
43 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()), 43 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()),
44 audio_parameters_(params), 44 audio_parameters_(params),
45 callback_(callback), 45 callback_(callback),
46 event_handler_(event_handler), 46 event_handler_(event_handler),
47 volume_(1.0), 47 volume_(1.0),
48 stream_id_(0), 48 stream_id_(0),
49 session_id_(0), 49 session_id_(0),
50 pending_device_ready_(false) { 50 pending_device_ready_(false) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 DCHECK_EQ(0, stream_id_); 97 DCHECK_EQ(0, stream_id_);
98 if (stream_id_) 98 if (stream_id_)
99 return; 99 return;
100 100
101 stream_id_ = filter_->AddDelegate(this); 101 stream_id_ = filter_->AddDelegate(this);
102 // If |session_id_| is not specified, it will directly create the stream; 102 // If |session_id_| is not specified, it will directly create the stream;
103 // otherwise it will send a AudioInputHostMsg_StartDevice msg to the browser 103 // otherwise it will send a AudioInputHostMsg_StartDevice msg to the browser
104 // and create the stream when getting a OnDeviceReady() callback. 104 // and create the stream when getting a OnDeviceReady() callback.
105 if (!session_id_) { 105 if (!session_id_) {
106 Send(new AudioInputHostMsg_CreateStream( 106 Send(new AudioInputHostMsg_CreateStream(
107 stream_id_, audio_parameters_, AudioManagerBase::kDefaultDeviceId)); 107 stream_id_, audio_parameters_,
108 media::AudioManagerBase::kDefaultDeviceId));
108 } else { 109 } else {
109 Send(new AudioInputHostMsg_StartDevice(stream_id_, session_id_)); 110 Send(new AudioInputHostMsg_StartDevice(stream_id_, session_id_));
110 pending_device_ready_ = true; 111 pending_device_ready_ = true;
111 } 112 }
112 } 113 }
113 114
114 void AudioInputDevice::SetSessionIdOnIOThread(int session_id) { 115 void AudioInputDevice::SetSessionIdOnIOThread(int session_id) {
115 DCHECK(message_loop()->BelongsToCurrentThread()); 116 DCHECK(message_loop()->BelongsToCurrentThread());
116 session_id_ = session_id; 117 session_id_ = session_id;
117 } 118 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 filter_->Send(message); 264 filter_->Send(message);
264 } 265 }
265 266
266 void AudioInputDevice::WillDestroyCurrentMessageLoop() { 267 void AudioInputDevice::WillDestroyCurrentMessageLoop() {
267 LOG(ERROR) << "IO loop going away before the input device has been stopped"; 268 LOG(ERROR) << "IO loop going away before the input device has been stopped";
268 ShutDownOnIOThread(); 269 ShutDownOnIOThread();
269 } 270 }
270 271
271 // AudioInputDevice::AudioThreadCallback 272 // AudioInputDevice::AudioThreadCallback
272 AudioInputDevice::AudioThreadCallback::AudioThreadCallback( 273 AudioInputDevice::AudioThreadCallback::AudioThreadCallback(
273 const AudioParameters& audio_parameters, 274 const media::AudioParameters& audio_parameters,
274 base::SharedMemoryHandle memory, 275 base::SharedMemoryHandle memory,
275 int memory_length, 276 int memory_length,
276 CaptureCallback* capture_callback) 277 CaptureCallback* capture_callback)
277 : AudioDeviceThread::Callback(audio_parameters, memory, memory_length), 278 : AudioDeviceThread::Callback(audio_parameters, memory, memory_length),
278 capture_callback_(capture_callback) { 279 capture_callback_(capture_callback) {
279 } 280 }
280 281
281 AudioInputDevice::AudioThreadCallback::~AudioThreadCallback() { 282 AudioInputDevice::AudioThreadCallback::~AudioThreadCallback() {
282 } 283 }
283 284
(...skipping 17 matching lines...) Expand all
301 channel_index, 302 channel_index,
302 bytes_per_sample, 303 bytes_per_sample,
303 number_of_frames); 304 number_of_frames);
304 } 305 }
305 306
306 // Deliver captured data to the client in floating point format 307 // Deliver captured data to the client in floating point format
307 // and update the audio-delay measurement. 308 // and update the audio-delay measurement.
308 capture_callback_->Capture(audio_data_, number_of_frames, 309 capture_callback_->Capture(audio_data_, number_of_frames,
309 audio_delay_milliseconds); 310 audio_delay_milliseconds);
310 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698