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

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

Issue 10828023: PPAPI/NaCl: Make NaClIPCAdapter transfer handles more generally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review? Created 8 years, 4 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 "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 "ppapi/shared_impl/ppapi_globals.h" 8 #include "ppapi/shared_impl/ppapi_globals.h"
9 9
10 using base::subtle::Atomic32; 10 using base::subtle::Atomic32;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 void PPB_Audio_Shared::SetStreamInfo( 87 void PPB_Audio_Shared::SetStreamInfo(
88 PP_Instance instance, 88 PP_Instance instance,
89 base::SharedMemoryHandle shared_memory_handle, 89 base::SharedMemoryHandle shared_memory_handle,
90 size_t shared_memory_size, 90 size_t shared_memory_size,
91 base::SyncSocket::Handle socket_handle) { 91 base::SyncSocket::Handle socket_handle) {
92 socket_.reset(new base::CancelableSyncSocket(socket_handle)); 92 socket_.reset(new base::CancelableSyncSocket(socket_handle));
93 shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); 93 shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false));
94 shared_memory_size_ = shared_memory_size; 94 shared_memory_size_ = shared_memory_size;
95 95
96 if (!shared_memory_->Map(TotalSharedMemorySizeInBytes(shared_memory_size_))) { 96 if (!shared_memory_->Map(TotalSharedMemorySizeInBytes(
97 static_cast<uint32>(shared_memory_size_)))) {
97 PpapiGlobals::Get()->LogWithSource(instance, PP_LOGLEVEL_WARNING, "", 98 PpapiGlobals::Get()->LogWithSource(instance, PP_LOGLEVEL_WARNING, "",
98 "Failed to map shared memory for PPB_Audio_Shared."); 99 "Failed to map shared memory for PPB_Audio_Shared.");
99 } 100 }
100 101
101 StartThread(); 102 StartThread();
102 } 103 }
103 104
104 void PPB_Audio_Shared::StartThread() { 105 void PPB_Audio_Shared::StartThread() {
105 // Don't start the thread unless all our state is set up correctly. 106 // Don't start the thread unless all our state is set up correctly.
106 if (!playing_ || !callback_ || !socket_.get() || !shared_memory_->memory()) 107 if (!playing_ || !callback_ || !socket_.get() || !shared_memory_->memory())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 162 }
162 #endif 163 #endif
163 164
164 void PPB_Audio_Shared::Run() { 165 void PPB_Audio_Shared::Run() {
165 int pending_data; 166 int pending_data;
166 void* buffer = shared_memory_->memory(); 167 void* buffer = shared_memory_->memory();
167 168
168 while (sizeof(pending_data) == 169 while (sizeof(pending_data) ==
169 socket_->Receive(&pending_data, sizeof(pending_data)) && 170 socket_->Receive(&pending_data, sizeof(pending_data)) &&
170 pending_data != kPauseMark) { 171 pending_data != kPauseMark) {
171 callback_(buffer, shared_memory_size_, user_data_); 172 callback_(buffer, static_cast<uint32_t>(shared_memory_size_), user_data_);
172 173
173 // Let the host know we are done. 174 // Let the host know we are done.
174 SetActualDataSizeInBytes(shared_memory_.get(), shared_memory_size_, 175 SetActualDataSizeInBytes(shared_memory_.get(),
175 shared_memory_size_); 176 static_cast<uint32>(shared_memory_size_),
177 static_cast<uint32>(shared_memory_size_));
176 } 178 }
177 } 179 }
178 180
179 } // namespace ppapi 181 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698