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

Diff of /linuxsampler/trunk/src/audiodriver/AudioOutputDevice.h

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

revision 122 by schoenebeck, Thu May 6 20:06:20 2004 UTC revision 123 by schoenebeck, Mon Jun 14 19:33:16 2004 UTC
# Line 24  Line 24 
24  #define __LS_AUDIOOUTPUTDEVICE_H__  #define __LS_AUDIOOUTPUTDEVICE_H__
25    
26  #include <set>  #include <set>
27    #include <map>
28  #include <vector>  #include <vector>
29  #include <stdexcept>  #include <stdexcept>
30    
31  #include "../common/global.h"  #include "../common/global.h"
32  #include "../common/LinuxSamplerException.h"  #include "../common/LinuxSamplerException.h"
33    #include "../drivers/DeviceParameter.h"
34  #include "../engines/common/Engine.h"  #include "../engines/common/Engine.h"
35  #include "AudioChannel.h"  #include "AudioChannel.h"
36    
# Line 46  namespace LinuxSampler { Line 48  namespace LinuxSampler {
48      class AudioOutputDevice {      class AudioOutputDevice {
49          public:          public:
50    
51    
52              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
53              // type definitions              // type definitions
54    
55              /**              class ParameterActive : public DeviceCreationParameterBool {
56               * List of all currently implemented audio output drivers.                  public:
57               */                      ParameterActive(AudioOutputDevice* pDevice)                              { this->pDevice = pDevice;                            }
58              enum type_t {                      virtual String Description()                                             { return "Enable / disable device";                   }
59                  type_alsa,                      virtual bool   Fix()                                                     { return false;                                       }
60                  type_jack                      virtual bool   Mandatory()                                               { return false;                                       }
61                        virtual std::map<String,DeviceCreationParameter*> DependsAsParameters()  { return std::map<String,DeviceCreationParameter*>(); }
62                        virtual optional<bool> DefaultAsBool(std::map<String,String> Parameters) { return optional<bool>::nothing;                     }
63                        virtual void OnSetValue(bool b) throw (LinuxSamplerException)            { if (b) pDevice->Play(); else pDevice->Stop();       }
64                    protected:
65                        AudioOutputDevice* pDevice;
66                };
67    
68                class ParameterSampleRate : public DeviceCreationParameterInt {
69                    public:
70                        ParameterSampleRate(AudioOutputDevice* pDevice)                                 { this->pDevice = pDevice;                            }
71                        virtual String Description()                                                    { return "Output sample rate";                        }
72                        virtual bool   Fix()                                                            { return true;                                        }
73                        virtual bool   Mandatory()                                                      { return false;                                       }
74                        virtual std::map<String,DeviceCreationParameter*> DependsAsParameters()         { return std::map<String,DeviceCreationParameter*>(); }
75                        virtual optional<int>    DefaultAsInt(std::map<String,String> Parameters)       { return optional<int>::nothing;                      }
76                        virtual optional<int>    RangeMinAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }
77                        virtual optional<int>    RangeMaxAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }
78                        virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) { return std::vector<int>();                          }
79                        virtual void             OnSetValue(int i) throw (LinuxSamplerException)        { /* cannot happen, as parameter is fix */            }
80                    protected:
81                        AudioOutputDevice* pDevice;
82                };
83    
84                class ParameterChannels : public DeviceCreationParameterInt {
85                    public:
86                        ParameterChannels(AudioOutputDevice* pDevice)                                   { this->pDevice = pDevice;                            }
87                        virtual String Description()                                                    { return "Number of output channels";                 }
88                        virtual bool   Fix()                                                            { return false;                                       }
89                        virtual bool   Mandatory()                                                      { return false;                                       }
90                        virtual std::map<String,DeviceCreationParameter*> DependsAsParameters()         { return std::map<String,DeviceCreationParameter*>(); }
91                        virtual optional<int>    DefaultAsInt(std::map<String,String> Parameters)       { return optional<int>::nothing;                      }
92                        virtual optional<int>    RangeMinAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }
93                        virtual optional<int>    RangeMaxAsInt(std::map<String,String> Parameters)      { return optional<int>::nothing;                      }
94                        virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) { return std::vector<int>();                          }
95                        virtual void             OnSetValue(int i) throw (LinuxSamplerException)        { pDevice->AcquireChannels(i);                        }
96                    protected:
97                        AudioOutputDevice* pDevice;
98              };              };
99    
100    
# Line 132  namespace LinuxSampler { Line 172  namespace LinuxSampler {
172               */               */
173              virtual uint SampleRate() = 0;              virtual uint SampleRate() = 0;
174    
175                static std::map<String,DeviceCreationParameter*> AvailableParameters();
176    
177    
178    
179              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
# Line 163  namespace LinuxSampler { Line 205  namespace LinuxSampler {
205               */               */
206              AudioChannel* Channel(uint ChannelIndex);              AudioChannel* Channel(uint ChannelIndex);
207    
208              /**              std::map<String,DeviceCreationParameter*> DeviceParameters();
209               * Returns the ID that identifies the implementing audio output  
              * driver.  
              */  
             type_t Type();  
210    
211          protected:          protected:
212              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.
213              std::vector<AudioChannel*> Channels; ///< All audio channels of the audio output device. This is just a container; the descendant has to create channels by himself.              std::vector<AudioChannel*>                Channels;    ///< All audio channels of the audio output device. This is just a container; the descendant has to create channels by himself.
214              type_t                     AudioOutputType;              std::map<String,DeviceCreationParameter*> Parameters;  ///< All device parameters.
215    
216              /**              AudioOutputDevice(std::map<String,DeviceCreationParameter*> DriverParameters);
217               * Constructor. Has to be called by the implementing audio  
218               * output driver to define the ID of the driver. When a new              virtual ~AudioOutputDevice();
              * audio output driver is implemented, the  
              * AudioOutputDevice::type_t enumeration has to be extended with  
              * a new ID for the new audio output driver.  
              */  
             AudioOutputDevice(type_t Type);  
219    
220              /**              /**
221               * This method should be called by the AudioOutputDevice               * This method should be called by the AudioOutputDevice
# Line 207  namespace LinuxSampler { Line 241  namespace LinuxSampler {
241               * @returns  0 on success               * @returns  0 on success
242               */               */
243              int RenderSilence(uint Samples);              int RenderSilence(uint Samples);
244    
245                friend class Sampler; // allow Sampler class to destroy audio devices
246    
247            private:
248                 static std::map<String,DeviceCreationParameter*> CreateAvailableParameters();
249      };      };
250    
251      /**      /**

Legend:
Removed from v.122  
changed lines
  Added in v.123

  ViewVC Help
Powered by ViewVC