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

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

Issue 9104043: Monitor the IO message loop in the AudioDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indent Created 8 years, 10 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 | « content/renderer/media/audio_device.cc ('k') | content/renderer/media/audio_input_device.cc » ('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) 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 // Low-latency audio capturing unit utilizing audio input stream provided 5 // Low-latency audio capturing unit utilizing audio input stream provided
6 // by browser process through IPC. 6 // by browser process through IPC.
7 // 7 //
8 // Relationship of classes: 8 // Relationship of classes:
9 // 9 //
10 // AudioInputController AudioInputDevice 10 // AudioInputController AudioInputDevice
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 #include <vector> 72 #include <vector>
73 73
74 #include "base/basictypes.h" 74 #include "base/basictypes.h"
75 #include "base/compiler_specific.h" 75 #include "base/compiler_specific.h"
76 #include "base/memory/scoped_ptr.h" 76 #include "base/memory/scoped_ptr.h"
77 #include "base/shared_memory.h" 77 #include "base/shared_memory.h"
78 #include "base/threading/simple_thread.h" 78 #include "base/threading/simple_thread.h"
79 #include "content/common/content_export.h" 79 #include "content/common/content_export.h"
80 #include "content/renderer/media/audio_input_message_filter.h" 80 #include "content/renderer/media/audio_input_message_filter.h"
81 #include "content/renderer/media/scoped_loop_observer.h"
81 #include "media/audio/audio_parameters.h" 82 #include "media/audio/audio_parameters.h"
82 83
83 // TODO(henrika): This class is based on the AudioDevice class and it has 84 // TODO(henrika): This class is based on the AudioDevice class and it has
84 // many components in common. Investigate potential for re-factoring. 85 // many components in common. Investigate potential for re-factoring.
85 // TODO(henrika): Add support for event handling (e.g. OnStateChanged, 86 // TODO(henrika): Add support for event handling (e.g. OnStateChanged,
86 // OnCaptureStopped etc.) and ensure that we can deliver these notifications 87 // OnCaptureStopped etc.) and ensure that we can deliver these notifications
87 // to any clients using this class. 88 // to any clients using this class.
88 class CONTENT_EXPORT AudioInputDevice 89 class CONTENT_EXPORT AudioInputDevice
89 : public AudioInputMessageFilter::Delegate, 90 : public AudioInputMessageFilter::Delegate,
90 public base::DelegateSimpleThread::Delegate, 91 public base::DelegateSimpleThread::Delegate,
92 public ScopedLoopObserver,
91 public base::RefCountedThreadSafe<AudioInputDevice> { 93 public base::RefCountedThreadSafe<AudioInputDevice> {
92 public: 94 public:
93 class CONTENT_EXPORT CaptureCallback { 95 class CONTENT_EXPORT CaptureCallback {
94 public: 96 public:
95 virtual void Capture(const std::vector<float*>& audio_data, 97 virtual void Capture(const std::vector<float*>& audio_data,
96 size_t number_of_frames, 98 size_t number_of_frames,
97 size_t audio_delay_milliseconds) = 0; 99 size_t audio_delay_milliseconds) = 0;
98 protected: 100 protected:
99 virtual ~CaptureCallback() {} 101 virtual ~CaptureCallback() {}
100 }; 102 };
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 171
170 void Send(IPC::Message* message); 172 void Send(IPC::Message* message);
171 173
172 // Method called on the audio thread ---------------------------------------- 174 // Method called on the audio thread ----------------------------------------
173 // Calls the client's callback for capturing audio. 175 // Calls the client's callback for capturing audio.
174 void FireCaptureCallback(int16* input_audio); 176 void FireCaptureCallback(int16* input_audio);
175 177
176 // DelegateSimpleThread::Delegate implementation. 178 // DelegateSimpleThread::Delegate implementation.
177 virtual void Run() OVERRIDE; 179 virtual void Run() OVERRIDE;
178 180
181 // MessageLoop::DestructionObserver implementation for the IO loop.
182 // If the IO loop dies before we do, we shut down the audio thread from here.
183 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
184
179 // Format 185 // Format
180 AudioParameters audio_parameters_; 186 AudioParameters audio_parameters_;
181 187
182 CaptureCallback* callback_; 188 CaptureCallback* callback_;
183 CaptureEventHandler* event_handler_; 189 CaptureEventHandler* event_handler_;
184 190
185 // The client callback receives captured audio here. 191 // The client callback receives captured audio here.
186 std::vector<float*> audio_data_; 192 std::vector<float*> audio_data_;
187 193
188 // The client stores the last reported audio delay in this member. 194 // The client stores the last reported audio delay in this member.
(...skipping 22 matching lines...) Expand all
211 bool pending_device_ready_; 217 bool pending_device_ready_;
212 218
213 base::SharedMemoryHandle shared_memory_handle_; 219 base::SharedMemoryHandle shared_memory_handle_;
214 scoped_ptr<base::CancelableSyncSocket> audio_socket_; 220 scoped_ptr<base::CancelableSyncSocket> audio_socket_;
215 int memory_length_; 221 int memory_length_;
216 222
217 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); 223 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice);
218 }; 224 };
219 225
220 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ 226 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/audio_device.cc ('k') | content/renderer/media/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698