| 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_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Make sure we have been shut down. Warning: this will usually happen on | 24 // Make sure we have been shut down. Warning: this will usually happen on |
| 25 // the I/O thread! | 25 // the I/O thread! |
| 26 DCHECK_EQ(0, stream_id_); | 26 DCHECK_EQ(0, stream_id_); |
| 27 DCHECK(!client_); | 27 DCHECK(!client_); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create( | 31 PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create( |
| 32 uint32_t sample_rate, | 32 uint32_t sample_rate, |
| 33 uint32_t sample_count, | 33 uint32_t sample_count, |
| 34 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { | 34 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { |
| 35 scoped_refptr<PepperPlatformAudioOutputImpl> audio_output( | 35 scoped_refptr<PepperPlatformAudioOutputImpl> audio_output( |
| 36 new PepperPlatformAudioOutputImpl); | 36 new PepperPlatformAudioOutputImpl); |
| 37 if (audio_output->Initialize(sample_rate, sample_count, client)) { | 37 if (audio_output->Initialize(sample_rate, sample_count, client)) { |
| 38 // Balanced by Release invoked in | 38 // Balanced by Release invoked in |
| 39 // PepperPlatformAudioOutputImpl::ShutDownOnIOThread(). | 39 // PepperPlatformAudioOutputImpl::ShutDownOnIOThread(). |
| 40 return audio_output.release(); | 40 return audio_output.release(); |
| 41 } | 41 } |
| 42 return NULL; | 42 return NULL; |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 69 // the client on the main thread, and the delegates from the I/O thread. | 69 // the client on the main thread, and the delegates from the I/O thread. |
| 70 client_ = NULL; | 70 client_ = NULL; |
| 71 ChildProcess::current()->io_message_loop()->PostTask( | 71 ChildProcess::current()->io_message_loop()->PostTask( |
| 72 FROM_HERE, | 72 FROM_HERE, |
| 73 base::Bind(&PepperPlatformAudioOutputImpl::ShutDownOnIOThread, this)); | 73 base::Bind(&PepperPlatformAudioOutputImpl::ShutDownOnIOThread, this)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool PepperPlatformAudioOutputImpl::Initialize( | 76 bool PepperPlatformAudioOutputImpl::Initialize( |
| 77 uint32_t sample_rate, | 77 uint32_t sample_rate, |
| 78 uint32_t sample_count, | 78 uint32_t sample_count, |
| 79 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) { | 79 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { |
| 80 DCHECK(client); | 80 DCHECK(client); |
| 81 // Make sure we don't call init more than once. | 81 // Make sure we don't call init more than once. |
| 82 DCHECK_EQ(0, stream_id_); | 82 DCHECK_EQ(0, stream_id_); |
| 83 | 83 |
| 84 client_ = client; | 84 client_ = client; |
| 85 | 85 |
| 86 AudioParameters params; | 86 AudioParameters params; |
| 87 const uint32_t kMaxSampleCountForLowLatency = 2048; | 87 const uint32_t kMaxSampleCountForLowLatency = 2048; |
| 88 // Use the low latency back end if the client request is compatible, and | 88 // Use the low latency back end if the client request is compatible, and |
| 89 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY. | 89 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // Must dereference the client only on the main thread. Shutdown may have | 154 // Must dereference the client only on the main thread. Shutdown may have |
| 155 // occurred while the request was in-flight, so we need to NULL check. | 155 // occurred while the request was in-flight, so we need to NULL check. |
| 156 if (client_) | 156 if (client_) |
| 157 client_->StreamCreated(handle, length, socket_handle); | 157 client_->StreamCreated(handle, length, socket_handle); |
| 158 } else { | 158 } else { |
| 159 main_message_loop_proxy_->PostTask(FROM_HERE, | 159 main_message_loop_proxy_->PostTask(FROM_HERE, |
| 160 base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this, | 160 base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this, |
| 161 handle, socket_handle, length)); | 161 handle, socket_handle, length)); |
| 162 } | 162 } |
| 163 } | 163 } |
| OLD | NEW |