Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_output.cc

Issue 1856673002: Mojofication of the Chrome Audio Rendering Prototype Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.h" 5 #include "content/renderer/pepper/pepper_platform_audio_output.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "content/browser/media/audio_output_impl.h"
13 #include "content/child/child_process.h" 14 #include "content/child/child_process.h"
14 #include "content/common/media/audio_messages.h" 15 #include "content/common/media/audio_messages.h"
15 #include "content/renderer/media/audio_message_filter.h" 16 #include "content/renderer/media/audio_message_filter.h"
16 #include "content/renderer/pepper/audio_helper.h" 17 #include "content/renderer/pepper/audio_helper.h"
17 #include "content/renderer/render_thread_impl.h" 18 #include "content/renderer/render_thread_impl.h"
18 #include "media/base/audio_hardware_config.h" 19 #include "media/base/audio_hardware_config.h"
19 #include "ppapi/shared_impl/ppb_audio_config_shared.h" 20 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
20 21
21 namespace content { 22 namespace content {
22 23
(...skipping 10 matching lines...) Expand all
33 source_render_frame_id, 34 source_render_frame_id,
34 client)) { 35 client)) {
35 // Balanced by Release invoked in 36 // Balanced by Release invoked in
36 // PepperPlatformAudioOutput::ShutDownOnIOThread(). 37 // PepperPlatformAudioOutput::ShutDownOnIOThread().
37 audio_output->AddRef(); 38 audio_output->AddRef();
38 return audio_output.get(); 39 return audio_output.get();
39 } 40 }
40 return NULL; 41 return NULL;
41 } 42 }
42 43
44 media::AudioOutputIPC* PepperPlatformAudioOutput::getIPC() {
45 return ipc_.get();
46 }
47
43 bool PepperPlatformAudioOutput::StartPlayback() { 48 bool PepperPlatformAudioOutput::StartPlayback() {
44 if (ipc_) { 49 if (ipc_) {
45 io_task_runner_->PostTask( 50 io_task_runner_->PostTask(
46 FROM_HERE, 51 FROM_HERE,
47 base::Bind(&PepperPlatformAudioOutput::StartPlaybackOnIOThread, this)); 52 base::Bind(&PepperPlatformAudioOutput::StartPlaybackOnIOThread, this));
48 return true; 53 return true;
49 } 54 }
50 return false; 55 return false;
51 } 56 }
52 57
(...skipping 19 matching lines...) Expand all
72 void PepperPlatformAudioOutput::OnStateChanged( 77 void PepperPlatformAudioOutput::OnStateChanged(
73 media::AudioOutputIPCDelegateState state) {} 78 media::AudioOutputIPCDelegateState state) {}
74 79
75 void PepperPlatformAudioOutput::OnDeviceAuthorized( 80 void PepperPlatformAudioOutput::OnDeviceAuthorized(
76 media::OutputDeviceStatus device_status, 81 media::OutputDeviceStatus device_status,
77 const media::AudioParameters& output_params) { 82 const media::AudioParameters& output_params) {
78 NOTREACHED(); 83 NOTREACHED();
79 } 84 }
80 85
81 void PepperPlatformAudioOutput::OnStreamCreated( 86 void PepperPlatformAudioOutput::OnStreamCreated(
87 mojom::AudioOutputStreamPtr* stream,
82 base::SharedMemoryHandle handle, 88 base::SharedMemoryHandle handle,
83 base::SyncSocket::Handle socket_handle, 89 base::SyncSocket::Handle socket_handle,
84 int length) { 90 int length) {
85 #if defined(OS_WIN) 91 #if defined(OS_WIN)
86 DCHECK(handle.IsValid()); 92 DCHECK(handle.IsValid());
87 DCHECK(socket_handle); 93 DCHECK(socket_handle);
88 #else 94 #else
89 DCHECK(base::SharedMemory::IsHandleValid(handle)); 95 DCHECK(base::SharedMemory::IsHandleValid(handle));
90 DCHECK_NE(-1, socket_handle); 96 DCHECK_NE(-1, socket_handle);
91 #endif 97 #endif
92 DCHECK(length); 98 DCHECK(length);
93 99
100 stream_ = stream;
94 if (base::ThreadTaskRunnerHandle::Get().get() == main_task_runner_.get()) { 101 if (base::ThreadTaskRunnerHandle::Get().get() == main_task_runner_.get()) {
95 // Must dereference the client only on the main thread. Shutdown may have 102 // Must dereference the client only on the main thread. Shutdown may have
96 // occurred while the request was in-flight, so we need to NULL check. 103 // occurred while the request was in-flight, so we need to NULL check.
97 if (client_) 104 if (client_)
98 client_->StreamCreated(handle, length, socket_handle); 105 client_->StreamCreated(handle, length, socket_handle);
99 } else { 106 } else {
100 main_task_runner_->PostTask( 107 main_task_runner_->PostTask(
101 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this, 108 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this,
102 handle, socket_handle, length)); 109 stream_, handle, socket_handle, length));
103 } 110 }
104 } 111 }
105 112
106 void PepperPlatformAudioOutput::OnIPCClosed() { ipc_.reset(); } 113 void PepperPlatformAudioOutput::OnIPCClosed() { ipc_.reset(); }
107 114
108 PepperPlatformAudioOutput::~PepperPlatformAudioOutput() { 115 PepperPlatformAudioOutput::~PepperPlatformAudioOutput() {
109 // Make sure we have been shut down. Warning: this will usually happen on 116 // Make sure we have been shut down. Warning: this will usually happen on
110 // the I/O thread! 117 // the I/O thread!
111 DCHECK(!ipc_); 118 DCHECK(!ipc_);
112 DCHECK(!client_); 119 DCHECK(!client_);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return; 176 return;
170 177
171 ipc_->CloseStream(); 178 ipc_->CloseStream();
172 ipc_.reset(); 179 ipc_.reset();
173 180
174 Release(); // Release for the delegate, balances out the reference taken in 181 Release(); // Release for the delegate, balances out the reference taken in
175 // PepperPlatformAudioOutput::Create. 182 // PepperPlatformAudioOutput::Create.
176 } 183 }
177 184
178 } // namespace content 185 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_platform_audio_output.h ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698