Commit 50efb113 authored by glider@chromium.org's avatar glider@chromium.org

Remove the atomic operations from media::AudioFifo, making it truly thread-unsafe.

This class isn't used in multithreaded fashion anymore.

BUG=NONE

Review URL: https://codereview.chromium.org/337163004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277796 0039d316-1c4b-4281-b951-d872f2087c98
parent 64eff593
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
#include "base/logging.h" #include "base/logging.h"
using base::subtle::Atomic32;
using base::subtle::NoBarrier_Store;
namespace media { namespace media {
// Given current position in the FIFO, the maximum number of elements in the // Given current position in the FIFO, the maximum number of elements in the
...@@ -52,7 +49,6 @@ AudioFifo::~AudioFifo() {} ...@@ -52,7 +49,6 @@ AudioFifo::~AudioFifo() {}
int AudioFifo::frames() const { int AudioFifo::frames() const {
int delta = frames_pushed_ - frames_consumed_; int delta = frames_pushed_ - frames_consumed_;
base::subtle::MemoryBarrier();
return delta; return delta;
} }
...@@ -83,12 +79,7 @@ void AudioFifo::Push(const AudioBus* source) { ...@@ -83,12 +79,7 @@ void AudioFifo::Push(const AudioBus* source) {
} }
} }
// Ensure the data is *really* written before updating |frames_pushed_|. frames_pushed_ += source_size;
base::subtle::MemoryBarrier();
Atomic32 new_frames_pushed = frames_pushed_ + source_size;
NoBarrier_Store(&frames_pushed_, new_frames_pushed);
DCHECK_LE(frames(), max_frames()); DCHECK_LE(frames(), max_frames());
write_pos_ = UpdatePos(write_pos_, source_size, max_frames()); write_pos_ = UpdatePos(write_pos_, source_size, max_frames());
} }
...@@ -128,9 +119,7 @@ void AudioFifo::Consume(AudioBus* destination, ...@@ -128,9 +119,7 @@ void AudioFifo::Consume(AudioBus* destination,
} }
} }
Atomic32 new_frames_consumed = frames_consumed_ + frames_to_consume; frames_consumed_ += frames_to_consume;
NoBarrier_Store(&frames_consumed_, new_frames_consumed);
read_pos_ = UpdatePos(read_pos_, frames_to_consume, max_frames()); read_pos_ = UpdatePos(read_pos_, frames_to_consume, max_frames());
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef MEDIA_BASE_AUDIO_FIFO_H_ #ifndef MEDIA_BASE_AUDIO_FIFO_H_
#define MEDIA_BASE_AUDIO_FIFO_H_ #define MEDIA_BASE_AUDIO_FIFO_H_
#include "base/atomicops.h"
#include "media/base/audio_bus.h" #include "media/base/audio_bus.h"
#include "media/base/media_export.h" #include "media/base/media_export.h"
...@@ -15,8 +14,7 @@ namespace media { ...@@ -15,8 +14,7 @@ namespace media {
// The maximum number of audio frames in the FIFO is set at construction and // 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 // can not be extended dynamically. The allocated memory is utilized as a
// ring buffer. // ring buffer.
// This class is thread-safe in the limited sense that one thread may call // This class is thread-unsafe.
// Push(), while a second thread calls Consume().
class MEDIA_EXPORT AudioFifo { class MEDIA_EXPORT AudioFifo {
public: public:
// Creates a new AudioFifo and allocates |channels| of length |frames|. // Creates a new AudioFifo and allocates |channels| of length |frames|.
...@@ -51,8 +49,8 @@ class MEDIA_EXPORT AudioFifo { ...@@ -51,8 +49,8 @@ class MEDIA_EXPORT AudioFifo {
const int max_frames_; const int max_frames_;
// Number of actual elements in the FIFO. // Number of actual elements in the FIFO.
volatile base::subtle::Atomic32 frames_pushed_; int frames_pushed_;
volatile base::subtle::Atomic32 frames_consumed_; int frames_consumed_;
// Current read position. // Current read position.
int read_pos_; int read_pos_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment