| Index: media/audio/fake_audio_output_stream.cc
|
| diff --git a/media/audio/fake_audio_output_stream.cc b/media/audio/fake_audio_output_stream.cc
|
| index fe0d857a1c46c749740ec2a9f4d676e936f24d70..fbcddb166d952e99863fab9a8a31f0a41d38e437 100644
|
| --- a/media/audio/fake_audio_output_stream.cc
|
| +++ b/media/audio/fake_audio_output_stream.cc
|
| @@ -6,33 +6,21 @@
|
|
|
| #include "base/at_exit.h"
|
| #include "base/logging.h"
|
| +#include "media/audio/audio_manager_base.h"
|
|
|
| -bool FakeAudioOutputStream::has_created_fake_stream_ = false;
|
| -FakeAudioOutputStream* FakeAudioOutputStream::last_fake_stream_ = NULL;
|
| +FakeAudioOutputStream* FakeAudioOutputStream::current_fake_stream_ = NULL;
|
|
|
| // static
|
| AudioOutputStream* FakeAudioOutputStream::MakeFakeStream(
|
| + AudioManagerBase* manager,
|
| const AudioParameters& params) {
|
| - if (!has_created_fake_stream_)
|
| - base::AtExitManager::RegisterCallback(&DestroyLastFakeStream, NULL);
|
| - has_created_fake_stream_ = true;
|
| -
|
| - FakeAudioOutputStream* new_stream = new FakeAudioOutputStream(params);
|
| -
|
| - if (last_fake_stream_) {
|
| - DCHECK(last_fake_stream_->closed_);
|
| - delete last_fake_stream_;
|
| - }
|
| - last_fake_stream_ = new_stream;
|
| -
|
| + FakeAudioOutputStream* new_stream = new FakeAudioOutputStream(manager,
|
| + params);
|
| + DCHECK(current_fake_stream_ == NULL);
|
| + current_fake_stream_ = new_stream;
|
| return new_stream;
|
| }
|
|
|
| -// static
|
| -FakeAudioOutputStream* FakeAudioOutputStream::GetLastFakeStream() {
|
| - return last_fake_stream_;
|
| -}
|
| -
|
| bool FakeAudioOutputStream::Open() {
|
| if (packet_size_ < sizeof(int16))
|
| return false;
|
| @@ -40,6 +28,11 @@ bool FakeAudioOutputStream::Open() {
|
| return true;
|
| }
|
|
|
| +// static
|
| +FakeAudioOutputStream* FakeAudioOutputStream::GetCurrentFakeStream() {
|
| + return current_fake_stream_;
|
| +}
|
| +
|
| void FakeAudioOutputStream::Start(AudioSourceCallback* callback) {
|
| callback_ = callback;
|
| memset(buffer_.get(), 0, packet_size_);
|
| @@ -61,21 +54,19 @@ void FakeAudioOutputStream::GetVolume(double* volume) {
|
|
|
| void FakeAudioOutputStream::Close() {
|
| closed_ = true;
|
| + audio_manager_->ReleaseOutputStream(this);
|
| }
|
|
|
| -FakeAudioOutputStream::FakeAudioOutputStream(const AudioParameters& params)
|
| - : volume_(0),
|
| +FakeAudioOutputStream::FakeAudioOutputStream(AudioManagerBase* manager,
|
| + const AudioParameters& params)
|
| + : audio_manager_(manager),
|
| + volume_(0),
|
| callback_(NULL),
|
| packet_size_(params.GetPacketSize()),
|
| closed_(false) {
|
| }
|
|
|
| -FakeAudioOutputStream::~FakeAudioOutputStream() {}
|
| -
|
| -// static
|
| -void FakeAudioOutputStream::DestroyLastFakeStream(void* param) {
|
| - if (last_fake_stream_) {
|
| - DCHECK(last_fake_stream_->closed_);
|
| - delete last_fake_stream_;
|
| - }
|
| +FakeAudioOutputStream::~FakeAudioOutputStream() {
|
| + if (current_fake_stream_ == this)
|
| + current_fake_stream_ = NULL;
|
| }
|
|
|