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

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

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

revision 1682 by schoenebeck, Wed Feb 13 15:31:56 2008 UTC revision 2478 by persson, Sat Oct 19 07:52:33 2013 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 - 2008 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2013 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program 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  *
# Line 40  Line 40 
40  #endif  #endif
41    
42  namespace LinuxSampler {  namespace LinuxSampler {
43        
44        class JackClient;
45        class JackListener;
46    
47      /** JACK audio output driver      /** JACK audio output driver
48       *       *
# Line 62  namespace LinuxSampler { Line 65  namespace LinuxSampler {
65                      class ParameterName : public AudioChannel::ParameterName {                      class ParameterName : public AudioChannel::ParameterName {
66                          public:                          public:
67                              ParameterName(AudioChannelJack* pChannel);                              ParameterName(AudioChannelJack* pChannel);
68                              virtual void OnSetValue(String s);                              virtual void OnSetValue(String s) OVERRIDE;
69                          protected:                          protected:
70                              AudioChannelJack* pChannel;                              AudioChannelJack* pChannel;
71                      };                      };
# Line 74  namespace LinuxSampler { Line 77  namespace LinuxSampler {
77                      class ParameterJackBindings : public DeviceRuntimeParameterStrings {                      class ParameterJackBindings : public DeviceRuntimeParameterStrings {
78                          public:                          public:
79                              ParameterJackBindings(AudioChannelJack* pChannel);                              ParameterJackBindings(AudioChannelJack* pChannel);
80                              virtual String              Description();                              virtual String              Description() OVERRIDE;
81                              virtual bool                Fix();                              virtual bool                Fix() OVERRIDE;
82                              virtual std::vector<String> PossibilitiesAsString();                              virtual std::vector<String> PossibilitiesAsString() OVERRIDE;
83                              virtual void                OnSetValue(std::vector<String> vS);                              virtual void                OnSetValue(std::vector<String> vS) OVERRIDE;
84                              static String Name();                              static String Name();
85                          protected:                          protected:
86                              AudioChannelJack*   pChannel;                              AudioChannelJack*   pChannel;
# Line 86  namespace LinuxSampler { Line 89  namespace LinuxSampler {
89                  protected:                  protected:
90                      AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException);                      AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException);
91                      ~AudioChannelJack();                      ~AudioChannelJack();
92                        void UpdateJackBuffer(uint size);
93                      friend class AudioOutputDeviceJack;                      friend class AudioOutputDeviceJack;
94                  private:                  private:
95                      AudioOutputDeviceJack* pDevice;                      AudioOutputDeviceJack* pDevice;
# Line 104  namespace LinuxSampler { Line 108  namespace LinuxSampler {
108                  public:                  public:
109                      ParameterName();                      ParameterName();
110                      ParameterName(String s) throw (Exception);                      ParameterName(String s) throw (Exception);
111                      virtual String              Description();                      virtual String              Description() OVERRIDE;
112                      virtual bool                Fix();                      virtual bool                Fix() OVERRIDE;
113                      virtual bool                Mandatory();                      virtual bool                Mandatory() OVERRIDE;
114                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters() OVERRIDE;
115                      virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters);                      virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters) OVERRIDE;
116                      virtual optional<String>    DefaultAsString(std::map<String,String> Parameters);                      virtual optional<String>    DefaultAsString(std::map<String,String> Parameters) OVERRIDE;
117                      virtual void                OnSetValue(String s) throw (Exception);                      virtual void                OnSetValue(String s) throw (Exception) OVERRIDE;
118                      static String Name();                      static String Name();
119              };              };
120    
121              // derived abstract methods from class 'AudioOutputDevice'              // derived abstract methods from class 'AudioOutputDevice'
122              virtual void Play();              virtual void Play() OVERRIDE;
123              virtual bool IsPlaying();              virtual bool IsPlaying() OVERRIDE;
124              virtual void Stop();              virtual void Stop() OVERRIDE;
125              virtual uint MaxSamplesPerCycle();              virtual uint MaxSamplesPerCycle() OVERRIDE;
126              virtual uint SampleRate();              virtual uint SampleRate() OVERRIDE;
127              virtual AudioChannel* CreateChannel(uint ChannelNr);              virtual AudioChannel* CreateChannel(uint ChannelNr) OVERRIDE;
128                virtual String Driver() OVERRIDE;
129                virtual float latency() OVERRIDE;
130                
131              static String Name();              static String Name();
132    
             virtual String Driver();  
   
133              static String Description();              static String Description();
134              static String Version();              static String Version();
135    
136              int Process(uint Samples);  // FIXME: should be private              int Process(uint Samples);  // FIXME: should be private
137                void UpdateJackBuffers(uint size);
138                void addListener(JackListener* listener);
139                jack_client_t* jackClientHandle();
140          protected:          protected:
141              AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0);              AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0);
142          private:          private:
143              ConditionServer csIsPlaying;              ConditionServer csIsPlaying;
144              uint            uiMaxSamplesPerCycle;              uint            uiMaxSamplesPerCycle;
145              jack_client_t*  hJackClient;              jack_client_t*  hJackClient;
146                JackClient* pJackClient;
147      };      };
148    
149      // Callback functions for the libjack API      // Callback functions for the libjack API
150      int  linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg);      int  linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg);
     void linuxsampler_libjack_shutdown_callback(void* arg);  
   
151    
152      /** JACK client      /** JACK client
153       *       *
# Line 164  namespace LinuxSampler { Line 169  namespace LinuxSampler {
169              #if HAVE_JACK_MIDI              #if HAVE_JACK_MIDI
170              void SetMidiInputDevice(MidiInputDeviceJack* device);              void SetMidiInputDevice(MidiInputDeviceJack* device);
171              #endif              #endif
172                void addListener(JackListener* listener);
173    
174              jack_client_t* hJackClient;              jack_client_t* hJackClient;
175    
176          private:          private:
177                std::vector<JackListener*> jackListeners;
178              static std::map<String, JackClient*> Clients;              static std::map<String, JackClient*> Clients;
179              struct config_t {              struct config_t {
180                  AudioOutputDeviceJack* AudioDevice;                  AudioOutputDeviceJack* AudioDevice;
# Line 182  namespace LinuxSampler { Line 189  namespace LinuxSampler {
189    
190              JackClient(String Name);              JackClient(String Name);
191              ~JackClient();              ~JackClient();
192            
193                // Callback functions for the libjack API
194    #if HAVE_JACK_ON_INFO_SHUTDOWN
195                static void libjackShutdownCallback(jack_status_t code, const char* reason, void *arg);
196    #else
197                static void libjackShutdownCallback(void *arg);
198    #endif
199                static int libjackSampleRateCallback(jack_nframes_t nframes, void *arg);
200                static int libjackBufferSizeCallback(jack_nframes_t nframes, void *arg);
201        };
202        
203        /**
204         * Currently not derived / instantiated by the sampler itself, however this
205         * class can be subclassed and used i.e. by a GUI build on top of the sampler,
206         * to react on JACK events. Because registering JACK callback functions through
207         * the general JACK API is not possible after the JACK client has been activated,
208         * and the latter is already the case as soon as an AudioOutputDeviceJack object
209         * has been instantiated.
210         */
211        class JackListener {
212        public:
213            virtual void onJackShutdown(jack_status_t code, const char* reason) = 0;
214      };      };
215  }  }
216    

Legend:
Removed from v.1682  
changed lines
  Added in v.2478

  ViewVC Help
Powered by ViewVC