summaryrefslogtreecommitdiffstats
path: root/media/base/audio_fifo.h
diff options
context:
space:
mode:
Diffstat (limited to 'media/base/audio_fifo.h')
-rw-r--r--media/base/audio_fifo.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/media/base/audio_fifo.h b/media/base/audio_fifo.h
index 7f654b2..e978ace 100644
--- a/media/base/audio_fifo.h
+++ b/media/base/audio_fifo.h
@@ -5,6 +5,7 @@
#ifndef MEDIA_BASE_AUDIO_FIFO_H_
#define MEDIA_BASE_AUDIO_FIFO_H_
+#include "base/atomicops.h"
#include "media/base/audio_bus.h"
#include "media/base/media_export.h"
@@ -14,6 +15,8 @@ namespace media {
// The maximum number of audio frames in the FIFO is set at construction and
// can not be extended dynamically. The allocated memory is utilized as a
// ring buffer.
+// This class is thread-safe in the limited sense that one thread may call
+// Push(), while a second thread calls Consume().
class MEDIA_EXPORT AudioFifo {
public:
// Creates a new AudioFifo and allocates |channels| of length |frames|.
@@ -35,11 +38,11 @@ class MEDIA_EXPORT AudioFifo {
void Clear();
// Number of actual audio frames in the FIFO.
- int frames() const { return frames_; }
+ int frames() const;
- private:
int max_frames() const { return max_frames_; }
+ private:
// The actual FIFO is an audio bus implemented as a ring buffer.
scoped_ptr<AudioBus> audio_bus_;
@@ -48,7 +51,8 @@ class MEDIA_EXPORT AudioFifo {
const int max_frames_;
// Number of actual elements in the FIFO.
- int frames_;
+ volatile base::subtle::Atomic32 frames_pushed_;
+ volatile base::subtle::Atomic32 frames_consumed_;
// Current read position.
int read_pos_;