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

Diff of /linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 374 by schoenebeck, Sat Feb 12 00:36:08 2005 UTC revision 880 by schoenebeck, Tue Jun 27 22:57:37 2006 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6     *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   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     *   *   the Free Software Foundation; either version 2 of the License, or     *
11   *   (at your option) any later version.                                   *   *   (at your option) any later version.                                   *
12   *                                                                         *   *                                                                         *
13   *   This program is distributed in the hope that it will be useful,       *   *   This library is distributed in the hope that it will be useful,       *
14   *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *   *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
16   *   GNU General Public License for more details.                          *   *   GNU General Public License for more details.                          *
17   *                                                                         *   *                                                                         *
18   *   You should have received a copy of the GNU General Public License     *   *   You should have received a copy of the GNU General Public License     *
19   *   along with this program; if not, write to the Free Software           *   *   along with this library; if not, write to the Free Software           *
20   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
21   *   MA  02111-1307  USA                                                   *   *   MA  02111-1307  USA                                                   *
22   ***************************************************************************/   ***************************************************************************/
# Line 30  Line 31 
31  # include "AudioOutputDeviceJack.h"  # include "AudioOutputDeviceJack.h"
32  #endif // HAVE_JACK  #endif // HAVE_JACK
33    
34    #if HAVE_ARTS
35    # include "AudioOutputDeviceArts.h"
36    #endif // HAVE_ARTS
37    
38  namespace LinuxSampler {  namespace LinuxSampler {
39    
40      std::map<String, AudioOutputDeviceFactory::InnerFactory*> AudioOutputDeviceFactory::InnerFactories;      std::map<String, AudioOutputDeviceFactory::InnerFactory*> AudioOutputDeviceFactory::InnerFactories;
# Line 56  namespace LinuxSampler { Line 61  namespace LinuxSampler {
61      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterName);      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterName);
62  #endif // HAVE_JACK  #endif // HAVE_JACK
63    
64      AudioOutputDevice* AudioOutputDeviceFactory::Create(String DriverName, std::map<String,String> Parameters) throw (LinuxSamplerException) {  #if HAVE_ARTS
65          if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'.");      REGISTER_AUDIO_OUTPUT_DRIVER(AudioOutputDeviceArts);
66        /* Common parameters for now they'll have to be registered here. */
67        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterActive);
68        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterSampleRate);
69        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterChannels);
70        /* Driver specific parameters */
71        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterName);
72    #endif // HAVE_ARTS
73    
74        AudioOutputDevice* AudioOutputDeviceFactory::Create(String DriverName, std::map<String,String> Parameters) throw (Exception) {
75            if (!InnerFactories.count(DriverName)) throw Exception("There is no audio output driver '" + DriverName + "'.");
76          //Let's see if we need to create parameters          //Let's see if we need to create parameters
77          std::map<String,DeviceCreationParameter*> thisDeviceParams;          std::map<String,DeviceCreationParameter*> thisDeviceParams;
78          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];
# Line 65  namespace LinuxSampler { Line 80  namespace LinuxSampler {
80                  thisDeviceParams = pParamFactory->CreateAllParams(Parameters);                  thisDeviceParams = pParamFactory->CreateAllParams(Parameters);
81          } else {          } else {
82                  //No parameters are registered by the driver. Throw if any parameters were specified.                  //No parameters are registered by the driver. Throw if any parameters were specified.
83                  if (Parameters.size() != 0) throw LinuxSamplerException("Driver '" + DriverName + "' does not have any parameters.");                  if (Parameters.size() != 0) throw Exception("Driver '" + DriverName + "' does not have any parameters.");
84          }          }
85          //Now create the device using those parameters          //Now create the device using those parameters
86          AudioOutputDevice* pDevice = InnerFactories[DriverName]->Create(thisDeviceParams);          AudioOutputDevice* pDevice = InnerFactories[DriverName]->Create(thisDeviceParams);
# Line 97  namespace LinuxSampler { Line 112  namespace LinuxSampler {
112          return result;          return result;
113      }      }
114    
115      std::map<String,DeviceCreationParameter*> AudioOutputDeviceFactory::GetAvailableDriverParameters(String DriverName) throw (LinuxSamplerException) {      std::map<String,DeviceCreationParameter*> AudioOutputDeviceFactory::GetAvailableDriverParameters(String DriverName) throw (Exception) {
116          if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'.");          if (!InnerFactories.count(DriverName)) throw Exception("There is no audio output driver '" + DriverName + "'.");
117          std::map<String,DeviceCreationParameter*> thisDeviceParams;          std::map<String,DeviceCreationParameter*> thisDeviceParams;
118          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];
119          if (pParamFactory) {          if (pParamFactory) {
# Line 107  namespace LinuxSampler { Line 122  namespace LinuxSampler {
122          return thisDeviceParams;          return thisDeviceParams;
123      }      }
124    
125      DeviceCreationParameter* AudioOutputDeviceFactory::GetDriverParameter(String DriverName, String ParameterName) throw (LinuxSamplerException) {      DeviceCreationParameter* AudioOutputDeviceFactory::GetDriverParameter(String DriverName, String ParameterName) throw (Exception) {
126          std::map<String,DeviceCreationParameter*> parameters = GetAvailableDriverParameters(DriverName);          std::map<String,DeviceCreationParameter*> parameters = GetAvailableDriverParameters(DriverName);
127          if (!parameters.count(ParameterName)) throw LinuxSamplerException("Audio output driver '" + DriverName + "' does not have a parameter '" + ParameterName + "'.");          if (!parameters.count(ParameterName)) throw Exception("Audio output driver '" + DriverName + "' does not have a parameter '" + ParameterName + "'.");
128          return parameters[ParameterName];          return parameters[ParameterName];
129      }      }
130    
131      String AudioOutputDeviceFactory::GetDriverDescription(String DriverName) throw (LinuxSamplerException) {      String AudioOutputDeviceFactory::GetDriverDescription(String DriverName) throw (Exception) {
132          if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'.");          if (!InnerFactories.count(DriverName)) throw Exception("There is no audio output driver '" + DriverName + "'.");
133          return InnerFactories[DriverName]->Description();          return InnerFactories[DriverName]->Description();
134      }      }
135    
136      String AudioOutputDeviceFactory::GetDriverVersion(String DriverName) throw (LinuxSamplerException) {      String AudioOutputDeviceFactory::GetDriverVersion(String DriverName) throw (Exception) {
137          if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no audio output driver '" + DriverName + "'.");          if (!InnerFactories.count(DriverName)) throw Exception("There is no audio output driver '" + DriverName + "'.");
138          return InnerFactories[DriverName]->Version();          return InnerFactories[DriverName]->Version();
139      }      }
140    

Legend:
Removed from v.374  
changed lines
  Added in v.880

  ViewVC Help
Powered by ViewVC