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

Unified Diff: media/base/audio_fifo.h

Issue 10909185: Add Mac OS X synchronized audio I/O back-end (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
Index: media/base/audio_fifo.h
===================================================================
--- media/base/audio_fifo.h (revision 157152)
+++ media/base/audio_fifo.h (working copy)
@@ -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 @@
// 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 @@
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 @@
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_;

Powered by Google App Engine
This is Rietveld 408576698