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

Unified Diff: media/audio/audio_util.cc

Issue 7755001: Workaround for race condition between audio host and renderer (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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
« media/audio/audio_util.h ('K') | « media/audio/audio_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_util.cc
===================================================================
--- media/audio/audio_util.cc (revision 98956)
+++ 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 in 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
« media/audio/audio_util.h ('K') | « media/audio/audio_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698