summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authornfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 01:33:36 +0000
committernfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 01:33:36 +0000
commit7b42b7ba10faf12e90f77a446424c9b753d9fc4f (patch)
tree832b6daff6b6c51e9e5e76ab36b14078e9c165a1 /ppapi
parent9616dd19e3e8ff9f7224a01563eef622ba169e9f (diff)
downloadchromium_src-7b42b7ba10faf12e90f77a446424c9b753d9fc4f.zip
chromium_src-7b42b7ba10faf12e90f77a446424c9b753d9fc4f.tar.gz
chromium_src-7b42b7ba10faf12e90f77a446424c9b753d9fc4f.tar.bz2
Bump total shm size for dup'd handle passed into NaCl.
BUG=http://code.google.com/p/chromium/issues/detail?id=124863 TEST=various CWS titles Review URL: http://codereview.chromium.org/10213015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_rpc_server.cc10
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h8
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.cc26
3 files changed, 24 insertions, 20 deletions
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_rpc_server.cc
index f0f771b..f7224f0 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_rpc_server.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_rpc_server.cc
@@ -71,7 +71,7 @@ void StreamCreatedCallback(void* user_data, int32_t result) {
const int kInvalidIntHandle = int(nacl::kInvalidHandle);
int sync_socket_handle = kInvalidIntHandle;
int shared_memory_handle = kInvalidIntHandle;
- uint32_t shared_memory_size = 0;
+ uint32_t audio_buffer_size = 0;
if (PP_OK != audioTrusted->GetSyncSocket(data->audio_id,
&sync_socket_handle)) {
return;
@@ -81,12 +81,14 @@ void StreamCreatedCallback(void* user_data, int32_t result) {
}
if (PP_OK != audioTrusted->GetSharedMemory(data->audio_id,
&shared_memory_handle,
- &shared_memory_size)) {
+ &audio_buffer_size)) {
return;
}
if (kInvalidIntHandle == shared_memory_handle) {
return;
}
+ uint32_t total_shared_memory_size =
+ ppapi_proxy::TotalAudioSharedMemorySizeInBytes(audio_buffer_size);
nacl::DescWrapperFactory factory;
NaClHandle nacl_shm_handle = NaClHandle(shared_memory_handle);
NaClHandle nacl_sync_handle = NaClHandle(sync_socket_handle);
@@ -95,7 +97,7 @@ void StreamCreatedCallback(void* user_data, int32_t result) {
return;
}
nacl::scoped_ptr<nacl::DescWrapper> shm_wrapper(factory.ImportShmHandle(
- nacl_shm_dup_handle, shared_memory_size));
+ nacl_shm_dup_handle, total_shared_memory_size));
NaClHandle nacl_sync_dup_handle = NaClDuplicateNaClHandle(nacl_sync_handle);
if (nacl::kInvalidHandle == nacl_sync_dup_handle) {
return;
@@ -112,7 +114,7 @@ void StreamCreatedCallback(void* user_data, int32_t result) {
nacl_srpc_channel,
data->audio_id,
nacl_shm,
- shared_memory_size,
+ audio_buffer_size,
nacl_socket));
}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h
index 600f098..e23cd9d 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h
@@ -81,6 +81,14 @@ const struct PP_ThreadFunctions* GetThreadCreator();
// PPAPI constants used in the proxy.
extern const PP_Resource kInvalidResourceId;
+// The following function TotalSharedMemorySizeInBytes, is copied & similar
+// to the one in audio_util.cc. This function includes optional fields
+// stored at the end of the audio buffer.
+inline size_t TotalAudioSharedMemorySizeInBytes(size_t audio_buffer_size) {
+ // Include optional field that communicates the number of bytes written.
+ return audio_buffer_size + sizeof(uint32_t);
+}
+
} // namespace ppapi_proxy
#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_GLOBALS_H_
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.cc
index fb0f3b7..c7164dd 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.cc
@@ -29,17 +29,11 @@ size_t ceil64k(size_t n) {
return (n + 0xFFFF) & (~0xFFFF);
}
-// The following two functions (TotalSharedMemorySizeInBytes,
-// SetActualDataSizeInBytes) are copied & similar to audio_util.cc.
-
-uint32_t TotalSharedMemorySizeInBytes(size_t packet_size) {
- // Need to reserve extra 4 bytes for size of data.
- return ceil64k(packet_size + sizeof(uint32_t));
-}
-
-void SetActualDataSizeInBytes(void* audio_buffer,
- uint32_t buffer_size_in_bytes,
- uint32_t actual_size_in_bytes) {
+// The following function SetAudioActualDataSizeInBytes, is copied & similar
+// to the one in audio_util.cc.
+void SetAudioActualDataSizeInBytes(void* audio_buffer,
+ uint32_t buffer_size_in_bytes,
+ uint32_t actual_size_in_bytes) {
char* end = static_cast<char*>(audio_buffer) + buffer_size_in_bytes;
DCHECK(0 == (reinterpret_cast<size_t>(end) & 3));
volatile uint32_t* end32 = reinterpret_cast<volatile uint32_t*>(end);
@@ -71,7 +65,7 @@ PluginAudio::~PluginAudio() {
GetInterface()->StopPlayback(resource_);
// Unmap the shared memory buffer, if present.
if (shm_buffer_) {
- munmap(shm_buffer_, TotalSharedMemorySizeInBytes(shm_size_));
+ munmap(shm_buffer_, ceil64k(TotalAudioSharedMemorySizeInBytes(shm_size_)));
shm_buffer_ = NULL;
shm_size_ = 0;
}
@@ -109,9 +103,9 @@ void PluginAudio::AudioThread(void* self) {
audio->user_data_);
// Signal audio backend by writing buffer length at end of buffer.
// (Note: NaCl applications will always write the entire buffer.)
- SetActualDataSizeInBytes(audio->shm_buffer_,
- audio->shm_size_,
- audio->shm_size_);
+ SetAudioActualDataSizeInBytes(audio->shm_buffer_,
+ audio->shm_size_,
+ audio->shm_size_);
}
}
@@ -123,7 +117,7 @@ void PluginAudio::StreamCreated(NaClSrpcImcDescType socket,
shm_ = shm;
shm_size_ = shm_size;
shm_buffer_ = mmap(NULL,
- TotalSharedMemorySizeInBytes(shm_size),
+ ceil64k(TotalAudioSharedMemorySizeInBytes(shm_size)),
PROT_READ | PROT_WRITE,
MAP_SHARED,
shm,