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

Side by Side Diff: ppapi/shared_impl/ppb_audio_shared.cc

Issue 309483015: Add trace events for PPB audio callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « no previous file | no next file » | 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 "ppapi/shared_impl/ppb_audio_shared.h" 5 #include "ppapi/shared_impl/ppb_audio_shared.h"
6 6
7 #include "base/debug/trace_event.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "ppapi/nacl_irt/public/irt_ppapi.h" 9 #include "ppapi/nacl_irt/public/irt_ppapi.h"
9 #include "ppapi/shared_impl/ppapi_globals.h" 10 #include "ppapi/shared_impl/ppapi_globals.h"
10 #include "ppapi/shared_impl/ppb_audio_config_shared.h" 11 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
11 #include "ppapi/shared_impl/proxy_lock.h" 12 #include "ppapi/shared_impl/proxy_lock.h"
12 13
13 namespace ppapi { 14 namespace ppapi {
14 15
15 namespace { 16 namespace {
16 bool g_nacl_mode = false; 17 bool g_nacl_mode = false;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void PPB_Audio_Shared::Run() { 206 void PPB_Audio_Shared::Run() {
206 int pending_data = 0; 207 int pending_data = 0;
207 while (sizeof(pending_data) == 208 while (sizeof(pending_data) ==
208 socket_->Receive(&pending_data, sizeof(pending_data))) { 209 socket_->Receive(&pending_data, sizeof(pending_data))) {
209 // |buffer_index_| must track the number of Receive() calls. See the Send() 210 // |buffer_index_| must track the number of Receive() calls. See the Send()
210 // call below for why this is important. 211 // call below for why this is important.
211 ++buffer_index_; 212 ++buffer_index_;
212 if (pending_data < 0) 213 if (pending_data < 0)
213 break; 214 break;
214 215
215 PP_TimeDelta latency = 216 {
216 static_cast<double>(pending_data) / bytes_per_second_; 217 TRACE_EVENT0("audio", "PPB_Audio_Shared::FireRenderCallback");
217 callback_.Run( 218 PP_TimeDelta latency =
218 client_buffer_.get(), client_buffer_size_bytes_, latency, user_data_); 219 static_cast<double>(pending_data) / bytes_per_second_;
220 callback_.Run(
221 client_buffer_.get(), client_buffer_size_bytes_, latency, user_data_);
222 }
219 223
220 // Deinterleave the audio data into the shared memory as floats. 224 // Deinterleave the audio data into the shared memory as floats.
221 audio_bus_->FromInterleaved(client_buffer_.get(), 225 audio_bus_->FromInterleaved(client_buffer_.get(),
222 audio_bus_->frames(), 226 audio_bus_->frames(),
223 kBitsPerAudioOutputSample / 8); 227 kBitsPerAudioOutputSample / 8);
224 228
225 // Let the other end know which buffer we just filled. The buffer index is 229 // Let the other end know which buffer we just filled. The buffer index is
226 // used to ensure the other end is getting the buffer it expects. For more 230 // used to ensure the other end is getting the buffer it expects. For more
227 // details on how this works see AudioSyncReader::WaitUntilDataIsReady(). 231 // details on how this works see AudioSyncReader::WaitUntilDataIsReady().
228 size_t bytes_sent = socket_->Send(&buffer_index_, sizeof(buffer_index_)); 232 size_t bytes_sent = socket_->Send(&buffer_index_, sizeof(buffer_index_));
229 if (bytes_sent != sizeof(buffer_index_)) 233 if (bytes_sent != sizeof(buffer_index_))
230 break; 234 break;
231 } 235 }
232 } 236 }
233 237
234 } // namespace ppapi 238 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698