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 | |
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
31 files changed, 264 insertions, 159 deletions
diff --git a/content/browser/renderer_host/media/audio_renderer_host.cc b/content/browser/renderer_host/media/audio_renderer_host.cc index 27b8825..0042f28 100644 --- a/content/browser/renderer_host/media/audio_renderer_host.cc +++ b/content/browser/renderer_host/media/audio_renderer_host.cc @@ -12,7 +12,7 @@ #include "content/browser/renderer_host/media/audio_sync_reader.h" #include "content/common/media/audio_messages.h" #include "content/public/browser/media_observer.h" -#include "media/audio/audio_util.h" +#include "media/audio/shared_memory_util.h" using content::BrowserMessageFilter; using content::BrowserThread; diff --git a/content/browser/renderer_host/media/audio_sync_reader.cc b/content/browser/renderer_host/media/audio_sync_reader.cc index 113c4fc..2f06f55 100644 --- a/content/browser/renderer_host/media/audio_sync_reader.cc +++ b/content/browser/renderer_host/media/audio_sync_reader.cc @@ -10,7 +10,7 @@ #include "base/shared_memory.h" #include "base/threading/platform_thread.h" #include "media/audio/audio_buffers_state.h" -#include "media/audio/audio_util.h" +#include "media/audio/shared_memory_util.h" #if defined(OS_WIN) const int kMinIntervalBetweenReadCallsInMs = 10; @@ -31,7 +31,7 @@ bool AudioSyncReader::DataReady() { // media::AudioOutputController::SyncReader implementations. void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { - if (bytes != static_cast<uint32>(media::AudioOutputController::kPauseMark)) { + if (bytes != static_cast<uint32>(media::kPauseMark)) { // Store unknown length of data into buffer, so we later // can find out if data became available. media::SetUnknownDataSize( diff --git a/content/content_common.gypi b/content/content_common.gypi index 54974ae..749b93b 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -10,6 +10,7 @@ '../gpu/gpu.gyp:gpu_ipc', '../ipc/ipc.gyp:ipc', '../media/media.gyp:media', + '../media/media.gyp:shared_memory_support', '../net/net.gyp:net', '../ppapi/ppapi_internal.gyp:ppapi_shared', '../skia/skia.gyp:skia', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 7c46308..469f112 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -216,6 +216,7 @@ '../ipc/ipc.gyp:test_support_ipc', '../jingle/jingle.gyp:jingle_glue_test_util', '../media/media.gyp:media_test_support', + '../media/media.gyp:shared_memory_support', '../net/net.gyp:net_test_support', '../skia/skia.gyp:skia', '../testing/gmock.gyp:gmock', diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc index 60dd285..69b7797 100644 --- a/media/audio/audio_output_controller.cc +++ b/media/audio/audio_output_controller.cc @@ -11,6 +11,7 @@ #include "base/threading/platform_thread.h" #include "base/threading/thread_restrictions.h" #include "base/time.h" +#include "media/audio/shared_memory_util.h" using base::Time; using base::TimeDelta; @@ -18,9 +19,6 @@ using base::WaitableEvent; namespace media { -// Signal a pause in low-latency mode. -const int AudioOutputController::kPauseMark = -1; - // Polling-related constants. const int AudioOutputController::kPollNumAttempts = 3; const int AudioOutputController::kPollPauseInMilliseconds = 3; diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h index a8857a2..03b0959 100644 --- a/media/audio/audio_output_controller.h +++ b/media/audio/audio_output_controller.h @@ -68,10 +68,6 @@ class MEDIA_EXPORT AudioOutputController : public base::RefCountedThreadSafe<AudioOutputController>, public AudioOutputStream::AudioSourceCallback { public: - // Value sent by the controller to the renderer in low-latency mode - // indicating that the stream is paused. - static const int kPauseMark; - // An event handler that receives events from the AudioOutputController. The // following methods are called on the audio manager thread. class MEDIA_EXPORT EventHandler { diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc index 994fa40..da86f97 100644 --- a/media/audio/audio_output_device.cc +++ b/media/audio/audio_output_device.cc @@ -10,6 +10,7 @@ #include "base/time.h" #include "media/audio/audio_output_controller.h" #include "media/audio/audio_util.h" +#include "media/audio/shared_memory_util.h" namespace media { @@ -253,7 +254,7 @@ void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() { // Called whenever we receive notifications about pending data. void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) { - if (pending_data == AudioOutputController::kPauseMark) { + if (pending_data == kPauseMark) { memset(shared_memory_.memory(), 0, memory_length_); SetActualDataSizeInBytes(&shared_memory_, memory_length_, 0); return; diff --git a/media/audio/audio_output_device_unittest.cc b/media/audio/audio_output_device_unittest.cc index 152e958..14a7a35 100644 --- a/media/audio/audio_output_device_unittest.cc +++ b/media/audio/audio_output_device_unittest.cc @@ -11,8 +11,8 @@ #include "base/sync_socket.h" #include "base/test/test_timeouts.h" #include "media/audio/audio_output_device.h" -#include "media/audio/audio_util.h" #include "media/audio/sample_rates.h" +#include "media/audio/shared_memory_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock_mutant.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc index d54f277..1dabae9 100644 --- a/media/audio/audio_util.cc +++ b/media/audio/audio_util.cc @@ -12,16 +12,15 @@ // that a lot of the functions can be simplified and made more elegant. Revisit // after other audio cleanup is done. (crbug.com/120319) +#include "media/audio/audio_util.h" + #include <algorithm> #include <limits> -#include "base/atomicops.h" #include "base/basictypes.h" #include "base/logging.h" -#include "base/shared_memory.h" #include "base/time.h" #include "media/audio/audio_parameters.h" -#include "media/audio/audio_util.h" #include "media/base/audio_bus.h" #if defined(OS_MACOSX) @@ -36,10 +35,6 @@ #include "media/base/media_switches.h" #endif -using base::subtle::Atomic32; - -const uint32 kUnknownDataSize = static_cast<uint32>(-1); - namespace media { // TODO(fbarchard): Convert to intrinsics for better efficiency. @@ -483,56 +478,6 @@ size_t GetHighLatencyOutputBufferSize(int sample_rate) { return samples; } -// When transferring data in the shared memory, first word is size of data -// in bytes. Actual data starts immediately after it. - -uint32 TotalSharedMemorySizeInBytes(uint32 packet_size) { - // Need to reserve extra 4 bytes for size of data. - return packet_size + sizeof(Atomic32); -} - -uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size) { - return shared_memory_created_size - sizeof(Atomic32); -} - -uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, - uint32 shared_memory_size) { - char* ptr = static_cast<char*>(shared_memory->memory()) + shared_memory_size; - DCHECK_EQ(0u, reinterpret_cast<size_t>(ptr) & 3); - - // Actual data size stored at the end of the buffer. - uint32 actual_data_size = - base::subtle::Acquire_Load(reinterpret_cast<volatile Atomic32*>(ptr)); - return std::min(actual_data_size, shared_memory_size); -} - -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); -} - -void SetUnknownDataSize(base::SharedMemory* shared_memory, - uint32 shared_memory_size) { - SetActualDataSizeInBytes(shared_memory, shared_memory_size, kUnknownDataSize); -} - -bool IsUnknownDataSize(base::SharedMemory* shared_memory, - uint32 shared_memory_size) { - char* ptr = static_cast<char*>(shared_memory->memory()) + shared_memory_size; - DCHECK_EQ(0u, reinterpret_cast<size_t>(ptr) & 3); - - // Actual data size stored at the end of the buffer. - uint32 actual_data_size = - base::subtle::Acquire_Load(reinterpret_cast<volatile Atomic32*>(ptr)); - return actual_data_size == kUnknownDataSize; -} - #if defined(OS_WIN) bool IsWASAPISupported() { diff --git a/media/audio/audio_util.h b/media/audio/audio_util.h index d25fdf9..b329be1 100644 --- a/media/audio/audio_util.h +++ b/media/audio/audio_util.h @@ -111,21 +111,6 @@ MEDIA_EXPORT ChannelLayout GetAudioInputHardwareChannelLayout( // conjunction with AUDIO_PCM_LINEAR. MEDIA_EXPORT size_t GetHighLatencyOutputBufferSize(int sample_rate); -// Functions that handle data buffer passed between processes in the shared -// memory. Called on both IPC sides. - -MEDIA_EXPORT uint32 TotalSharedMemorySizeInBytes(uint32 packet_size); -MEDIA_EXPORT uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size); -MEDIA_EXPORT uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, - uint32 shared_memory_size); -MEDIA_EXPORT void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, - uint32 shared_memory_size, - uint32 actual_data_size); -MEDIA_EXPORT void SetUnknownDataSize(base::SharedMemory* shared_memory, - uint32 shared_memory_size); -MEDIA_EXPORT bool IsUnknownDataSize(base::SharedMemory* shared_memory, - uint32 shared_memory_size); - #if defined(OS_WIN) // Does Windows support WASAPI? We are checking in lot of places, and diff --git a/media/audio/shared_memory_util.cc b/media/audio/shared_memory_util.cc new file mode 100644 index 0000000..d79f54d --- /dev/null +++ b/media/audio/shared_memory_util.cc @@ -0,0 +1,70 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/audio/shared_memory_util.h" + +#include "base/atomicops.h" +#include "base/logging.h" + +using base::subtle::Atomic32; + +static const uint32 kUnknownDataSize = static_cast<uint32>(-1); + +namespace media { + +uint32 TotalSharedMemorySizeInBytes(uint32 packet_size) { + // Need to reserve extra 4 bytes for size of data. + return packet_size + sizeof(Atomic32); +} + +uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size) { + return shared_memory_created_size - sizeof(Atomic32); +} + +uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, + uint32 shared_memory_size) { + char* ptr = static_cast<char*>(shared_memory->memory()) + shared_memory_size; + DCHECK_EQ(0u, reinterpret_cast<size_t>(ptr) & 3); + + // Actual data size stored at the end of the buffer. + uint32 actual_data_size = + base::subtle::Acquire_Load(reinterpret_cast<volatile Atomic32*>(ptr)); + return std::min(actual_data_size, shared_memory_size); +} + +void SetActualDataSizeInBytes(void* shared_memory_ptr, + uint32 shared_memory_size, + uint32 actual_data_size) { + char* ptr = static_cast<char*>(shared_memory_ptr) + 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); +} + +void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, + uint32 shared_memory_size, + uint32 actual_data_size) { + SetActualDataSizeInBytes(shared_memory->memory(), + shared_memory_size, actual_data_size); +} + +void SetUnknownDataSize(base::SharedMemory* shared_memory, + uint32 shared_memory_size) { + SetActualDataSizeInBytes(shared_memory, shared_memory_size, kUnknownDataSize); +} + +bool IsUnknownDataSize(base::SharedMemory* shared_memory, + uint32 shared_memory_size) { + char* ptr = static_cast<char*>(shared_memory->memory()) + shared_memory_size; + DCHECK_EQ(0u, reinterpret_cast<size_t>(ptr) & 3); + + // Actual data size stored at the end of the buffer. + uint32 actual_data_size = + base::subtle::Acquire_Load(reinterpret_cast<volatile Atomic32*>(ptr)); + return actual_data_size == kUnknownDataSize; +} + +} // namespace media diff --git a/media/audio/shared_memory_util.h b/media/audio/shared_memory_util.h new file mode 100644 index 0000000..1255b92 --- /dev/null +++ b/media/audio/shared_memory_util.h @@ -0,0 +1,39 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_AUDIO_SHARED_MEMORY_UTIL_H_ +#define MEDIA_AUDIO_SHARED_MEMORY_UTIL_H_ + +#include "base/basictypes.h" +#include "base/shared_memory.h" +#include "media/base/media_export.h" + +namespace media { + +// Value sent by the controller to the renderer in low-latency mode +// indicating that the stream is paused. +enum { kPauseMark = -1 }; + +// Functions that handle data buffer passed between processes in the shared +// memory. Called on both IPC sides. These are necessary because the shared +// memory has a layout: the last word in the block is the data size in bytes. + +MEDIA_EXPORT uint32 TotalSharedMemorySizeInBytes(uint32 packet_size); +MEDIA_EXPORT uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size); +MEDIA_EXPORT uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, + uint32 shared_memory_size); +MEDIA_EXPORT void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, + uint32 shared_memory_size, + uint32 actual_data_size); +MEDIA_EXPORT void SetActualDataSizeInBytes(void* shared_memory_ptr, + uint32 shared_memory_size, + uint32 actual_data_size); +MEDIA_EXPORT void SetUnknownDataSize(base::SharedMemory* shared_memory, + uint32 shared_memory_size); +MEDIA_EXPORT bool IsUnknownDataSize(base::SharedMemory* shared_memory, + uint32 shared_memory_size); + +} // namespace media + +#endif // MEDIA_AUDIO_SHARED_MEMORY_UTIL_H_ diff --git a/media/base/channel_layout.cc b/media/base/channel_layout.cc index f65828d..8bf02ea 100644 --- a/media/base/channel_layout.cc +++ b/media/base/channel_layout.cc @@ -23,7 +23,6 @@ static const int kLayoutToChannels[] = { 8, // CHANNEL_LAYOUT_7POINT1_WIDE 2}; // CHANNEL_LAYOUT_STEREO_DOWNMIX -#if defined(OS_MACOSX) || defined(USE_PULSEAUDIO) const int kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX] = { // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR @@ -80,7 +79,6 @@ const int kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX] = { // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR | StL | StR }; -#endif int ChannelLayoutToChannelCount(ChannelLayout layout) { return kLayoutToChannels[layout]; diff --git a/media/base/channel_layout.h b/media/base/channel_layout.h index ac10661..9e88420 100644 --- a/media/base/channel_layout.h +++ b/media/base/channel_layout.h @@ -5,7 +5,6 @@ #ifndef MEDIA_BASE_CHANNEL_LAYOUT_H_ #define MEDIA_BASE_CHANNEL_LAYOUT_H_ -#include "build/build_config.h" #include "media/base/media_export.h" enum ChannelLayout { @@ -78,15 +77,14 @@ enum Channels { CHANNELS_MAX }; -#if defined(OS_MACOSX) || defined(USE_PULSEAUDIO) // The channel orderings for each layout as specified by FFmpeg. // Values represent the index of each channel in each layout. For example, the // left side surround sound channel in FFmpeg's 5.1 layout is in the 5th // position (because the order is L, R, C, LFE, LS, RS), so // kChannelOrderings[CHANNEL_LAYOUT_5POINT1][SIDE_LEFT] = 4; // Values of -1 mean the channel at that index is not used for that layout. -extern const int kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX]; -#endif +MEDIA_EXPORT extern const int +kChannelOrderings[CHANNEL_LAYOUT_MAX][CHANNELS_MAX]; // Returns the number of channels in a given ChannelLayout. MEDIA_EXPORT int ChannelLayoutToChannelCount(ChannelLayout layout); diff --git a/media/media.gyp b/media/media.gyp index 17e3c39..94f5227 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -12,6 +12,27 @@ }, 'targets': [ { + # Minimal target for NaCl and other renderer side media clients which only + # need to send audio data across the shared memory to the browser process. + 'target_name': 'shared_memory_support', + 'type': '<(component)', + 'dependencies': [ + '../base/base.gyp:base', + ], + 'defines': [ + 'MEDIA_IMPLEMENTATION', + ], + 'include_dirs': [ + '..', + ], + 'includes': [ + 'shared_memory_support.gypi', + ], + 'sources': [ + '<@(shared_memory_support_sources)', + ], + }, + { 'target_name': 'media', 'type': '<(component)', 'dependencies': [ @@ -19,6 +40,7 @@ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../build/temp_gyp/googleurl.gyp:googleurl', '../crypto/crypto.gyp:crypto', + 'shared_memory_support', '../ui/ui.gyp:ui', 'yuv_convert', ], @@ -73,8 +95,6 @@ 'audio/audio_output_mixer.h', 'audio/audio_output_proxy.cc', 'audio/audio_output_proxy.h', - 'audio/audio_parameters.cc', - 'audio/audio_parameters.h', 'audio/audio_util.cc', 'audio/audio_util.h', 'audio/cross_process_notification.cc', @@ -137,8 +157,6 @@ 'audio/win/waveout_output_win.h', 'base/android/media_jni_registrar.cc', 'base/android/media_jni_registrar.h', - 'base/audio_bus.cc', - 'base/audio_bus.h', 'base/audio_decoder.cc', 'base/audio_decoder.h', 'base/audio_decoder_config.cc', @@ -157,8 +175,6 @@ 'base/buffers.h', 'base/byte_queue.cc', 'base/byte_queue.h', - 'base/channel_layout.cc', - 'base/channel_layout.h', 'base/clock.cc', 'base/clock.h', 'base/data_buffer.cc', @@ -181,7 +197,6 @@ 'base/filter_collection.h', 'base/media.h', 'base/media_android.cc', - 'base/media_export.h', 'base/media_log.cc', 'base/media_log.h', 'base/media_log_event.h', @@ -671,6 +686,7 @@ 'dependencies': [ 'media', 'media_test_support', + 'shared_memory_support', 'yuv_convert', '../base/base.gyp:base', '../base/base.gyp:base_i18n', diff --git a/media/media_untrusted.gyp b/media/media_untrusted.gyp new file mode 100644 index 0000000..4abbe56 --- /dev/null +++ b/media/media_untrusted.gyp @@ -0,0 +1,44 @@ +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'chromium_code': 1, + }, + 'includes': [ + '../native_client/build/untrusted.gypi', + ], + 'conditions': [ + ['disable_nacl==0 and disable_nacl_untrusted==0', { + 'targets': [ + { + 'target_name': 'shared_memory_support_untrusted', + 'type': 'none', + 'variables': { + 'nacl_untrusted_build': 1, + 'nlib_target': 'libshared_memory_support_untrusted.a', + 'build_glibc': 0, + 'build_newlib': 1, + }, + 'dependencies': [ + '../native_client/tools.gyp:prep_toolchain', + '../base/base_untrusted.gyp:base_untrusted', + ], + 'defines': [ + 'MEDIA_IMPLEMENTATION', + ], + 'include_dirs': [ + '..', + ], + 'includes': [ + 'shared_memory_support.gypi', + ], + 'sources': [ + '<@(shared_memory_support_sources)', + ], + }, + ], + }], + ], +} diff --git a/media/shared_memory_support.gypi b/media/shared_memory_support.gypi new file mode 100644 index 0000000..f91edf5 --- /dev/null +++ b/media/shared_memory_support.gypi @@ -0,0 +1,23 @@ +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'chromium_code': 1, + # These are defined here because we need to build this library both for + # the general media pipeline and again for the untrusted NaCl target. + 'shared_memory_support_sources': [ + 'audio/audio_parameters.cc', + 'audio/audio_parameters.h', + 'audio/shared_memory_util.cc', + 'audio/shared_memory_util.h', + 'base/audio_bus.cc', + 'base/audio_bus.h', + 'base/channel_layout.cc', + 'base/channel_layout.h', + 'base/limits.h', + 'base/media_export.h', + ], + }, +} diff --git a/ppapi/native_client/native_client.gyp b/ppapi/native_client/native_client.gyp index b528c0e..37a9564 100644 --- a/ppapi/native_client/native_client.gyp +++ b/ppapi/native_client/native_client.gyp @@ -76,6 +76,8 @@ '-lsrpc', '-limc_syscalls', '-lplatform', + '-lbase_untrusted', + '-lshared_memory_support_untrusted', '-lgio', '-Wl,--end-group', '-lm', @@ -113,7 +115,9 @@ # once native_client/build/untrusted.gypi no longer needs them. 'extra_deps64': [ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppruntime.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libimc_syscalls.a', @@ -121,7 +125,9 @@ ], 'extra_deps32': [ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppruntime.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libimc_syscalls.a', @@ -129,7 +135,9 @@ ], 'extra_deps_newlib64': [ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libppruntime.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libimc_syscalls.a', @@ -137,7 +145,9 @@ ], 'extra_deps_newlib32': [ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libppruntime.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libimc_syscalls.a', @@ -145,7 +155,9 @@ ], 'extra_deps_glibc64': [ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libppruntime.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libimc_syscalls.a', @@ -153,7 +165,9 @@ ], 'extra_deps_glibc32': [ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libppruntime.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libimc_syscalls.a', @@ -161,7 +175,9 @@ ], 'extra_deps_arm': [ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libppruntime.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libimc_syscalls.a', @@ -170,6 +186,8 @@ }, 'dependencies': [ 'src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp:ppruntime_lib', + '../../base/base_untrusted.gyp:base_untrusted', + '../../media/media_untrusted.gyp:shared_memory_support_untrusted', '../../native_client/src/untrusted/irt/irt.gyp:irt_browser_lib', '../../native_client/src/shared/srpc/srpc.gyp:srpc_lib', '../../native_client/src/shared/platform/platform.gyp:platform_lib', @@ -210,6 +228,7 @@ '-lgpu_ipc_untrusted', '-lipc_untrusted', '-lbase_untrusted', + '-lshared_memory_support_untrusted', '-lsrpc', '-limc_syscalls', '-lplatform', @@ -260,6 +279,7 @@ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libipc_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libimc_syscalls.a', @@ -277,6 +297,7 @@ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libipc_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libimc_syscalls.a', @@ -294,6 +315,7 @@ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libipc_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libimc_syscalls.a', @@ -311,6 +333,7 @@ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libipc_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libimc_syscalls.a', @@ -328,6 +351,7 @@ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libipc_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libimc_syscalls.a', @@ -345,6 +369,7 @@ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libipc_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libimc_syscalls.a', @@ -362,6 +387,7 @@ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libipc_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libbase_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libirt_browser.a', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libshared_memory_support_untrusted.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libsrpc.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libplatform.a', '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libimc_syscalls.a', @@ -379,6 +405,7 @@ '../../gpu/gpu_untrusted.gyp:gpu_ipc_untrusted', '../../ipc/ipc_untrusted.gyp:ipc_untrusted', '../../base/base_untrusted.gyp:base_untrusted', + '../../media/media_untrusted.gyp:shared_memory_support_untrusted', '../../native_client/src/untrusted/irt/irt.gyp:irt_browser_lib', '../../native_client/src/shared/srpc/srpc.gyp:srpc_lib', '../../native_client/src/shared/platform/platform.gyp:platform_lib', diff --git a/ppapi/native_client/src/shared/ppapi_proxy/DEPS b/ppapi/native_client/src/shared/ppapi_proxy/DEPS index 1b9100d..f8bca48 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/DEPS +++ b/ppapi/native_client/src/shared/ppapi_proxy/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+native_client/src/trusted/plugin", "+gpu", + "+media", "+native_client/src/shared/imc", "+native_client/src/shared/srpc", "+native_client/src/trusted/desc", 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 c3f480c..4224a85 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 @@ -13,6 +13,7 @@ #include "native_client/src/shared/ppapi_proxy/utility.h" #include "native_client/src/trusted/desc/nacl_desc_invalid.h" #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" +#include "media/audio/shared_memory_util.h" #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_config.h" #include "ppapi/c/pp_errors.h" @@ -88,7 +89,7 @@ void StreamCreatedCallback(void* user_data, int32_t result) { return; } size_t total_shared_memory_size = - ppapi_proxy::TotalAudioSharedMemorySizeInBytes(audio_buffer_size); + media::TotalSharedMemorySizeInBytes(audio_buffer_size); nacl::DescWrapperFactory factory; NaClHandle nacl_shm_handle = NaClHandle(shared_memory_handle); NaClHandle nacl_sync_handle = NaClHandle(sync_socket_handle); 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 e23cd9d..600f098 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h @@ -81,14 +81,6 @@ 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 2a01b97..18558e6 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 @@ -15,6 +15,7 @@ #include "native_client/src/shared/ppapi_proxy/plugin_resource.h" #include "native_client/src/shared/ppapi_proxy/utility.h" #include "native_client/src/shared/srpc/nacl_srpc.h" +#include "media/audio/shared_memory_util.h" #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_config.h" #include "ppapi/cpp/module_impl.h" @@ -29,19 +30,6 @@ size_t ceil64k(size_t n) { return (n + 0xFFFF) & (~0xFFFF); } -// 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); - // Set actual data size at the end of the buffer. - __sync_synchronize(); - *end32 = actual_size_in_bytes; -} - } // namespace PluginAudio::PluginAudio() : @@ -65,7 +53,8 @@ PluginAudio::~PluginAudio() { GetInterface()->StopPlayback(resource_); // Unmap the shared memory buffer, if present. if (shm_buffer_) { - munmap(shm_buffer_, ceil64k(TotalAudioSharedMemorySizeInBytes(shm_size_))); + munmap(shm_buffer_, + ceil64k(media::TotalSharedMemorySizeInBytes(shm_size_))); shm_buffer_ = NULL; shm_size_ = 0; } @@ -103,9 +92,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.) - SetAudioActualDataSizeInBytes(audio->shm_buffer_, - audio->shm_size_, - audio->shm_size_); + media::SetActualDataSizeInBytes(audio->shm_buffer_, + audio->shm_size_, + audio->shm_size_); } } @@ -117,7 +106,7 @@ void PluginAudio::StreamCreated(NaClSrpcImcDescType socket, shm_ = shm; shm_size_ = shm_size; shm_buffer_ = mmap(NULL, - ceil64k(TotalAudioSharedMemorySizeInBytes(shm_size)), + ceil64k(media::TotalSharedMemorySizeInBytes(shm_size)), PROT_READ | PROT_WRITE, MAP_SHARED, shm, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp index 558e1a9..6aa09c5 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp @@ -11,7 +11,8 @@ 'target_name': 'ppruntime_lib', 'type': 'none', 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain' + '<(DEPTH)/native_client/tools.gyp:prep_toolchain', + '<(DEPTH)/media/media_untrusted.gyp:shared_memory_support_untrusted', ], 'variables': { 'nlib_target': 'libppruntime.a', @@ -19,6 +20,7 @@ 'build_newlib': 1, 'include_dirs': [ '<(DEPTH)/gpu', + '<(DEPTH)/media', '<(DEPTH)/third_party/khronos', '<(DEPTH)/ppapi/native_client/src/shared/ppapi_proxy/untrusted', ], diff --git a/ppapi/native_client/src/trusted/plugin/plugin.gyp b/ppapi/native_client/src/trusted/plugin/plugin.gyp index f080c49..3521409 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.gyp +++ b/ppapi/native_client/src/trusted/plugin/plugin.gyp @@ -60,6 +60,7 @@ 'target_base': 'ppNaClPlugin', }, 'dependencies': [ + '<(DEPTH)/media/media.gyp:shared_memory_support', '<(DEPTH)/native_client/src/shared/gio/gio.gyp:gio', '<(DEPTH)/native_client/src/shared/imc/imc.gyp:imc', '<(DEPTH)/native_client/src/shared/platform/platform.gyp:platform', @@ -92,6 +93,7 @@ ], }, 'dependencies': [ + '<(DEPTH)/media/media.gyp:shared_memory_support', '<(DEPTH)/native_client/src/shared/gio/gio.gyp:gio', '<(DEPTH)/native_client/src/shared/imc/imc.gyp:imc', '<(DEPTH)/native_client/src/shared/platform/platform.gyp:platform', diff --git a/ppapi/ppapi_host.gypi b/ppapi/ppapi_host.gypi index c0cdfa0..8357033 100644 --- a/ppapi/ppapi_host.gypi +++ b/ppapi/ppapi_host.gypi @@ -13,6 +13,7 @@ 'ppapi_internal.gyp:ppapi_shared', '../base/base.gyp:base', '../ipc/ipc.gyp:ipc', + '../media/media.gyp:shared_memory_support', '../ui/surface/surface.gyp:surface', ], 'defines': [ diff --git a/ppapi/ppapi_internal.gyp b/ppapi/ppapi_internal.gyp index d4f1497..8eed2eb 100644 --- a/ppapi/ppapi_internal.gyp +++ b/ppapi/ppapi_internal.gyp @@ -46,6 +46,7 @@ '../gpu/command_buffer/command_buffer.gyp:gles2_utils', '../gpu/gpu.gyp:command_buffer_client', '../gpu/gpu.gyp:gles2_implementation', + '../media/media.gyp:shared_memory_support', '../net/net.gyp:net', '../skia/skia.gyp:skia', '../third_party/icu/icu.gyp:icuuc', diff --git a/ppapi/ppapi_shared_untrusted.gyp b/ppapi/ppapi_shared_untrusted.gyp index e0a08b4..fb6a765 100644 --- a/ppapi/ppapi_shared_untrusted.gyp +++ b/ppapi/ppapi_shared_untrusted.gyp @@ -36,6 +36,7 @@ '../gpu/command_buffer/command_buffer_untrusted.gyp:gles2_utils_untrusted', '../gpu/gpu_untrusted.gyp:command_buffer_client_untrusted', '../gpu/gpu_untrusted.gyp:gles2_implementation_untrusted', + '../media/media_untrusted.gyp:shared_memory_support_untrusted', ], }, ], diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi index 0f52b17..ba244c9 100644 --- a/ppapi/ppapi_tests.gypi +++ b/ppapi/ppapi_tests.gypi @@ -133,6 +133,7 @@ '../gpu/gpu.gyp:gpu_ipc', '../ipc/ipc.gyp:ipc', '../ipc/ipc.gyp:test_support_ipc', + '../media/media.gyp:shared_memory_support', '../testing/gmock.gyp:gmock', '../testing/gtest.gyp:gtest', '../ui/surface/surface.gyp:surface', 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 diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc index 7024aea..96504aa 100644 --- a/webkit/plugins/ppapi/ppb_audio_impl.cc +++ b/webkit/plugins/ppapi/ppb_audio_impl.cc @@ -53,8 +53,6 @@ PP_Resource PPB_Audio_Impl::Create(PP_Instance instance, scoped_refptr<PPB_Audio_Impl> audio(new PPB_Audio_Impl(instance)); if (!audio->Init(config, audio_callback, user_data)) return 0; - CHECK(media::AudioOutputController::kPauseMark == - ::ppapi::PPB_Audio_Shared::kPauseMark); return audio->GetReference(); } |