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

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

Issue 1538563002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fix. git cl format. Rebase. Created 5 years 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
« no previous file with comments | « media/renderers/audio_renderer_impl.cc ('k') | 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/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "media/audio/audio_parameters.h"
9 #include "ppapi/nacl_irt/public/irt_ppapi.h" 10 #include "ppapi/nacl_irt/public/irt_ppapi.h"
10 #include "ppapi/shared_impl/ppapi_globals.h" 11 #include "ppapi/shared_impl/ppapi_globals.h"
11 #include "ppapi/shared_impl/ppb_audio_config_shared.h" 12 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
12 #include "ppapi/shared_impl/proxy_lock.h" 13 #include "ppapi/shared_impl/proxy_lock.h"
13 14
14 namespace ppapi { 15 namespace ppapi {
15 16
16 namespace { 17 namespace {
17 bool g_nacl_mode = false; 18 bool g_nacl_mode = false;
18 // Because this is static, the function pointers will be NULL initially. 19 // Because this is static, the function pointers will be NULL initially.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 kAudioOutputChannels * (kBitsPerAudioOutputSample / 8) * sample_rate; 106 kAudioOutputChannels * (kBitsPerAudioOutputSample / 8) * sample_rate;
106 buffer_index_ = 0; 107 buffer_index_ = 0;
107 108
108 if (!shared_memory_->Map(shared_memory_size_)) { 109 if (!shared_memory_->Map(shared_memory_size_)) {
109 PpapiGlobals::Get()->LogWithSource( 110 PpapiGlobals::Get()->LogWithSource(
110 instance, 111 instance,
111 PP_LOGLEVEL_WARNING, 112 PP_LOGLEVEL_WARNING,
112 std::string(), 113 std::string(),
113 "Failed to map shared memory for PPB_Audio_Shared."); 114 "Failed to map shared memory for PPB_Audio_Shared.");
114 } else { 115 } else {
115 audio_bus_ = media::AudioBus::WrapMemory( 116 DCHECK_EQ(shared_memory_size_,
116 kAudioOutputChannels, sample_frame_count, shared_memory_->memory()); 117 sizeof(media::AudioOutputBufferParameters) +
118 media::AudioBus::CalculateMemorySize(kAudioOutputChannels,
119 sample_frame_count));
120 media::AudioOutputBuffer* buffer =
121 reinterpret_cast<media::AudioOutputBuffer*>(shared_memory_->memory());
122 audio_bus_ = media::AudioBus::WrapMemory(kAudioOutputChannels,
123 sample_frame_count, buffer->audio);
117 // Setup integer audio buffer for user audio data. 124 // Setup integer audio buffer for user audio data.
118 client_buffer_size_bytes_ = audio_bus_->frames() * audio_bus_->channels() * 125 client_buffer_size_bytes_ = audio_bus_->frames() * audio_bus_->channels() *
119 kBitsPerAudioOutputSample / 8; 126 kBitsPerAudioOutputSample / 8;
120 client_buffer_.reset(new uint8_t[client_buffer_size_bytes_]); 127 client_buffer_.reset(new uint8_t[client_buffer_size_bytes_]);
121 } 128 }
122 129
123 StartThread(); 130 StartThread();
124 } 131 }
125 132
126 void PPB_Audio_Shared::StartThread() { 133 void PPB_Audio_Shared::StartThread() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Let the other end know which buffer we just filled. The buffer index is 240 // Let the other end know which buffer we just filled. The buffer index is
234 // used to ensure the other end is getting the buffer it expects. For more 241 // used to ensure the other end is getting the buffer it expects. For more
235 // details on how this works see AudioSyncReader::WaitUntilDataIsReady(). 242 // details on how this works see AudioSyncReader::WaitUntilDataIsReady().
236 size_t bytes_sent = socket_->Send(&buffer_index_, sizeof(buffer_index_)); 243 size_t bytes_sent = socket_->Send(&buffer_index_, sizeof(buffer_index_));
237 if (bytes_sent != sizeof(buffer_index_)) 244 if (bytes_sent != sizeof(buffer_index_))
238 break; 245 break;
239 } 246 }
240 } 247 }
241 248
242 } // namespace ppapi 249 } // namespace ppapi
OLDNEW
« no previous file with comments | « media/renderers/audio_renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698