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

Unified Diff: content/renderer/media/audio_device_factory.h

Issue 10537121: Adds AudioDevice factory for all audio clients in Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved AudioDeviceFactory to content namespace Created 8 years, 6 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
Index: content/renderer/media/audio_device_factory.h
diff --git a/content/renderer/media/audio_device_factory.h b/content/renderer/media/audio_device_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..1c7455656344ec08c71f3240720059c9500d523f
--- /dev/null
+++ b/content/renderer/media/audio_device_factory.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 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.
+
+#ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
+#define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "content/common/content_export.h"
+
+namespace media {
+class AudioRendererSink;
+}
+
+namespace content {
+
+// A factory for creating AudioRendererSinks. There is a global factory
+// function that can be installed for the purposes of testing to provide
+// a specialized AudioRendererSink class.
+// This class uses the same pattern as content::RenderViewHostFactory.
+class AudioDeviceFactory {
jam 2012/06/27 15:56:29 nit: it's a bit odd that this factory creates the
henrika (OOO until Aug 14) 2012/06/27 17:54:47 It's a very good comment. I will improve it. Thank
+ public:
+ // Creates an AudioRendererSink using the currently registered factory,
+ // or the default one if no factory is registered. Ownership of the returned
+ // pointer will be passed to the caller.
+ CONTENT_EXPORT static media::AudioRendererSink* Create();
+
+ // Returns true if there is currently a globally-registered factory.
+ CONTENT_EXPORT static bool has_factory() {
jam 2012/06/27 15:56:29 this isn't used, so take it out
henrika (OOO until Aug 14) 2012/06/27 17:54:47 Will do.
henrika (OOO until Aug 14) 2012/06/28 11:36:01 Done.
+ return !!factory_;
+ }
+
+ protected:
+ AudioDeviceFactory() {}
+ virtual ~AudioDeviceFactory() {}
+
+ // You can derive from this class and specify an implementation for this
+ // function to create a different kind of AudioRendererSink for testing.
+ virtual media::AudioRendererSink* CreateAudioDevice() = 0;
+
+ // Registers your factory to be called when new AudioRendererSinks are
+ // created. We have only one global factory, so there must be no factory
+ // registered before the call. This class does NOT take ownership of the
+ // pointer.
+ CONTENT_EXPORT static void RegisterFactory(AudioDeviceFactory* factory);
+
+ // Unregister the previously registered factory. With no factory registered,
+ // the default AudioRendererSinks will be created.
+ CONTENT_EXPORT static void UnregisterFactory();
jam 2012/06/27 15:56:29 nit: you can get rid of the Register and Unregiste
henrika (OOO until Aug 14) 2012/06/27 17:54:47 That's a smart observation. Note, also applies to
henrika (OOO until Aug 14) 2012/06/28 11:36:01 Done.
+
+ private:
+ // The current globally registered factory. This is NULL when we should
+ // create the default AudioRendererSinks.
+ CONTENT_EXPORT static AudioDeviceFactory* factory_;
jam 2012/06/27 15:56:29 don't need CONTENT_EXPORT here
henrika (OOO until Aug 14) 2012/06/27 17:54:47 Will do.
henrika (OOO until Aug 14) 2012/06/28 11:36:01 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698