diff options
author | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 22:19:33 +0000 |
---|---|---|
committer | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 22:19:33 +0000 |
commit | 9a499a01f4e66080673c8a08496e9c3b488c3fdf (patch) | |
tree | 44fc9d9d220404f59c0cd709183c062357f475dd /ppapi/shared_impl | |
parent | b6c1d7cd9f79ed599e0fef24569fee1b955693ce (diff) | |
download | chromium_src-9a499a01f4e66080673c8a08496e9c3b488c3fdf.zip chromium_src-9a499a01f4e66080673c8a08496e9c3b488c3fdf.tar.gz chromium_src-9a499a01f4e66080673c8a08496e9c3b488c3fdf.tar.bz2 |
Introduce shared_memory_support media target for PPAPI.
Allows PPAPI to directly utilize shared memory utility code instead
of duplicating it and CHECK'ing for equivalency.
Required to eventually convert PPAPI to using an AudioBus and floats
in PPB_Audio_Shared::Run(). http://crbug.com/114700
BUG=123203
TEST=unittests
Review URL: https://chromiumcodereview.appspot.com/10826296
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r-- | ppapi/shared_impl/ppb_audio_shared.cc | 35 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_audio_shared.h | 3 |
2 files changed, 6 insertions, 32 deletions
diff --git a/ppapi/shared_impl/ppb_audio_shared.cc b/ppapi/shared_impl/ppb_audio_shared.cc index 1a62130..5cf3002 100644 --- a/ppapi/shared_impl/ppb_audio_shared.cc +++ b/ppapi/shared_impl/ppb_audio_shared.cc @@ -5,10 +5,9 @@ #include "ppapi/shared_impl/ppb_audio_shared.h" #include "base/logging.h" +#include "media/audio/shared_memory_util.h" #include "ppapi/shared_impl/ppapi_globals.h" -using base::subtle::Atomic32; - namespace ppapi { #if defined(OS_NACL) @@ -18,29 +17,6 @@ PP_ThreadFunctions thread_functions; } #endif // defined(OS_NACL) -// FIXME: The following two functions (TotalSharedMemorySizeInBytes, -// SetActualDataSizeInBytes) are copied from audio_util.cc. -// Remove these functions once a minimal media library is provided for them. -// code.google.com/p/chromium/issues/detail?id=123203 - -uint32 TotalSharedMemorySizeInBytes(uint32 packet_size) { - // Need to reserve extra 4 bytes for size of data. - return packet_size + sizeof(Atomic32); -} - -void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, - uint32 shared_memory_size, - uint32 actual_data_size) { - char* ptr = static_cast<char*>(shared_memory->memory()) + shared_memory_size; - DCHECK_EQ(0u, reinterpret_cast<size_t>(ptr) & 3); - - // Set actual data size at the end of the buffer. - base::subtle::Release_Store(reinterpret_cast<volatile Atomic32*>(ptr), - actual_data_size); -} - -const int PPB_Audio_Shared::kPauseMark = -1; - PPB_Audio_Shared::PPB_Audio_Shared() : playing_(false), shared_memory_size_(0), @@ -93,7 +69,8 @@ void PPB_Audio_Shared::SetStreamInfo( shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); shared_memory_size_ = shared_memory_size; - if (!shared_memory_->Map(TotalSharedMemorySizeInBytes(shared_memory_size_))) { + if (!shared_memory_->Map( + media::TotalSharedMemorySizeInBytes(shared_memory_size_))) { PpapiGlobals::Get()->LogWithSource(instance, PP_LOGLEVEL_WARNING, "", "Failed to map shared memory for PPB_Audio_Shared."); } @@ -167,12 +144,12 @@ void PPB_Audio_Shared::Run() { while (sizeof(pending_data) == socket_->Receive(&pending_data, sizeof(pending_data)) && - pending_data != kPauseMark) { + pending_data != media::kPauseMark) { callback_(buffer, shared_memory_size_, user_data_); // Let the host know we are done. - SetActualDataSizeInBytes(shared_memory_.get(), shared_memory_size_, - shared_memory_size_); + media::SetActualDataSizeInBytes( + shared_memory_.get(), shared_memory_size_, shared_memory_size_); } } diff --git a/ppapi/shared_impl/ppb_audio_shared.h b/ppapi/shared_impl/ppb_audio_shared.h index cde075b..8858e5c 100644 --- a/ppapi/shared_impl/ppb_audio_shared.h +++ b/ppapi/shared_impl/ppb_audio_shared.h @@ -29,9 +29,6 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared PPB_Audio_Shared(); virtual ~PPB_Audio_Shared(); - // Keep in sync with media::AudioOutputController::kPauseMark. - static const int kPauseMark; - bool playing() const { return playing_; } // Sets the callback information that the background thread will use. This |