OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 virtual ~CaptureCallback() {} | 73 virtual ~CaptureCallback() {} |
74 }; | 74 }; |
75 | 75 |
76 // Methods called on main render thread ------------------------------------- | 76 // Methods called on main render thread ------------------------------------- |
77 AudioInputDevice(size_t buffer_size, | 77 AudioInputDevice(size_t buffer_size, |
78 int channels, | 78 int channels, |
79 double sample_rate, | 79 double sample_rate, |
80 CaptureCallback* callback); | 80 CaptureCallback* callback); |
81 virtual ~AudioInputDevice(); | 81 virtual ~AudioInputDevice(); |
82 | 82 |
83 // Starts audio capturing. Returns |true| on success. | 83 // Starts audio capturing. |
84 bool Start(); | 84 void Start(); |
85 | 85 |
86 // Stops audio capturing. Returns |true| on success. | 86 // Stops audio capturing. Returns |true| on success. |
87 bool Stop(); | 87 bool Stop(); |
88 | 88 |
89 // Sets the capture volume scaling, with range [0.0, 1.0] inclusive. | 89 // Sets the capture volume scaling, with range [0.0, 1.0] inclusive. |
90 // Returns |true| on success. | 90 // Returns |true| on success. |
91 bool SetVolume(double volume); | 91 bool SetVolume(double volume); |
92 | 92 |
93 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive. | 93 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive. |
94 // Returns |true| on success. | 94 // Returns |true| on success. |
95 bool GetVolume(double* volume); | 95 bool GetVolume(double* volume); |
96 | 96 |
97 double sample_rate() const { return sample_rate_; } | 97 double sample_rate() const { return sample_rate_; } |
98 size_t buffer_size() const { return buffer_size_; } | 98 size_t buffer_size() const { return buffer_size_; } |
99 | 99 |
100 // Methods called on IO thread ---------------------------------------------- | 100 // Methods called on IO thread ---------------------------------------------- |
101 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter | 101 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter |
102 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 102 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
103 base::SyncSocket::Handle socket_handle, | 103 base::SyncSocket::Handle socket_handle, |
104 uint32 length); | 104 uint32 length); |
105 virtual void OnVolume(double volume); | 105 virtual void OnVolume(double volume); |
106 | 106 |
107 private: | 107 private: |
108 // Methods called on IO thread ---------------------------------------------- | 108 // Methods called on IO thread ---------------------------------------------- |
109 // The following methods are tasks posted on the IO thread that needs to | 109 // The following methods are tasks posted on the IO thread that needs to |
110 // be executed on that thread. They interact with AudioInputMessageFilter and | 110 // be executed on that thread. They interact with AudioInputMessageFilter and |
111 // sends IPC messages on that thread. | 111 // sends IPC messages on that thread. |
112 void InitializeOnIOThread(const AudioParameters& params); | 112 void InitializeOnIOThread(const AudioParameters& params); |
113 void StartOnIOThread(); | 113 void StartOnIOThread(); |
114 void ShutDownOnIOThread(); | 114 void ShutDownOnIOThread(base::WaitableEvent* completion); |
115 void SetVolumeOnIOThread(double volume); | 115 void SetVolumeOnIOThread(double volume); |
116 | 116 |
117 void Send(IPC::Message* message); | 117 void Send(IPC::Message* message); |
118 | 118 |
119 // Method called on the audio thread ---------------------------------------- | 119 // Method called on the audio thread ---------------------------------------- |
120 // Calls the client's callback for capturing audio. | 120 // Calls the client's callback for capturing audio. |
121 void FireCaptureCallback(); | 121 void FireCaptureCallback(); |
122 | 122 |
123 // DelegateSimpleThread::Delegate implementation. | 123 // DelegateSimpleThread::Delegate implementation. |
124 virtual void Run(); | 124 virtual void Run(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Our stream ID on the message filter. Only modified on the IO thread. | 156 // Our stream ID on the message filter. Only modified on the IO thread. |
157 int32 stream_id_; | 157 int32 stream_id_; |
158 | 158 |
159 scoped_ptr<base::SharedMemory> shared_memory_; | 159 scoped_ptr<base::SharedMemory> shared_memory_; |
160 scoped_ptr<base::SyncSocket> socket_; | 160 scoped_ptr<base::SyncSocket> socket_; |
161 | 161 |
162 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 162 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
163 }; | 163 }; |
164 | 164 |
165 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ | 165 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ |
OLD | NEW |