OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |