| 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 "media/audio/shared_memory_util.h" | 8 #include "media/audio/shared_memory_util.h" |
| 9 #include "ppapi/shared_impl/ppapi_globals.h" | 9 #include "ppapi/shared_impl/ppapi_globals.h" |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 base::SharedMemoryHandle shared_memory_handle, | 73 base::SharedMemoryHandle shared_memory_handle, |
| 74 size_t shared_memory_size, | 74 size_t shared_memory_size, |
| 75 base::SyncSocket::Handle socket_handle, | 75 base::SyncSocket::Handle socket_handle, |
| 76 int sample_frame_count) { | 76 int sample_frame_count) { |
| 77 socket_.reset(new base::CancelableSyncSocket(socket_handle)); | 77 socket_.reset(new base::CancelableSyncSocket(socket_handle)); |
| 78 shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); | 78 shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); |
| 79 shared_memory_size_ = shared_memory_size; | 79 shared_memory_size_ = shared_memory_size; |
| 80 | 80 |
| 81 if (!shared_memory_->Map( | 81 if (!shared_memory_->Map( |
| 82 media::TotalSharedMemorySizeInBytes(shared_memory_size_))) { | 82 media::TotalSharedMemorySizeInBytes(shared_memory_size_))) { |
| 83 PpapiGlobals::Get()->LogWithSource(instance, PP_LOGLEVEL_WARNING, "", | 83 PpapiGlobals::Get()->LogWithSource( |
| 84 "Failed to map shared memory for PPB_Audio_Shared."); | 84 instance, |
| 85 PP_LOGLEVEL_WARNING, |
| 86 std::string(), |
| 87 "Failed to map shared memory for PPB_Audio_Shared."); |
| 85 } else { | 88 } else { |
| 86 audio_bus_ = media::AudioBus::WrapMemory( | 89 audio_bus_ = media::AudioBus::WrapMemory( |
| 87 kChannels, sample_frame_count, shared_memory_->memory()); | 90 kChannels, sample_frame_count, shared_memory_->memory()); |
| 88 // Setup integer audio buffer for user audio data. | 91 // Setup integer audio buffer for user audio data. |
| 89 client_buffer_size_bytes_ = | 92 client_buffer_size_bytes_ = |
| 90 audio_bus_->frames() * audio_bus_->channels() * kBytesPerSample; | 93 audio_bus_->frames() * audio_bus_->channels() * kBytesPerSample; |
| 91 client_buffer_.reset(new uint8_t[client_buffer_size_bytes_]); | 94 client_buffer_.reset(new uint8_t[client_buffer_size_bytes_]); |
| 92 } | 95 } |
| 93 | 96 |
| 94 StartThread(); | 97 StartThread(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // padding for alignment, there may be more data available than this. We're | 175 // padding for alignment, there may be more data available than this. We're |
| 173 // relying on AudioSyncReader::Read() to parse this with that in mind. | 176 // relying on AudioSyncReader::Read() to parse this with that in mind. |
| 174 // Rename these methods to Set/GetActualFrameCount(). | 177 // Rename these methods to Set/GetActualFrameCount(). |
| 175 media::SetActualDataSizeInBytes( | 178 media::SetActualDataSizeInBytes( |
| 176 shared_memory_.get(), shared_memory_size_, | 179 shared_memory_.get(), shared_memory_size_, |
| 177 audio_bus_->frames() * bytes_per_frame); | 180 audio_bus_->frames() * bytes_per_frame); |
| 178 } | 181 } |
| 179 } | 182 } |
| 180 | 183 |
| 181 } // namespace ppapi | 184 } // namespace ppapi |
| OLD | NEW |