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/pepper/pepper_platform_audio_output_impl.h" | 5 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 int length) { | 75 int length) { |
76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
77 DCHECK(handle); | 77 DCHECK(handle); |
78 DCHECK(socket_handle); | 78 DCHECK(socket_handle); |
79 #else | 79 #else |
80 DCHECK_NE(-1, handle.fd); | 80 DCHECK_NE(-1, handle.fd); |
81 DCHECK_NE(-1, socket_handle); | 81 DCHECK_NE(-1, socket_handle); |
82 #endif | 82 #endif |
83 DCHECK(length); | 83 DCHECK(length); |
84 | 84 |
85 if (base::MessageLoopProxy::current() == main_message_loop_proxy_) { | 85 if (base::MessageLoopProxy::current().get() == main_message_loop_proxy_) { |
86 // Must dereference the client only on the main thread. Shutdown may have | 86 // Must dereference the client only on the main thread. Shutdown may have |
87 // occurred while the request was in-flight, so we need to NULL check. | 87 // occurred while the request was in-flight, so we need to NULL check. |
88 if (client_) | 88 if (client_) |
89 client_->StreamCreated(handle, length, socket_handle); | 89 client_->StreamCreated(handle, length, socket_handle); |
90 } else { | 90 } else { |
91 main_message_loop_proxy_->PostTask(FROM_HERE, | 91 main_message_loop_proxy_->PostTask(FROM_HERE, |
92 base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this, | 92 base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this, |
93 handle, socket_handle, length)); | 93 handle, socket_handle, length)); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 void PepperPlatformAudioOutputImpl::OnIPCClosed() { | 97 void PepperPlatformAudioOutputImpl::OnIPCClosed() { |
98 ipc_.reset(); | 98 ipc_.reset(); |
99 } | 99 } |
100 | 100 |
101 PepperPlatformAudioOutputImpl::~PepperPlatformAudioOutputImpl() { | 101 PepperPlatformAudioOutputImpl::~PepperPlatformAudioOutputImpl() { |
102 // Make sure we have been shut down. Warning: this will usually happen on | 102 // Make sure we have been shut down. Warning: this will usually happen on |
103 // the I/O thread! | 103 // the I/O thread! |
104 DCHECK(!ipc_); | 104 DCHECK(!ipc_); |
105 DCHECK(!client_); | 105 DCHECK(!client_); |
106 } | 106 } |
107 | 107 |
108 PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl() | 108 PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl() |
109 : client_(NULL), | 109 : client_(NULL), |
110 main_message_loop_proxy_(base::MessageLoopProxy::current()) { | 110 main_message_loop_proxy_(base::MessageLoopProxy::current().get()) {} |
111 } | |
112 | 111 |
113 bool PepperPlatformAudioOutputImpl::Initialize( | 112 bool PepperPlatformAudioOutputImpl::Initialize( |
114 int sample_rate, | 113 int sample_rate, |
115 int frames_per_buffer, | 114 int frames_per_buffer, |
116 int source_render_view_id, | 115 int source_render_view_id, |
117 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { | 116 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { |
118 DCHECK(client); | 117 DCHECK(client); |
119 client_ = client; | 118 client_ = client; |
120 | 119 |
121 RenderThreadImpl* const render_thread = RenderThreadImpl::current(); | 120 RenderThreadImpl* const render_thread = RenderThreadImpl::current(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return; | 165 return; |
167 | 166 |
168 ipc_->CloseStream(); | 167 ipc_->CloseStream(); |
169 ipc_.reset(); | 168 ipc_.reset(); |
170 | 169 |
171 Release(); // Release for the delegate, balances out the reference taken in | 170 Release(); // Release for the delegate, balances out the reference taken in |
172 // PepperPluginDelegateImpl::CreateAudio. | 171 // PepperPluginDelegateImpl::CreateAudio. |
173 } | 172 } |
174 | 173 |
175 } // namespace content | 174 } // namespace content |
OLD | NEW |