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

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

Issue 225903006: PPAPI: Run clang_format.py on content/renderer/pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 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 | Annotate | Revision Log
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_audio_input_host.h" 5 #include "content/renderer/pepper/pepper_audio_input_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/renderer/pepper/pepper_media_device_manager.h" 9 #include "content/renderer/pepper/pepper_media_device_manager.h"
10 #include "content/renderer/pepper/pepper_platform_audio_input.h" 10 #include "content/renderer/pepper/pepper_platform_audio_input.h"
(...skipping 21 matching lines...) Expand all
32 return shared_memory.handle().fd; 32 return shared_memory.handle().fd;
33 #elif defined(OS_WIN) 33 #elif defined(OS_WIN)
34 return shared_memory.handle(); 34 return shared_memory.handle();
35 #else 35 #else
36 #error "Platform not supported." 36 #error "Platform not supported."
37 #endif 37 #endif
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 PepperAudioInputHost::PepperAudioInputHost( 42 PepperAudioInputHost::PepperAudioInputHost(RendererPpapiHostImpl* host,
43 RendererPpapiHostImpl* host, 43 PP_Instance instance,
44 PP_Instance instance, 44 PP_Resource resource)
45 PP_Resource resource)
46 : ResourceHost(host->GetPpapiHost(), instance, resource), 45 : ResourceHost(host->GetPpapiHost(), instance, resource),
47 renderer_ppapi_host_(host), 46 renderer_ppapi_host_(host),
48 audio_input_(NULL), 47 audio_input_(NULL),
49 enumeration_helper_( 48 enumeration_helper_(this,
50 this, 49 PepperMediaDeviceManager::GetForRenderView(
51 PepperMediaDeviceManager::GetForRenderView( 50 host->GetRenderViewForInstance(pp_instance())),
52 host->GetRenderViewForInstance(pp_instance())), 51 PP_DEVICETYPE_DEV_AUDIOCAPTURE,
53 PP_DEVICETYPE_DEV_AUDIOCAPTURE, 52 host->GetDocumentURL(instance)) {}
54 host->GetDocumentURL(instance)) {
55 }
56 53
57 PepperAudioInputHost::~PepperAudioInputHost() { 54 PepperAudioInputHost::~PepperAudioInputHost() { Close(); }
58 Close();
59 }
60 55
61 int32_t PepperAudioInputHost::OnResourceMessageReceived( 56 int32_t PepperAudioInputHost::OnResourceMessageReceived(
62 const IPC::Message& msg, 57 const IPC::Message& msg,
63 ppapi::host::HostMessageContext* context) { 58 ppapi::host::HostMessageContext* context) {
64 int32_t result = PP_ERROR_FAILED; 59 int32_t result = PP_ERROR_FAILED;
65 if (enumeration_helper_.HandleResourceMessage(msg, context, &result)) 60 if (enumeration_helper_.HandleResourceMessage(msg, context, &result))
66 return result; 61 return result;
67 62
68 IPC_BEGIN_MESSAGE_MAP(PepperAudioInputHost, msg) 63 IPC_BEGIN_MESSAGE_MAP(PepperAudioInputHost, msg)
69 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_Open, OnOpen) 64 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_Open, OnOpen)
70 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_StartOrStop, 65 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_StartOrStop,
71 OnStartOrStop); 66 OnStartOrStop);
72 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_AudioInput_Close, 67 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_AudioInput_Close, OnClose);
73 OnClose);
74 IPC_END_MESSAGE_MAP() 68 IPC_END_MESSAGE_MAP()
75 return PP_ERROR_FAILED; 69 return PP_ERROR_FAILED;
76 } 70 }
77 71
78 void PepperAudioInputHost::StreamCreated( 72 void PepperAudioInputHost::StreamCreated(
79 base::SharedMemoryHandle shared_memory_handle, 73 base::SharedMemoryHandle shared_memory_handle,
80 size_t shared_memory_size, 74 size_t shared_memory_size,
81 base::SyncSocket::Handle socket) { 75 base::SyncSocket::Handle socket) {
82 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket); 76 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket);
83 } 77 }
84 78
85 void PepperAudioInputHost::StreamCreationFailed() { 79 void PepperAudioInputHost::StreamCreationFailed() {
86 OnOpenComplete(PP_ERROR_FAILED, base::SharedMemory::NULLHandle(), 0, 80 OnOpenComplete(PP_ERROR_FAILED,
81 base::SharedMemory::NULLHandle(),
82 0,
87 base::SyncSocket::kInvalidHandle); 83 base::SyncSocket::kInvalidHandle);
88 } 84 }
89 85
90 int32_t PepperAudioInputHost::OnOpen( 86 int32_t PepperAudioInputHost::OnOpen(ppapi::host::HostMessageContext* context,
91 ppapi::host::HostMessageContext* context, 87 const std::string& device_id,
92 const std::string& device_id, 88 PP_AudioSampleRate sample_rate,
93 PP_AudioSampleRate sample_rate, 89 uint32_t sample_frame_count) {
94 uint32_t sample_frame_count) {
95 if (open_context_) 90 if (open_context_)
96 return PP_ERROR_INPROGRESS; 91 return PP_ERROR_INPROGRESS;
97 if (audio_input_) 92 if (audio_input_)
98 return PP_ERROR_FAILED; 93 return PP_ERROR_FAILED;
99 94
100 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); 95 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance());
101 if (!document_url.is_valid()) 96 if (!document_url.is_valid())
102 return PP_ERROR_FAILED; 97 return PP_ERROR_FAILED;
103 98
104 // When it is done, we'll get called back on StreamCreated() or 99 // When it is done, we'll get called back on StreamCreated() or
105 // StreamCreationFailed(). 100 // StreamCreationFailed().
106 RenderViewImpl* render_view = static_cast<RenderViewImpl*>( 101 RenderViewImpl* render_view = static_cast<RenderViewImpl*>(
107 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); 102 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()));
108 103
109 audio_input_ = PepperPlatformAudioInput::Create( 104 audio_input_ =
110 render_view->AsWeakPtr(), device_id, 105 PepperPlatformAudioInput::Create(render_view->AsWeakPtr(),
111 document_url, 106 device_id,
112 static_cast<int>(sample_rate), 107 document_url,
113 static_cast<int>(sample_frame_count), this); 108 static_cast<int>(sample_rate),
109 static_cast<int>(sample_frame_count),
110 this);
114 if (audio_input_) { 111 if (audio_input_) {
115 open_context_.reset(new ppapi::host::ReplyMessageContext( 112 open_context_.reset(new ppapi::host::ReplyMessageContext(
116 context->MakeReplyMessageContext())); 113 context->MakeReplyMessageContext()));
117 return PP_OK_COMPLETIONPENDING; 114 return PP_OK_COMPLETIONPENDING;
118 } else { 115 } else {
119 return PP_ERROR_FAILED; 116 return PP_ERROR_FAILED;
120 } 117 }
121 } 118 }
122 119
123 int32_t PepperAudioInputHost::OnStartOrStop( 120 int32_t PepperAudioInputHost::OnStartOrStop(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 audio_input_ = NULL; 204 audio_input_ = NULL;
208 205
209 if (open_context_) { 206 if (open_context_) {
210 open_context_->params.set_result(PP_ERROR_ABORTED); 207 open_context_->params.set_result(PP_ERROR_ABORTED);
211 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); 208 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply());
212 open_context_.reset(); 209 open_context_.reset();
213 } 210 }
214 } 211 }
215 212
216 } // namespace content 213 } // namespace content
217
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_audio_input_host.h ('k') | content/renderer/pepper/pepper_broker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698