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

Unified Diff: media/audio/audio_manager.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/audio_manager.h ('k') | media/audio/audio_manager_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_manager.cc
diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7148d214072e2d22c1c0603b31bb47a3522671c1
--- /dev/null
+++ b/media/audio/audio_manager.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/audio/audio_manager.h"
+
+#include "base/at_exit.h"
+#include "base/logging.h"
+
+namespace {
+
+AudioManager* g_audio_manager = NULL;
+
+// NullAudioManager is the audio manager used on the systems that have no
+// audio support.
+class NullAudioManager : public AudioManager {
+ public:
+ NullAudioManager() { }
+
+ // Implementation of AudioManager.
+ virtual bool HasAudioOutputDevices() { return false; }
+ virtual bool HasAudioInputDevices() { return false; }
+ virtual AudioOutputStream* MakeAudioOutputStream(Format format, int channels,
+ int sample_rate,
+ char bits_per_sample) {
+ NOTIMPLEMENTED();
+ return NULL;
+ }
+ virtual AudioInputStream* MakeAudioInputStream(Format format, int channels,
+ int sample_rate,
+ char bits_per_sample,
+ uint32 samples_per_packet) {
+ NOTIMPLEMENTED();
+ return NULL;
+ }
+ virtual void MuteAll() { NOTIMPLEMENTED(); }
+ virtual void UnMuteAll() { NOTIMPLEMENTED(); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NullAudioManager);
+};
+
+} // namespace
+
+// static
+void AudioManager::Destroy(void* not_used) {
+ delete g_audio_manager;
+ g_audio_manager = NULL;
+}
+
+// static
+AudioManager* AudioManager::GetAudioManager() {
+ if (!g_audio_manager) {
+ g_audio_manager = CreateAudioManager();
+ g_audio_manager->Init();
+ base::AtExitManager::RegisterCallback(&AudioManager::Destroy, NULL);
+ }
+ return g_audio_manager;
+}
« no previous file with comments | « media/audio/audio_manager.h ('k') | media/audio/audio_manager_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698