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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1889 - (show annotations) (download) (as text)
Sun Apr 26 12:19:00 2009 UTC (14 years, 11 months ago) by persson
File MIME type: text/x-c++hdr
File size: 5250 byte(s)
* fixed a memory management error which could cause a crash when a
  plugin was unloaded
* minor fixes in ASIO and MME drivers for win64

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2009 Christian Schoenebeck *
7 * *
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 #include "../../common/Exception.h"
31 #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 class AudioOutputDeviceFactory {
40 public:
41 class InnerFactory {
42 public:
43 virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) = 0;
44 virtual String Description() = 0;
45 virtual String Version() = 0;
46 };
47
48 template <class Driver_T>
49 class InnerFactoryTemplate : public InnerFactory {
50 public:
51 virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) { return new Driver_T(Parameters); }
52 virtual String Description() { return Driver_T::Description(); }
53 virtual String Version() { return Driver_T::Version(); }
54 };
55
56 template <class Driver_T>
57 class InnerFactoryRegistrator {
58 public:
59 InnerFactoryRegistrator() {
60 AudioOutputDeviceFactory::InnerFactories[Driver_T::Name()] = new AudioOutputDeviceFactory::InnerFactoryTemplate<Driver_T>;
61 AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()] = new DeviceParameterFactory();
62 }
63 ~InnerFactoryRegistrator() {
64 AudioOutputDeviceFactory::Unregister(Driver_T::Name());
65 }
66 };
67
68 template <class Driver_T, class Parameter_T>
69 class ParameterRegistrator {
70 public:
71 ParameterRegistrator() {
72 DeviceParameterFactory::Register<Parameter_T>(AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()]);
73 }
74 };
75
76 static AudioOutputDevice* Create(String DriverName, std::map<String,String> Parameters) throw (Exception);
77 static std::vector<String> AvailableDrivers();
78 static String AvailableDriversAsString();
79 static std::map<String,DeviceCreationParameter*> GetAvailableDriverParameters(String DriverName) throw (Exception);
80 static DeviceCreationParameter* GetDriverParameter(String DriverName, String ParameterName) throw (Exception);
81 static String GetDriverDescription(String DriverName) throw (Exception);
82 static String GetDriverVersion(String DriverName) throw (Exception);
83 static void Unregister(String DriverName);
84
85 // protected: /* FIXME: fields below should be protected, causes errors on gcc 2.95 though */
86 static std::map<String, InnerFactory*> InnerFactories;
87 static std::map<String, DeviceParameterFactory*> ParameterFactories;
88 };
89
90 } // namespace LinuxSampler
91
92 #endif // __LS_AUDIO_OUTPUT_DEVICE_FACTORY_H__

  ViewVC Help
Powered by ViewVC