/[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 483 by schoenebeck, Mon Mar 21 23:40:56 2005 UTC revision 2412 by schoenebeck, Mon Feb 4 21:52:56 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 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 24  Line 24 
24  #ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__  #ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__
25  #define __LS_AUDIOOUTPUTDEVICEJACK_H__  #define __LS_AUDIOOUTPUTDEVICEJACK_H__
26    
27  #include "../../common/global.h"  #include "../../common/global_private.h"
28    
29  #if HAVE_JACK  #if HAVE_JACK
30    
# Line 35  Line 35 
35  #include "AudioOutputDevice.h"  #include "AudioOutputDevice.h"
36  #include "../../common/ConditionServer.h"  #include "../../common/ConditionServer.h"
37    
38    #if HAVE_JACK_MIDI
39    #include "../midi/MidiInputDeviceJack.h"
40    #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 82  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 99  namespace LinuxSampler { Line 107  namespace LinuxSampler {
107              class ParameterName : public DeviceCreationParameterString {              class ParameterName : public DeviceCreationParameterString {
108                  public:                  public:
109                      ParameterName();                      ParameterName();
110                      ParameterName(String s) throw (LinuxSamplerException);                      ParameterName(String s) throw (Exception);
111                      virtual String              Description();                      virtual String              Description();
112                      virtual bool                Fix();                      virtual bool                Fix();
113                      virtual bool                Mandatory();                      virtual bool                Mandatory();
114                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();                      virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
115                      virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters);                      virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters);
116                      virtual optional<String>    DefaultAsString(std::map<String,String> Parameters);                      virtual optional<String>    DefaultAsString(std::map<String,String> Parameters);
117                      virtual void                OnSetValue(String s) throw (LinuxSamplerException);                      virtual void                OnSetValue(String s) throw (Exception);
118                      static String Name();                      static String Name();
119              };              };
120    
# Line 117  namespace LinuxSampler { Line 125  namespace LinuxSampler {
125              virtual uint MaxSamplesPerCycle();              virtual uint MaxSamplesPerCycle();
126              virtual uint SampleRate();              virtual uint SampleRate();
127              virtual AudioChannel* CreateChannel(uint ChannelNr);              virtual AudioChannel* CreateChannel(uint ChannelNr);
128                virtual float latency();
129    
130                static String Name();
             static String Name();  
131    
132              virtual String Driver();              virtual String Driver();
133    
# Line 127  namespace LinuxSampler { Line 135  namespace LinuxSampler {
135              static String Version();              static String Version();
136    
137              int Process(uint Samples);  // FIXME: should be private              int Process(uint Samples);  // FIXME: should be private
138                void UpdateJackBuffers(uint size);
139                void addListener(JackListener* listener);
140                jack_client_t* jackClientHandle();
141          protected:          protected:
142              AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0);              AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0);
143          private:          private:
144              ConditionServer csIsPlaying;              ConditionServer csIsPlaying;
145              uint            uiMaxSamplesPerCycle;              uint            uiMaxSamplesPerCycle;
146              jack_client_t*  hJackClient;              jack_client_t*  hJackClient;
147                JackClient* pJackClient;
148      };      };
149    
150      // Callback functions for the libjack API      // Callback functions for the libjack API
151      int  __libjack_process_callback(jack_nframes_t nframes, void* arg);      int  linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg);
152      void __libjack_shutdown_callback(void* arg);  
153        /** JACK client
154         *
155         * Represents a jack client. This class is shared by
156         * AudioOutputDeviceJack and MidiInputDeviceJack. The jack server
157         * calls JackClient::Process, which in turn calls
158         * AudioOutputDeviceJack::Process and/or
159         * MidiInputDeviceJack::Process.
160         */
161        class JackClient {
162            public:
163                static JackClient* CreateAudio(String Name);
164                static JackClient* CreateMidi(String Name);
165                static void ReleaseAudio(String Name);
166                static void ReleaseMidi(String Name);
167                int Process(uint Samples);
168                void Stop();
169                void SetAudioOutputDevice(AudioOutputDeviceJack* device);
170                #if HAVE_JACK_MIDI
171                void SetMidiInputDevice(MidiInputDeviceJack* device);
172                #endif
173                void addListener(JackListener* listener);
174    
175                jack_client_t* hJackClient;
176    
177            private:
178                std::vector<JackListener*> jackListeners;
179                static std::map<String, JackClient*> Clients;
180                struct config_t {
181                    AudioOutputDeviceJack* AudioDevice;
182                    #if HAVE_JACK_MIDI
183                    MidiInputDeviceJack* MidiDevice;
184                    #endif
185                };
186                SynchronizedConfig<config_t> Config;
187                SynchronizedConfig<config_t>::Reader ConfigReader;
188                bool audio;
189                bool midi;
190    
191                JackClient(String Name);
192                ~JackClient();
193            
194                // Callback functions for the libjack API
195                static void libjackShutdownCallback(void* arg);
196                static int libjackSampleRateCallback(jack_nframes_t nframes, void *arg);
197                static int libjackBufferSizeCallback(jack_nframes_t nframes, void *arg);
198        };
199        
200        /**
201         * Currently not derived / instantiated by the sampler itself, however this
202         * class can be subclassed and used i.e. by a GUI build on top of the sampler,
203         * to react on JACK events. Because registering JACK callback functions through
204         * the general JACK API is not possible after the JACK client has been activated,
205         * and the latter is already the case as soon as an AudioOutputDeviceJack object
206         * has been instantiated.
207         */
208        class JackListener {
209        public:
210            virtual void onJackShutdown() = 0;
211        };
212  }  }
213    
214  #endif // HAVE_JACK  #endif // HAVE_JACK

Legend:
Removed from v.483  
changed lines
  Added in v.2412

  ViewVC Help
Powered by ViewVC