25 |
namespace LinuxSampler { |
namespace LinuxSampler { |
26 |
|
|
27 |
std::map<String, AudioOutputDeviceFactory::InnerFactory*> AudioOutputDeviceFactory::InnerFactories; |
std::map<String, AudioOutputDeviceFactory::InnerFactory*> AudioOutputDeviceFactory::InnerFactories; |
28 |
|
std::map<String, DeviceParameterFactory*> AudioOutputDeviceFactory::ParameterFactories; |
29 |
|
|
30 |
AudioOutputDevice* AudioOutputDeviceFactory::Create(String DriverName, std::map<String,String>& Parameters) throw (LinuxSamplerException) { |
AudioOutputDevice* AudioOutputDeviceFactory::Create(String DriverName, std::map<String,String> Parameters) throw (LinuxSamplerException) { |
31 |
if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'."); |
if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'."); |
32 |
return InnerFactories[DriverName]->Create(Parameters); |
//Let's see if we need to create parameters |
33 |
|
std::map<String,DeviceCreationParameter*> thisDeviceParams; |
34 |
|
DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName]; |
35 |
|
if (pParamFactory) { |
36 |
|
thisDeviceParams = pParamFactory->CreateAllParams(Parameters); |
37 |
|
} else { |
38 |
|
//No parameters are registered by the driver. Throw if any parameters were specified. |
39 |
|
if (Parameters.size() != 0) throw LinuxSamplerException("Driver '" + DriverName + "' does not have any parameters."); |
40 |
|
} |
41 |
|
//Now create the device using those parameters |
42 |
|
AudioOutputDevice* pDevice = InnerFactories[DriverName]->Create(thisDeviceParams); |
43 |
|
//Now attach all parameters to the newely created device. |
44 |
|
for (std::map<String,DeviceCreationParameter*>::iterator iter = thisDeviceParams.begin(); iter != thisDeviceParams.end(); iter++) { |
45 |
|
iter->second->Attach(pDevice); |
46 |
|
} |
47 |
|
return pDevice; |
48 |
} |
} |
49 |
|
|
50 |
std::vector<String> AudioOutputDeviceFactory::AvailableDrivers() { |
std::vector<String> AudioOutputDeviceFactory::AvailableDrivers() { |
70 |
|
|
71 |
std::map<String,DeviceCreationParameter*> AudioOutputDeviceFactory::GetAvailableDriverParameters(String DriverName) throw (LinuxSamplerException) { |
std::map<String,DeviceCreationParameter*> AudioOutputDeviceFactory::GetAvailableDriverParameters(String DriverName) throw (LinuxSamplerException) { |
72 |
if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'."); |
if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'."); |
73 |
return InnerFactories[DriverName]->AvailableParameters(); |
std::map<String,DeviceCreationParameter*> thisDeviceParams; |
74 |
|
DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName]; |
75 |
|
if (pParamFactory) { |
76 |
|
thisDeviceParams = pParamFactory->CreateAllParams(); |
77 |
|
} |
78 |
|
return thisDeviceParams; |
79 |
} |
} |
80 |
|
|
81 |
DeviceCreationParameter* AudioOutputDeviceFactory::GetDriverParameter(String DriverName, String ParameterName) throw (LinuxSamplerException) { |
DeviceCreationParameter* AudioOutputDeviceFactory::GetDriverParameter(String DriverName, String ParameterName) throw (LinuxSamplerException) { |