/[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 288 by schoenebeck, Tue Oct 19 00:36:34 2004 UTC revision 1604 by schoenebeck, Mon Dec 31 15:33:54 2007 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 - 2007 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   ***************************************************************************/   ***************************************************************************/
23    
24  #include "AudioOutputDeviceFactory.h"  #include "AudioOutputDeviceFactory.h"
25    
26  // just to avoid linker problems  #include "../../common/global_private.h"
 #include "AudioOutputDeviceAlsa.h"  
 #include "AudioOutputDeviceJack.h"  
27    
28    #if HAVE_ALSA
29    # include "AudioOutputDeviceAlsa.h"
30    #endif // HAVE_ALSA
31    
32    #if HAVE_JACK
33    # include "AudioOutputDeviceJack.h"
34    #endif // HAVE_JACK
35    
36    #if HAVE_ARTS
37    # include "AudioOutputDeviceArts.h"
38    #endif // HAVE_ARTS
39    
40    #if HAVE_ASIO
41    # include "AudioOutputDeviceAsio.h"
42    #endif // HAVE_ASIO
43  namespace LinuxSampler {  namespace LinuxSampler {
44    
45      std::map<String, AudioOutputDeviceFactory::InnerFactory*> AudioOutputDeviceFactory::InnerFactories;      std::map<String, AudioOutputDeviceFactory::InnerFactory*> AudioOutputDeviceFactory::InnerFactories;
46      std::map<String, DeviceParameterFactory*> AudioOutputDeviceFactory::ParameterFactories;      std::map<String, DeviceParameterFactory*> AudioOutputDeviceFactory::ParameterFactories;
47    
48      // just a little hack to avoid linker problems  #if HAVE_ALSA
49      static int ___init___foo___() {      REGISTER_AUDIO_OUTPUT_DRIVER(AudioOutputDeviceAlsa);
50          #if HAVE_ALSA      /* Common parameters for now they'll have to be registered here. */
51          AudioOutputDeviceAlsa::Name().c_str();      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAlsa, ParameterActive);
52          #endif // HAVE_ALSA      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAlsa, ParameterSampleRate);
53          #if HAVE_JACK      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAlsa, ParameterChannels);
54          AudioOutputDeviceJack::Name().c_str();      /* Driver specific parameters */
55          #endif // HAVE_JACK      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAlsa, ParameterCard);
56          return 0;      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAlsa, ParameterFragments);
57      }      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAlsa, ParameterFragmentSize);
58      static int ___foo___ = ___init___foo___();  #endif // HAVE_ALSA
59    
60    #if HAVE_JACK
61        REGISTER_AUDIO_OUTPUT_DRIVER(AudioOutputDeviceJack);
62        /* Common parameters for now they'll have to be registered here. */
63        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterActive);
64        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterSampleRate);
65        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterChannels);
66        /* Driver specific parameters */
67        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterName);
68    #endif // HAVE_JACK
69    
70    #if HAVE_ARTS
71        REGISTER_AUDIO_OUTPUT_DRIVER(AudioOutputDeviceArts);
72        /* Common parameters for now they'll have to be registered here. */
73        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterActive);
74        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterSampleRate);
75        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterChannels);
76        /* Driver specific parameters */
77        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceArts, ParameterName);
78    #endif // HAVE_ARTS
79    
80    #if HAVE_ASIO
81        REGISTER_AUDIO_OUTPUT_DRIVER(AudioOutputDeviceAsio);
82        /* Common parameters for now they'll have to be registered here. */
83        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAsio, ParameterActive);
84        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAsio, ParameterSampleRate);
85        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAsio, ParameterChannels);
86        /* Driver specific parameters */
87        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAsio, ParameterCard);
88        REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceAsio, ParameterFragmentSize);
89    #endif // HAVE_ASIO
90    
91      AudioOutputDevice* AudioOutputDeviceFactory::Create(String DriverName, std::map<String,String> Parameters) throw (LinuxSamplerException) {      AudioOutputDevice* AudioOutputDeviceFactory::Create(String DriverName, std::map<String,String> Parameters) throw (Exception) {
92          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 + "'.");
93          //Let's see if we need to create parameters          //Let's see if we need to create parameters
94          std::map<String,DeviceCreationParameter*> thisDeviceParams;          std::map<String,DeviceCreationParameter*> thisDeviceParams;
95          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];
# Line 52  namespace LinuxSampler { Line 97  namespace LinuxSampler {
97                  thisDeviceParams = pParamFactory->CreateAllParams(Parameters);                  thisDeviceParams = pParamFactory->CreateAllParams(Parameters);
98          } else {          } else {
99                  //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.
100                  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.");
101          }          }
102          //Now create the device using those parameters          //Now create the device using those parameters
103          AudioOutputDevice* pDevice = InnerFactories[DriverName]->Create(thisDeviceParams);          AudioOutputDevice* pDevice = InnerFactories[DriverName]->Create(thisDeviceParams);
# Line 84  namespace LinuxSampler { Line 129  namespace LinuxSampler {
129          return result;          return result;
130      }      }
131    
132      std::map<String,DeviceCreationParameter*> AudioOutputDeviceFactory::GetAvailableDriverParameters(String DriverName) throw (LinuxSamplerException) {      std::map<String,DeviceCreationParameter*> AudioOutputDeviceFactory::GetAvailableDriverParameters(String DriverName) throw (Exception) {
133          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 + "'.");
134          std::map<String,DeviceCreationParameter*> thisDeviceParams;          std::map<String,DeviceCreationParameter*> thisDeviceParams;
135          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];          DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];
136          if (pParamFactory) {          if (pParamFactory) {
# Line 94  namespace LinuxSampler { Line 139  namespace LinuxSampler {
139          return thisDeviceParams;          return thisDeviceParams;
140      }      }
141    
142      DeviceCreationParameter* AudioOutputDeviceFactory::GetDriverParameter(String DriverName, String ParameterName) throw (LinuxSamplerException) {      DeviceCreationParameter* AudioOutputDeviceFactory::GetDriverParameter(String DriverName, String ParameterName) throw (Exception) {
143          std::map<String,DeviceCreationParameter*> parameters = GetAvailableDriverParameters(DriverName);          std::map<String,DeviceCreationParameter*> parameters = GetAvailableDriverParameters(DriverName);
144          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 + "'.");
145          return parameters[ParameterName];          return parameters[ParameterName];
146      }      }
147    
148      String AudioOutputDeviceFactory::GetDriverDescription(String DriverName) throw (LinuxSamplerException) {      String AudioOutputDeviceFactory::GetDriverDescription(String DriverName) throw (Exception) {
149          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 + "'.");
150          return InnerFactories[DriverName]->Description();          return InnerFactories[DriverName]->Description();
151      }      }
152    
153      String AudioOutputDeviceFactory::GetDriverVersion(String DriverName) throw (LinuxSamplerException) {      String AudioOutputDeviceFactory::GetDriverVersion(String DriverName) throw (Exception) {
154          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 + "'.");
155          return InnerFactories[DriverName]->Version();          return InnerFactories[DriverName]->Version();
156      }      }
157    

Legend:
Removed from v.288  
changed lines
  Added in v.1604

  ViewVC Help
Powered by ViewVC