summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorraymond.liu@intel.com <raymond.liu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-18 05:50:15 +0000
committerraymond.liu@intel.com <raymond.liu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-18 05:50:15 +0000
commit3e3715e8cd62029ac8e3f17dcb235e47ed0a9a11 (patch)
tree7ebee524e817180cdabed46c94b9e272c8aa8544 /ppapi
parentdc8cba6dfc67d707c3c1a3d04b4bcba99187f090 (diff)
downloadchromium_src-3e3715e8cd62029ac8e3f17dcb235e47ed0a9a11.zip
chromium_src-3e3715e8cd62029ac8e3f17dcb235e47ed0a9a11.tar.gz
chromium_src-3e3715e8cd62029ac8e3f17dcb235e47ed0a9a11.tar.bz2
Notify audio host that audio rendering in Pepper plugin is done.
BUG=120837 TEST=See bug Review URL: http://codereview.chromium.org/9921006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/shared_impl/ppb_audio_shared.cc30
1 files changed, 29 insertions, 1 deletions
diff --git a/ppapi/shared_impl/ppb_audio_shared.cc b/ppapi/shared_impl/ppb_audio_shared.cc
index 63bd471..00742cc 100644
--- a/ppapi/shared_impl/ppb_audio_shared.cc
+++ b/ppapi/shared_impl/ppb_audio_shared.cc
@@ -6,8 +6,31 @@
#include "base/logging.h"
+using base::subtle::Atomic32;
+
namespace ppapi {
+// 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()
@@ -66,7 +89,8 @@ void PPB_Audio_Shared::SetStreamInfo(
shared_memory_size_ = shared_memory_size;
if (callback_) {
- shared_memory_->Map(shared_memory_size_);
+ shared_memory_->Map(TotalSharedMemorySizeInBytes(
+ shared_memory_size_));
// In common case StartPlayback() was called before StreamCreated().
if (playing_)
@@ -90,6 +114,10 @@ void PPB_Audio_Shared::Run() {
socket_->Receive(&pending_data, sizeof(pending_data)) &&
pending_data != 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_);
}
}