Chromium Code Reviews| 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 namespace content { | |
| 17 | |
| 18 // A factory for creating AudioRendererSinks. There is a global factory | |
| 19 // function that can be installed for the purposes of testing to provide | |
| 20 // a specialized AudioRendererSink class. | |
| 21 // This class uses the same pattern as content::RenderViewHostFactory. | |
| 22 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
| |
| 23 public: | |
| 24 // Creates an AudioRendererSink using the currently registered factory, | |
| 25 // or the default one if no factory is registered. Ownership of the returned | |
| 26 // pointer will be passed to the caller. | |
| 27 CONTENT_EXPORT static media::AudioRendererSink* Create(); | |
| 28 | |
| 29 // Returns true if there is currently a globally-registered factory. | |
| 30 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.
| |
| 31 return !!factory_; | |
| 32 } | |
| 33 | |
| 34 protected: | |
| 35 AudioDeviceFactory() {} | |
| 36 virtual ~AudioDeviceFactory() {} | |
| 37 | |
| 38 // You can derive from this class and specify an implementation for this | |
| 39 // function to create a different kind of AudioRendererSink for testing. | |
| 40 virtual media::AudioRendererSink* CreateAudioDevice() = 0; | |
| 41 | |
| 42 // Registers your factory to be called when new AudioRendererSinks are | |
| 43 // created. We have only one global factory, so there must be no factory | |
| 44 // registered before the call. This class does NOT take ownership of the | |
| 45 // pointer. | |
| 46 CONTENT_EXPORT static void RegisterFactory(AudioDeviceFactory* factory); | |
| 47 | |
| 48 // Unregister the previously registered factory. With no factory registered, | |
| 49 // the default AudioRendererSinks will be created. | |
| 50 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.
| |
| 51 | |
| 52 private: | |
| 53 // The current globally registered factory. This is NULL when we should | |
| 54 // create the default AudioRendererSinks. | |
| 55 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.
| |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory); | |
| 58 }; | |
| 59 | |
| 60 } // namespace content | |
| 61 | |
| 62 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ | |
| OLD | NEW |