OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "content/common/content_export.h" |
| 11 |
| 12 namespace media { |
| 13 class AudioRendererSink; |
| 14 } |
| 15 |
| 16 // A factory for creating AudioRendererSinks. There is a global factory |
| 17 // function that can be installed for the purposes of testing to provide |
| 18 // a specialized AudioRendererSink class. |
| 19 // This class uses the same pattern as content::RenderViewHostFactory. |
| 20 class AudioDeviceFactory { |
| 21 public: |
| 22 // Creates an AudioRendererSink using the currently registered factory, |
| 23 // or the default one if no factory is registered. Ownership of the returned |
| 24 // pointer will be passed to the caller. |
| 25 static media::AudioRendererSink* Create(); |
| 26 |
| 27 // Returns true if there is currently a globally-registered factory. |
| 28 static bool has_factory() { |
| 29 return !!factory_; |
| 30 } |
| 31 |
| 32 protected: |
| 33 AudioDeviceFactory() {} |
| 34 virtual ~AudioDeviceFactory() {} |
| 35 |
| 36 // You can derive from this class and specify an implementation for this |
| 37 // function to create a different kind of AudioRendererSink for testing. |
| 38 virtual media::AudioRendererSink* CreateAudioDevice() = 0; |
| 39 |
| 40 // Registers your factory to be called when new AudioRendererSinks are |
| 41 // created. We have only one global factory, so there must be no factory |
| 42 // registered before the call. This class does NOT take ownership of the |
| 43 // pointer. |
| 44 CONTENT_EXPORT static void RegisterFactory(AudioDeviceFactory* factory); |
| 45 |
| 46 // Unregister the previously registered factory. With no factory registered, |
| 47 // the default AudioRendererSinks will be created. |
| 48 CONTENT_EXPORT static void UnregisterFactory(); |
| 49 |
| 50 private: |
| 51 // The current globally registered factory. This is NULL when we should |
| 52 // create the default AudioRendererSinks. |
| 53 CONTENT_EXPORT static AudioDeviceFactory* factory_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory); |
| 56 }; |
| 57 |
| 58 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ |
OLD | NEW |