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

Unified Diff: media/audio/fake_audio_output_stream.cc

Issue 3185022: Share one thread between all AudioOutputControllers instead of creating one per stream. (Closed)
Patch Set: - Created 10 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
« no previous file with comments | « media/audio/fake_audio_output_stream.h ('k') | media/audio/linux/alsa_output.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 47b7d3ea36a23360bff80204399968b4362aaa0e..4f9dd846235b8b5be15215e39c9cb0c47347ce9b 100644
--- a/media/audio/fake_audio_output_stream.cc
+++ b/media/audio/fake_audio_output_stream.cc
@@ -5,6 +5,7 @@
#include "media/audio/fake_audio_output_stream.h"
#include "base/at_exit.h"
+#include "base/logging.h"
bool FakeAudioOutputStream::has_created_fake_stream_ = false;
FakeAudioOutputStream* FakeAudioOutputStream::last_fake_stream_ = NULL;
@@ -15,7 +16,15 @@ AudioOutputStream* FakeAudioOutputStream::MakeFakeStream() {
base::AtExitManager::RegisterCallback(&DestroyLastFakeStream, NULL);
has_created_fake_stream_ = true;
- return new FakeAudioOutputStream();
+ FakeAudioOutputStream* new_stream = new FakeAudioOutputStream();
+
+ if (last_fake_stream_) {
+ DCHECK(last_fake_stream_->closed_);
+ delete last_fake_stream_;
+ }
+ last_fake_stream_ = new_stream;
+
+ return new_stream;
}
// static
@@ -55,20 +64,20 @@ void FakeAudioOutputStream::Close() {
callback_->OnClose(this);
callback_ = NULL;
}
-
- if (last_fake_stream_)
- delete last_fake_stream_;
- last_fake_stream_ = this;
+ closed_ = true;
}
FakeAudioOutputStream::FakeAudioOutputStream()
: volume_(0),
callback_(NULL),
- packet_size_(0) {
+ packet_size_(0),
+ closed_(false) {
}
// static
void FakeAudioOutputStream::DestroyLastFakeStream(void* param) {
- if (last_fake_stream_)
+ if (last_fake_stream_) {
+ DCHECK(last_fake_stream_->closed_);
delete last_fake_stream_;
+ }
}
« no previous file with comments | « media/audio/fake_audio_output_stream.h ('k') | media/audio/linux/alsa_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698