36 |
|
|
37 |
namespace LinuxSampler { |
namespace LinuxSampler { |
38 |
|
|
39 |
|
class Plugin; |
40 |
|
|
41 |
class AudioOutputDeviceFactory { |
class AudioOutputDeviceFactory { |
42 |
public: |
public: |
43 |
class InnerFactory { |
class InnerFactory { |
45 |
virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) = 0; |
virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) = 0; |
46 |
virtual String Description() = 0; |
virtual String Description() = 0; |
47 |
virtual String Version() = 0; |
virtual String Version() = 0; |
48 |
|
virtual bool isAutonomousDriver() = 0; |
49 |
}; |
}; |
50 |
|
|
51 |
template <class Driver_T> |
template <class Driver_T> |
54 |
virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) { return new Driver_T(Parameters); } |
virtual AudioOutputDevice* Create(std::map<String,DeviceCreationParameter*> Parameters) { return new Driver_T(Parameters); } |
55 |
virtual String Description() { return Driver_T::Description(); } |
virtual String Description() { return Driver_T::Description(); } |
56 |
virtual String Version() { return Driver_T::Version(); } |
virtual String Version() { return Driver_T::Version(); } |
57 |
|
virtual bool isAutonomousDriver() { return Driver_T::isAutonomousDriver(); } |
58 |
}; |
}; |
59 |
|
|
60 |
template <class Driver_T> |
template <class Driver_T> |
62 |
public: |
public: |
63 |
InnerFactoryRegistrator() { |
InnerFactoryRegistrator() { |
64 |
AudioOutputDeviceFactory::InnerFactories[Driver_T::Name()] = new AudioOutputDeviceFactory::InnerFactoryTemplate<Driver_T>; |
AudioOutputDeviceFactory::InnerFactories[Driver_T::Name()] = new AudioOutputDeviceFactory::InnerFactoryTemplate<Driver_T>; |
65 |
AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()] = new DeviceParameterFactory(); |
AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()] = new DeviceParameterFactory(); |
66 |
} |
} |
67 |
~InnerFactoryRegistrator() { |
~InnerFactoryRegistrator() { |
68 |
AudioOutputDeviceFactory::Unregister(Driver_T::Name()); |
AudioOutputDeviceFactory::Unregister(Driver_T::Name()); |
69 |
} |
} |
70 |
}; |
}; |
71 |
|
|
72 |
template <class Driver_T, class Parameter_T> |
template <class Driver_T, class Parameter_T> |
73 |
class ParameterRegistrator { |
class ParameterRegistrator { |
74 |
public: |
public: |
75 |
ParameterRegistrator() { |
ParameterRegistrator() { |
76 |
DeviceParameterFactory::Register<Parameter_T>(AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()]); |
DeviceParameterFactory::Register<Parameter_T>(AudioOutputDeviceFactory::ParameterFactories[Driver_T::Name()]); |
77 |
} |
} |
78 |
}; |
}; |
79 |
|
|
80 |
static AudioOutputDevice* Create(String DriverName, std::map<String,String> Parameters) throw (Exception); |
static AudioOutputDevice* Create(String DriverName, std::map<String,String> Parameters) throw (Exception); |
81 |
|
static void Destroy(AudioOutputDevice* pDevice) throw (Exception); |
82 |
static std::vector<String> AvailableDrivers(); |
static std::vector<String> AvailableDrivers(); |
83 |
static String AvailableDriversAsString(); |
static String AvailableDriversAsString(); |
84 |
static std::map<String,DeviceCreationParameter*> GetAvailableDriverParameters(String DriverName) throw (Exception); |
static std::map<String,DeviceCreationParameter*> GetAvailableDriverParameters(String DriverName) throw (Exception); |
86 |
static String GetDriverDescription(String DriverName) throw (Exception); |
static String GetDriverDescription(String DriverName) throw (Exception); |
87 |
static String GetDriverVersion(String DriverName) throw (Exception); |
static String GetDriverVersion(String DriverName) throw (Exception); |
88 |
static void Unregister(String DriverName); |
static void Unregister(String DriverName); |
89 |
|
static std::map<uint, AudioOutputDevice*> Devices(); |
90 |
|
|
91 |
|
protected: |
92 |
|
static AudioOutputDevice* CreatePrivate(String DriverName, std::map<String,String> Parameters) throw (Exception); |
93 |
|
static void DestroyPrivate(AudioOutputDevice* pDevice) throw (Exception); |
94 |
|
friend class Plugin; // host plugin base class (e.g. for VST, AU, DSSI, LV2) |
95 |
|
|
96 |
// protected: /* FIXME: fields below should be protected, causes errors on gcc 2.95 though */ |
public: /* FIXME: fields below should be protected, causes errors on gcc 2.95 though */ |
97 |
static std::map<String, InnerFactory*> InnerFactories; |
static std::map<String, InnerFactory*> InnerFactories; |
98 |
static std::map<String, DeviceParameterFactory*> ParameterFactories; |
static std::map<String, DeviceParameterFactory*> ParameterFactories; |
99 |
|
|
100 |
|
private: |
101 |
|
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
102 |
|
static AudioOutputDeviceMap mAudioOutputDevices; ///< contains all created audio output devices |
103 |
}; |
}; |
104 |
|
|
105 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |