OLD | NEW |
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" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 audio_thread_.Start(audio_callback_.get(), socket_handle, "AudioInputDevice"); | 126 audio_thread_.Start(audio_callback_.get(), socket_handle, "AudioInputDevice"); |
127 | 127 |
128 MessageLoop::current()->PostTask(FROM_HERE, | 128 MessageLoop::current()->PostTask(FROM_HERE, |
129 base::Bind(&AudioInputDevice::StartOnIOThread, this)); | 129 base::Bind(&AudioInputDevice::StartOnIOThread, this)); |
130 } | 130 } |
131 | 131 |
132 void AudioInputDevice::OnVolume(double volume) { | 132 void AudioInputDevice::OnVolume(double volume) { |
133 NOTIMPLEMENTED(); | 133 NOTIMPLEMENTED(); |
134 } | 134 } |
135 | 135 |
136 void AudioInputDevice::OnStateChanged(AudioStreamState state) { | 136 void AudioInputDevice::OnStateChanged(media::AudioStreamState state) { |
137 DCHECK(message_loop()->BelongsToCurrentThread()); | 137 DCHECK(message_loop()->BelongsToCurrentThread()); |
138 | 138 |
139 // Do nothing if the stream has been closed. | 139 // Do nothing if the stream has been closed. |
140 if (!stream_id_) | 140 if (!stream_id_) |
141 return; | 141 return; |
142 | 142 |
143 switch (state) { | 143 switch (state) { |
144 // TODO(xians): This should really be kAudioStreamStopped since the stream | 144 // TODO(xians): This should really be kAudioStreamStopped since the stream |
145 // has been closed at this point. | 145 // has been closed at this point. |
146 case kAudioStreamPaused: | 146 case media::kAudioStreamPaused: |
147 // TODO(xians): Should we just call ShutDownOnIOThread here instead? | 147 // TODO(xians): Should we just call ShutDownOnIOThread here instead? |
148 filter_->RemoveDelegate(stream_id_); | 148 filter_->RemoveDelegate(stream_id_); |
149 | 149 |
150 audio_thread_.Stop(MessageLoop::current()); | 150 audio_thread_.Stop(MessageLoop::current()); |
151 audio_callback_.reset(); | 151 audio_callback_.reset(); |
152 | 152 |
153 if (event_handler_) | 153 if (event_handler_) |
154 event_handler_->OnDeviceStopped(); | 154 event_handler_->OnDeviceStopped(); |
155 | 155 |
156 stream_id_ = 0; | 156 stream_id_ = 0; |
157 pending_device_ready_ = false; | 157 pending_device_ready_ = false; |
158 break; | 158 break; |
159 case kAudioStreamPlaying: | 159 case media::kAudioStreamPlaying: |
160 NOTIMPLEMENTED(); | 160 NOTIMPLEMENTED(); |
161 break; | 161 break; |
162 case kAudioStreamError: | 162 case media::kAudioStreamError: |
163 DLOG(WARNING) << "AudioInputDevice::OnStateChanged(kError)"; | 163 DLOG(WARNING) << "AudioInputDevice::OnStateChanged(kError)"; |
164 // Don't dereference the callback object if the audio thread | 164 // Don't dereference the callback object if the audio thread |
165 // is stopped or stopping. That could mean that the callback | 165 // is stopped or stopping. That could mean that the callback |
166 // object has been deleted. | 166 // object has been deleted. |
167 // TODO(tommi): Add an explicit contract for clearing the callback | 167 // TODO(tommi): Add an explicit contract for clearing the callback |
168 // object. Possibly require calling Initialize again or provide | 168 // object. Possibly require calling Initialize again or provide |
169 // a callback object via Start() and clear it in Stop(). | 169 // a callback object via Start() and clear it in Stop(). |
170 if (!audio_thread_.IsStopped()) | 170 if (!audio_thread_.IsStopped()) |
171 callback_->OnCaptureError(); | 171 callback_->OnCaptureError(); |
172 break; | 172 break; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 channel_index, | 334 channel_index, |
335 bytes_per_sample, | 335 bytes_per_sample, |
336 number_of_frames); | 336 number_of_frames); |
337 } | 337 } |
338 | 338 |
339 // Deliver captured data to the client in floating point format | 339 // Deliver captured data to the client in floating point format |
340 // and update the audio-delay measurement. | 340 // and update the audio-delay measurement. |
341 capture_callback_->Capture(audio_data_, number_of_frames, | 341 capture_callback_->Capture(audio_data_, number_of_frames, |
342 audio_delay_milliseconds, volume); | 342 audio_delay_milliseconds, volume); |
343 } | 343 } |
OLD | NEW |