| Index: media/audio/audio_util.cc
|
| ===================================================================
|
| --- media/audio/audio_util.cc (revision 100908)
|
| +++ media/audio/audio_util.cc (working copy)
|
| @@ -21,6 +21,8 @@
|
|
|
| using base::subtle::Atomic32;
|
|
|
| +const uint32 kUnknownDataSize = static_cast<uint32>(-1);
|
| +
|
| namespace media {
|
|
|
| // TODO(fbarchard): Convert to intrinsics for better efficiency.
|
| @@ -257,7 +259,7 @@
|
| char* ptr = static_cast<char*>(shared_memory->memory()) + shared_memory_size;
|
| DCHECK_EQ(0u, reinterpret_cast<size_t>(ptr) & 3);
|
|
|
| - // Actual data size stored in the beginning of the buffer.
|
| + // 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);
|
| @@ -269,9 +271,25 @@
|
| char* ptr = static_cast<char*>(shared_memory->memory()) + shared_memory_size;
|
| DCHECK_EQ(0u, reinterpret_cast<size_t>(ptr) & 3);
|
|
|
| - // Set actual data size in the beginning of the buffer.
|
| + // 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;
|
| +}
|
| +
|
| } // namespace media
|
|
|