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_device.h" | 5 #include "content/renderer/media/audio_device.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 void AudioDevice::InitializeOnIOThread(const AudioParameters& params) { | 146 void AudioDevice::InitializeOnIOThread(const AudioParameters& params) { |
147 DCHECK_EQ(MessageLoop::current(), ChildProcess::current()->io_message_loop()); | 147 DCHECK_EQ(MessageLoop::current(), ChildProcess::current()->io_message_loop()); |
148 // Make sure we don't create the stream more than once. | 148 // Make sure we don't create the stream more than once. |
149 DCHECK_EQ(0, stream_id_); | 149 DCHECK_EQ(0, stream_id_); |
150 if (stream_id_) | 150 if (stream_id_) |
151 return; | 151 return; |
152 | 152 |
153 stream_id_ = filter_->AddDelegate(this); | 153 stream_id_ = filter_->AddDelegate(this); |
154 Send(new AudioHostMsg_CreateStream(stream_id_, params, true)); | 154 Send(new AudioHostMsg_CreateStream(stream_id_, params)); |
155 } | 155 } |
156 | 156 |
157 void AudioDevice::PlayOnIOThread() { | 157 void AudioDevice::PlayOnIOThread() { |
158 DCHECK_EQ(MessageLoop::current(), ChildProcess::current()->io_message_loop()); | 158 DCHECK_EQ(MessageLoop::current(), ChildProcess::current()->io_message_loop()); |
159 if (stream_id_ && is_started_) | 159 if (stream_id_ && is_started_) |
160 Send(new AudioHostMsg_PlayStream(stream_id_)); | 160 Send(new AudioHostMsg_PlayStream(stream_id_)); |
161 else | 161 else |
162 play_on_start_ = true; | 162 play_on_start_ = true; |
163 } | 163 } |
164 | 164 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void AudioDevice::OnRequestPacket(AudioBuffersState buffers_state) { | 200 void AudioDevice::OnRequestPacket(AudioBuffersState buffers_state) { |
201 // This method does not apply to the low-latency system. | 201 // This method does not apply to the low-latency system. |
202 } | 202 } |
203 | 203 |
204 void AudioDevice::OnStateChanged(AudioStreamState state) { | 204 void AudioDevice::OnStateChanged(AudioStreamState state) { |
205 if (state == kAudioStreamError) { | 205 if (state == kAudioStreamError) { |
206 DLOG(WARNING) << "AudioDevice::OnStateChanged(kError)"; | 206 DLOG(WARNING) << "AudioDevice::OnStateChanged(kError)"; |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 void AudioDevice::OnCreated( | |
211 base::SharedMemoryHandle handle, uint32 length) { | |
212 // Not needed in this simple implementation. | |
213 } | |
214 | |
215 void AudioDevice::OnLowLatencyCreated( | 210 void AudioDevice::OnLowLatencyCreated( |
216 base::SharedMemoryHandle handle, | 211 base::SharedMemoryHandle handle, |
217 base::SyncSocket::Handle socket_handle, | 212 base::SyncSocket::Handle socket_handle, |
218 uint32 length) { | 213 uint32 length) { |
219 DCHECK_EQ(MessageLoop::current(), ChildProcess::current()->io_message_loop()); | 214 DCHECK_EQ(MessageLoop::current(), ChildProcess::current()->io_message_loop()); |
220 DCHECK_GE(length, buffer_size_ * sizeof(int16) * channels_); | 215 DCHECK_GE(length, buffer_size_ * sizeof(int16) * channels_); |
221 #if defined(OS_WIN) | 216 #if defined(OS_WIN) |
222 DCHECK(handle); | 217 DCHECK(handle); |
223 DCHECK(socket_handle); | 218 DCHECK(socket_handle); |
224 #else | 219 #else |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 314 |
320 if (audio_thread_.get()) { | 315 if (audio_thread_.get()) { |
321 // Close the socket to terminate the main thread function in the | 316 // Close the socket to terminate the main thread function in the |
322 // audio thread. | 317 // audio thread. |
323 audio_socket_->Close(); | 318 audio_socket_->Close(); |
324 audio_socket_ = NULL; | 319 audio_socket_ = NULL; |
325 audio_thread_->Join(); | 320 audio_thread_->Join(); |
326 audio_thread_.reset(NULL); | 321 audio_thread_.reset(NULL); |
327 } | 322 } |
328 } | 323 } |
OLD | NEW |