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

Side by Side Diff: webkit/plugins/ppapi/ppb_audio_impl.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_audio_impl.h ('k') | webkit/plugins/ppapi/ppb_audio_input_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/plugins/ppapi/ppb_audio_impl.h" 5 #include "webkit/plugins/ppapi/ppb_audio_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/audio/audio_output_controller.h" 8 #include "media/audio/audio_output_controller.h"
9 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/c/ppb_audio.h" 10 #include "ppapi/c/ppb_audio.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (!audio_) 105 if (!audio_)
106 return PP_FALSE; 106 return PP_FALSE;
107 if (!playing()) 107 if (!playing())
108 return PP_TRUE; 108 return PP_TRUE;
109 if (!audio_->StopPlayback()) 109 if (!audio_->StopPlayback())
110 return PP_FALSE; 110 return PP_FALSE;
111 SetStopPlaybackState(); 111 SetStopPlaybackState();
112 return PP_TRUE; 112 return PP_TRUE;
113 } 113 }
114 114
115 int32_t PPB_Audio_Impl::OpenTrusted(PP_Resource config, 115 int32_t PPB_Audio_Impl::OpenTrusted(
116 PP_CompletionCallback create_callback) { 116 PP_Resource config,
117 scoped_refptr<TrackedCallback> create_callback) {
117 // Validate the config and keep a reference to it. 118 // Validate the config and keep a reference to it.
118 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); 119 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true);
119 if (enter.failed()) 120 if (enter.failed())
120 return PP_ERROR_FAILED; 121 return PP_ERROR_FAILED;
121 config_ = config; 122 config_ = config;
122 123
123 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); 124 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
124 if (!plugin_delegate) 125 if (!plugin_delegate)
125 return PP_ERROR_FAILED; 126 return PP_ERROR_FAILED;
126 127
127 // When the stream is created, we'll get called back on StreamCreated(). 128 // When the stream is created, we'll get called back on StreamCreated().
128 DCHECK(!audio_); 129 DCHECK(!audio_);
129 audio_ = plugin_delegate->CreateAudioOutput( 130 audio_ = plugin_delegate->CreateAudioOutput(
130 enter.object()->GetSampleRate(), enter.object()->GetSampleFrameCount(), 131 enter.object()->GetSampleRate(), enter.object()->GetSampleFrameCount(),
131 this); 132 this);
132 if (!audio_) 133 if (!audio_)
133 return PP_ERROR_FAILED; 134 return PP_ERROR_FAILED;
134 135
135 // At this point, we are guaranteeing ownership of the completion 136 // At this point, we are guaranteeing ownership of the completion
136 // callback. Audio promises to fire the completion callback 137 // callback. Audio promises to fire the completion callback
137 // once and only once. 138 // once and only once.
138 SetCreateCallback(new TrackedCallback(this, create_callback)); 139 SetCreateCallback(create_callback);
139 140
140 return PP_OK_COMPLETIONPENDING; 141 return PP_OK_COMPLETIONPENDING;
141 } 142 }
142 143
143 int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) { 144 int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) {
144 return GetSyncSocketImpl(sync_socket); 145 return GetSyncSocketImpl(sync_socket);
145 } 146 }
146 147
147 int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, 148 int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle,
148 uint32_t* shm_size) { 149 uint32_t* shm_size) {
149 return GetSharedMemoryImpl(shm_handle, shm_size); 150 return GetSharedMemoryImpl(shm_handle, shm_size);
150 } 151 }
151 152
152 void PPB_Audio_Impl::OnSetStreamInfo( 153 void PPB_Audio_Impl::OnSetStreamInfo(
153 base::SharedMemoryHandle shared_memory_handle, 154 base::SharedMemoryHandle shared_memory_handle,
154 size_t shared_memory_size, 155 size_t shared_memory_size,
155 base::SyncSocket::Handle socket_handle) { 156 base::SyncSocket::Handle socket_handle) {
156 SetStreamInfo(pp_instance(), shared_memory_handle, shared_memory_size, 157 SetStreamInfo(pp_instance(), shared_memory_handle, shared_memory_size,
157 socket_handle); 158 socket_handle);
158 } 159 }
159 160
160 } // namespace ppapi 161 } // namespace ppapi
161 } // namespace webkit 162 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_audio_impl.h ('k') | webkit/plugins/ppapi/ppb_audio_input_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698