Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: media/audio/audio_util.cc

Issue 10826296: Introduce shared_memory_support media target for PPAPI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_util.h ('k') | media/audio/shared_memory_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_util.cc
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index 56bc14d3219e51f49a8bf20554946ff2464aa642..19aef1242fe532658d7b6d06514d0a77685878a2 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.
@@ -437,56 +432,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() {
« no previous file with comments | « media/audio/audio_util.h ('k') | media/audio/shared_memory_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698