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

Diff of /linuxsampler/trunk/src/drivers/audio/AudioOutputDevice.h

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

revision 200 by schoenebeck, Tue Jul 13 22:04:16 2004 UTC revision 226 by schoenebeck, Wed Aug 25 22:00:33 2004 UTC
# Line 30  Line 30 
30    
31  #include "../../common/global.h"  #include "../../common/global.h"
32  #include "../../common/LinuxSamplerException.h"  #include "../../common/LinuxSamplerException.h"
33  #include "../InputOutputDevice.h"  #include "../Device.h"
34  #include "../DeviceParameter.h"  #include "../DeviceParameter.h"
35  #include "../../engines/common/Engine.h"  #include "../../engines/common/Engine.h"
36  #include "AudioChannel.h"  #include "AudioChannel.h"
# Line 46  namespace LinuxSampler { Line 46  namespace LinuxSampler {
46       * connection to a specific audio output system (e.g. Alsa, Jack,       * connection to a specific audio output system (e.g. Alsa, Jack,
47       * CoreAudio).       * CoreAudio).
48       */       */
49      class AudioOutputDevice : public InputOutputDevice {      class AudioOutputDevice : public Device {
50          public:          public:
51    
52              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
53              // Device parameters              // Device parameters
54    
55                /** Device Parameter 'ACTIVE'
56                 *
57                 * Used to activate / deactivate the audio output device.
58                 */
59              class ParameterActive : public DeviceCreationParameterBool {              class ParameterActive : public DeviceCreationParameterBool {
60                  public:                  public:
61                      ParameterActive( void ) : DeviceCreationParameterBool()                  { InitWithDefault();                                  }                      ParameterActive();
62                      ParameterActive( String s ) : DeviceCreationParameterBool(s)             {}                      ParameterActive(String s);
63                      virtual String Description()                                             { return "Enable / disable device";                   }                      virtual String Description();
64                      virtual bool   Fix()                                                     { return false;                                       }                      virtual bool   Fix();
65                      virtual bool   Mandatory()                                               { return false;                                       }                      virtual bool   Mandatory();
66                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters()  { return std::map<String,DeviceCreationParameter*>(); }                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
67                      virtual optional<bool> DefaultAsBool(std::map<String,String> Parameters) { return true;                                        }                      virtual optional<bool> DefaultAsBool(std::map<String,String> Parameters);
68                      virtual void OnSetValue(bool b) throw (LinuxSamplerException)            { if (b) ((AudioOutputDevice*)pDevice)->Play(); else ((AudioOutputDevice*)pDevice)->Stop();       }                      virtual void OnSetValue(bool b) throw (LinuxSamplerException);
69                      static String Name( void ) { return "active"; }                      static String Name();
70              };              };
71    
72                /** Device Parameter 'SAMPLERATE'
73                 *
74                 * Used to set the sample rate of the audio output device.
75                 */
76              class ParameterSampleRate : public DeviceCreationParameterInt {              class ParameterSampleRate : public DeviceCreationParameterInt {
77                  public:                  public:
78                      ParameterSampleRate() : DeviceCreationParameterInt()                            { InitWithDefault();                                  }                      ParameterSampleRate();
79                      ParameterSampleRate( String s ) : DeviceCreationParameterInt(s)                 {}                      ParameterSampleRate(String s);
80                      virtual String Description()                                                    { return "Output sample rate";                        }                      virtual String Description();
81                      virtual bool   Fix()                                                            { return true;                                        }                      virtual bool   Fix();
82                      virtual bool   Mandatory()                                                      { return false;                                       }                      virtual bool   Mandatory();
83                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters()         { return std::map<String,DeviceCreationParameter*>(); }                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
84                      virtual optional<int>    DefaultAsInt(std::map<String,String> Parameters)       { return 44100;                                       }                      virtual optional<int>    DefaultAsInt(std::map<String,String> Parameters);
85                      virtual optional<int>    RangeMinAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }                      virtual optional<int>    RangeMinAsInt(std::map<String,String> Parameters);
86                      virtual optional<int>    RangeMaxAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }                      virtual optional<int>    RangeMaxAsInt(std::map<String,String> Parameters);
87                      virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) { return std::vector<int>();                          }                      virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
88                      virtual void             OnSetValue(int i) throw (LinuxSamplerException)        { /* cannot happen, as parameter is fix */            }                      virtual void             OnSetValue(int i) throw (LinuxSamplerException);
89                      static String Name( void ) { return "samplerate"; }                      static String Name();
90              };              };
91    
92                /** Device Parameters 'CHANNELS'
93                 *
94                 * Used to increase / decrease the number of audio channels of
95                 * audio output device.
96                 */
97              class ParameterChannels : public DeviceCreationParameterInt {              class ParameterChannels : public DeviceCreationParameterInt {
98                  public:                  public:
99                      ParameterChannels() : DeviceCreationParameterInt()                              { InitWithDefault();                                  }                      ParameterChannels();
100                      ParameterChannels( String s ) : DeviceCreationParameterInt(s)                   {}                      ParameterChannels(String s);
101                      virtual String Description()                                                    { return "Number of output channels";                 }                      virtual String Description();
102                      virtual bool   Fix()                                                            { return false;                                       }                      virtual bool   Fix();
103                      virtual bool   Mandatory()                                                      { return false;                                       }                      virtual bool   Mandatory();
104                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters()         { return std::map<String,DeviceCreationParameter*>(); }                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
105                      virtual optional<int>    DefaultAsInt(std::map<String,String> Parameters)       { return 2;                                           }                      virtual optional<int>    DefaultAsInt(std::map<String,String> Parameters);
106                      virtual optional<int>    RangeMinAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }                      virtual optional<int>    RangeMinAsInt(std::map<String,String> Parameters);
107                      virtual optional<int>    RangeMaxAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }                      virtual optional<int>    RangeMaxAsInt(std::map<String,String> Parameters);
108                      virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) { return std::vector<int>();                          }                      virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
109                      virtual void             OnSetValue(int i) throw (LinuxSamplerException)        { ((AudioOutputDevice*)pDevice)->AcquireChannels(i);    }                      virtual void             OnSetValue(int i) throw (LinuxSamplerException);
110                      static String Name( void ) { return "channels"; }                      static String Name();
111              };              };
112    
113    
114    
115              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
116              // abstract methods              // abstract methods
117              //     (these have to be implemented by the descendant)              //     (these have to be implemented by the descendant)
# Line 132  namespace LinuxSampler { Line 146  namespace LinuxSampler {
146              virtual void Stop() = 0;              virtual void Stop() = 0;
147    
148              /**              /**
              * This method will usually be called by the sampler engines that  
              * are connected to this audio device to inform the audio device  
              * how much audio channels the engine(s) need. It's the  
              * responsibility of the audio device to offer that amount of  
              * audio channels - again: this is not an option this is a must!  
              * The engines will assume to be able to access those audio  
              * channels right after. If the audio driver is not able to offer  
              * that much channels, it can simply create mix channels which  
              * are then just mixed to the 'real' audio channels. See  
              * AudioChannel.h for details about channels and mix channels.  
              *  
              * @param Channels - amount of output channels required by  
              *                   a sampler engine  
              * @throws AudioOutputException  if desired amount of channels  
              *                               cannot be offered  
              * @see AudioChannel  
              */  
             virtual void AcquireChannels(uint Channels) = 0;  
   
             /**  
149               * Maximum amount of sample points the implementing audio               * Maximum amount of sample points the implementing audio
150               * device will ever demand the sampler engines to write in one               * device will ever demand the sampler engines to write in one
151               * fragment cycle / period. Simple audio device drivers usually               * fragment cycle / period. Simple audio device drivers usually
# Line 172  namespace LinuxSampler { Line 166  namespace LinuxSampler {
166              virtual uint SampleRate() = 0;              virtual uint SampleRate() = 0;
167    
168              /**              /**
169               * Return the audio output device driver type name.               * Return the audio output device driver name.
170               */               */
171              virtual String Driver() = 0;              virtual String Driver() = 0;
172    
173                /**
174                 * Create new audio channel. This will be called by
175                 * AcquireChannels(). Each driver must implement it.
176                 */
177                virtual AudioChannel* CreateChannel(uint ChannelNr) = 0;
178    
179    
180    
181              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
182              // normal methods              // normal methods
183              //     (usually not to be overriden by descendant)              //     (usually not to be overriden by descendant)
# Line 205  namespace LinuxSampler { Line 207  namespace LinuxSampler {
207               */               */
208              AudioChannel* Channel(uint ChannelIndex);              AudioChannel* Channel(uint ChannelIndex);
209    
210              std::map<String,DeviceCreationParameter*> DeviceParameters();              /**
211                 * This method will usually be called by the sampler engines that
212                 * are connected to this audio device to inform the audio device
213                 * how much audio channels the engine(s) need. It's the
214                 * responsibility of the audio device to offer that amount of
215                 * audio channels - again: this is not an option this is a must!
216                 * The engines will assume to be able to access those audio
217                 * channels right after. If the audio driver is not able to offer
218                 * that much channels, it can simply create mix channels which
219                 * are then just mixed to the 'real' audio channels. See
220                 * AudioChannel.h for details about channels and mix channels.
221                 *
222                 * @param Channels - amount of output channels required by
223                 *                   a sampler engine
224                 * @throws AudioOutputException  if desired amount of channels
225                 *                               cannot be offered
226                 * @see AudioChannel
227                 */
228                void AcquireChannels(uint Channels);
229    
230                /**
231                 * Returns all device parameter settings.
232                 */
233                std::map<String,DeviceCreationParameter*> DeviceParameters();
234    
235          protected:          protected:
236              std::set<Engine*>                         Engines;     ///< All sampler engines that are connected to the audio output device.              std::set<Engine*>                         Engines;     ///< All sampler engines that are connected to the audio output device.

Legend:
Removed from v.200  
changed lines
  Added in v.226

  ViewVC Help
Powered by ViewVC