/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceFactory.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceFactory.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2503 - (hide annotations) (download) (as text)
Sat Jan 11 14:05:17 2014 UTC (6 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6269 byte(s)
* Minor C++11 compliance fixes (caused compilation errors
  on some recent compilers).

1 schoenebeck 200 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 2503 * Copyright (C) 2005 - 2014 Christian Schoenebeck *
7 schoenebeck 200 * *
8     * This program is free software; you can redistribute it and/or modify *
9     * it under the terms of the GNU General Public License as published by *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     #ifndef __LS_AUDIO_OUTPUT_DEVICE_FACTORY_H__
25     #define __LS_AUDIO_OUTPUT_DEVICE_FACTORY_H__
26    
27     #include <map>
28     #include <vector>
29    
30 schoenebeck 880 #include "../../common/Exception.h"
31 schoenebeck 200 #include "../DeviceParameterFactory.h"
32     #include "AudioOutputDevice.h"
33    
34     #define REGISTER_AUDIO_OUTPUT_DRIVER(DriverClass) static LinuxSampler::AudioOutputDeviceFactory::InnerFactoryRegistrator<DriverClass> __auto_register_audio_output_driver__##DriverClass
35     #define REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(DriverClass, ParameterClass) static LinuxSampler::AudioOutputDeviceFactory::ParameterRegistrator<DriverClass, DriverClass::ParameterClass> __auto_register_audio_output_driver_parameter__##DriverClass##ParameterClass
36    
37     namespace LinuxSampler {
38    
39 schoenebeck 1934 class Plugin;
40    
41 schoenebeck 200 class AudioOutputDeviceFactory {
42     public:
43     class InnerFactory {
44     public:
45 schoenebeck 2503 virtual ~InnerFactory() {}
46 schoenebeck 200 virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) = 0;
47     virtual String Description() = 0;
48     virtual String Version() = 0;
49 schoenebeck 1934 virtual bool isAutonomousDriver() = 0;
50 schoenebeck 200 };
51    
52     template <class Driver_T>
53     class InnerFactoryTemplate : public InnerFactory {
54     public:
55     virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) { return new Driver_T(Parameters); }
56     virtual String Description() { return Driver_T::Description(); }
57     virtual String Version() { return Driver_T::Version(); }
58 schoenebeck 1934 virtual bool isAutonomousDriver() { return Driver_T::isAutonomousDriver(); }
59 schoenebeck 200 };
60    
61     template <class Driver_T>
62     class InnerFactoryRegistrator {
63     public:
64     InnerFactoryRegistrator() {
65 schoenebeck 277 AudioOutputDeviceFactory::InnerFactories[Driver_T::Name()] = new AudioOutputDeviceFactory::InnerFactoryTemplate<Driver_T>;
66 schoenebeck 1934 AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()] = new DeviceParameterFactory();
67 schoenebeck 200 }
68 persson 1248 ~InnerFactoryRegistrator() {
69 persson 1889 AudioOutputDeviceFactory::Unregister(Driver_T::Name());
70 persson 1248 }
71 schoenebeck 200 };
72    
73 schoenebeck 1934 template <class Driver_T, class Parameter_T>
74 schoenebeck 200 class ParameterRegistrator {
75 schoenebeck 1934 public:
76 schoenebeck 200 ParameterRegistrator() {
77 persson 1248 DeviceParameterFactory::Register<Parameter_T>(AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()]);
78 schoenebeck 1934 }
79     };
80 schoenebeck 200
81 schoenebeck 880 static AudioOutputDevice* Create(String DriverName, std::map<String,String> Parameters) throw (Exception);
82 schoenebeck 1934 static void Destroy(AudioOutputDevice* pDevice) throw (Exception);
83 schoenebeck 200 static std::vector<String> AvailableDrivers();
84     static String AvailableDriversAsString();
85 schoenebeck 880 static std::map<String,DeviceCreationParameter*> GetAvailableDriverParameters(String DriverName) throw (Exception);
86     static DeviceCreationParameter* GetDriverParameter(String DriverName, String ParameterName) throw (Exception);
87     static String GetDriverDescription(String DriverName) throw (Exception);
88     static String GetDriverVersion(String DriverName) throw (Exception);
89 persson 1889 static void Unregister(String DriverName);
90 schoenebeck 1934 static std::map<uint, AudioOutputDevice*> Devices();
91 schoenebeck 200
92 schoenebeck 1934 protected:
93     static AudioOutputDevice* CreatePrivate(String DriverName, std::map<String,String> Parameters) throw (Exception);
94     static void DestroyPrivate(AudioOutputDevice* pDevice) throw (Exception);
95     friend class Plugin; // host plugin base class (e.g. for VST, AU, DSSI, LV2)
96    
97     public: /* FIXME: fields below should be protected, causes errors on gcc 2.95 though */
98 schoenebeck 200 static std::map<String, InnerFactory*> InnerFactories;
99 schoenebeck 1934 static std::map<String, DeviceParameterFactory*> ParameterFactories;
100    
101     private:
102     typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;
103     static AudioOutputDeviceMap mAudioOutputDevices; ///< contains all created audio output devices
104 schoenebeck 200 };
105    
106     } // namespace LinuxSampler
107    
108     #endif // __LS_AUDIO_OUTPUT_DEVICE_FACTORY_H__

  ViewVC Help
Powered by ViewVC