summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 02:46:38 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 02:46:38 +0000
commita31b0cc12b1550c126af2e58156d86250e14b640 (patch)
tree494c706ad134d73161a376b130cfa9a11c03b15b /media
parentfba9da17fee049e74c4165ac7ff0ee4793f5d08f (diff)
downloadchromium_src-a31b0cc12b1550c126af2e58156d86250e14b640.zip
chromium_src-a31b0cc12b1550c126af2e58156d86250e14b640.tar.gz
chromium_src-a31b0cc12b1550c126af2e58156d86250e14b640.tar.bz2
Add destruction to AudioManager singleton for windows
-Current unit tests sufice Review URL: http://codereview.chromium.org/28036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/win/audio_manager_win.h1
-rw-r--r--media/audio/win/audio_output_win.cc19
2 files changed, 14 insertions, 6 deletions
diff --git a/media/audio/win/audio_manager_win.h b/media/audio/win/audio_manager_win.h
index 05040ce..7ade9ec 100644
--- a/media/audio/win/audio_manager_win.h
+++ b/media/audio/win/audio_manager_win.h
@@ -34,6 +34,7 @@ class AudioManagerWin : public AudioManager {
void ReleaseStream(AudioOutputStreamMockWin* stream);
private:
+ friend void DestroyAudioManagerWin(void *);
virtual ~AudioManagerWin();
DISALLOW_COPY_AND_ASSIGN(AudioManagerWin);
};
diff --git a/media/audio/win/audio_output_win.cc b/media/audio/win/audio_output_win.cc
index 6003fcd..ff45ccc 100644
--- a/media/audio/win/audio_output_win.cc
+++ b/media/audio/win/audio_output_win.cc
@@ -5,6 +5,7 @@
#include <windows.h>
#include <mmsystem.h>
+#include "base/at_exit.h"
#include "base/basictypes.h"
#include "media/audio/audio_output.h"
#include "media/audio/win/audio_manager_win.h"
@@ -80,6 +81,7 @@ class AudioOutputStreamMockWin : public AudioOutputStream {
namespace {
AudioOutputStreamMockWin* g_last_mock_stream = NULL;
+AudioManagerWin* g_audio_manager = NULL;
void ReplaceLastMockStream(AudioOutputStreamMockWin* newer) {
if (g_last_mock_stream)
@@ -135,11 +137,16 @@ AudioManagerWin::~AudioManagerWin() {
ReplaceLastMockStream(NULL);
}
-// TODO(cpu): Decide how to manage the lifetime of the AudioManager singleton.
-// Right now we are leaking it.
+void DestroyAudioManagerWin(void* param) {
+ delete g_audio_manager;
+ g_audio_manager = NULL;
+}
+
AudioManager* AudioManager::GetAudioManager() {
- static AudioManagerWin* audio_manager = NULL;
- if (!audio_manager)
- audio_manager = new AudioManagerWin();
- return audio_manager;
+ if (!g_audio_manager) {
+ g_audio_manager = new AudioManagerWin();
+ base::AtExitManager::RegisterCallback(&DestroyAudioManagerWin, NULL);
+ }
+ return g_audio_manager;
}
+