/[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 221 by schoenebeck, Fri Aug 20 17:25:19 2004 UTC revision 1651 by persson, Sun Jan 27 15:07:11 2008 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                       *
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 23  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 33  Line 34 
34    
35  #include "AudioOutputDevice.h"  #include "AudioOutputDevice.h"
36  #include "../../common/ConditionServer.h"  #include "../../common/ConditionServer.h"
37    #include "../midi/MidiInputDeviceJack.h"
38    
39  namespace LinuxSampler {  namespace LinuxSampler {
40    
# Line 43  namespace LinuxSampler { Line 45  namespace LinuxSampler {
45      class AudioOutputDeviceJack : public AudioOutputDevice {      class AudioOutputDeviceJack : public AudioOutputDevice {
46          public:          public:
47              AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters);              AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters);
48              ~AudioOutputDeviceJack();              virtual ~AudioOutputDeviceJack();
49    
50              /** Audio Channel Parameter 'JACK_BINDINGS'              /**
51               *               * Audio channel implementation for the JACK audio driver.
              * Used to connect to other JACK clients.  
52               */               */
53              class ParameterJackBindings : public DeviceRuntimeParameterStrings {              class AudioChannelJack : public AudioChannel {
54                  public:                  public:
55                      ParameterJackBindings(AudioChannel* pChannel, std::vector<String> InitialBindings) : DeviceRuntimeParameterStrings(InitialBindings) { this->pChannel = pChannel; }                      /** Audio Channel Parameter 'NAME'
56                      virtual String              Description()                      { return "Bindings to other JACK clients";                     }                       *
57                      virtual bool                Fix()                              { return false;                                                }                       * Used to assign an arbitrary name to an audio channel.
58                      virtual std::vector<String> PossibilitiesAsString()            { return std::vector<String>(); /* TODO: to be implemented */  }                       */
59                      virtual void                OnSetValue(std::vector<String> vS) { /* TODO: code to connect to other jack clients */            }                      class ParameterName : public AudioChannel::ParameterName {
60                            public:
61                                ParameterName(AudioChannelJack* pChannel);
62                                virtual void OnSetValue(String s);
63                            protected:
64                                AudioChannelJack* pChannel;
65                        };
66    
67                        /** Audio Channel Parameter 'JACK_BINDINGS'
68                         *
69                         * Used to connect to other JACK clients.
70                         */
71                        class ParameterJackBindings : public DeviceRuntimeParameterStrings {
72                            public:
73                                ParameterJackBindings(AudioChannelJack* pChannel);
74                                virtual String              Description();
75                                virtual bool                Fix();
76                                virtual std::vector<String> PossibilitiesAsString();
77                                virtual void                OnSetValue(std::vector<String> vS);
78                                static String Name();
79                            protected:
80                                AudioChannelJack*   pChannel;
81                                std::vector<String> Bindings;
82                        };
83                  protected:                  protected:
84                      AudioChannel* pChannel;                      AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException);
85                        ~AudioChannelJack();
86                        friend class AudioOutputDeviceJack;
87                    private:
88                        AudioOutputDeviceJack* pDevice;
89                        jack_port_t*           hJackPort;
90                        uint                   ChannelNr;
91    
92                        float* CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException);
93                };
94    
95                /** Audio Device Parameter 'NAME'
96                 *
97                 * Used to assign an arbitrary name to the JACK client of this
98                 * audio device.
99                 */
100                class ParameterName : public DeviceCreationParameterString {
101                    public:
102                        ParameterName();
103                        ParameterName(String s) throw (Exception);
104                        virtual String              Description();
105                        virtual bool                Fix();
106                        virtual bool                Mandatory();
107                        virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
108                        virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters);
109                        virtual optional<String>    DefaultAsString(std::map<String,String> Parameters);
110                        virtual void                OnSetValue(String s) throw (Exception);
111                        static String Name();
112              };              };
113    
114              // derived abstract methods from class 'AudioOutputDevice'              // derived abstract methods from class 'AudioOutputDevice'
115              virtual void Play();              virtual void Play();
116              virtual bool IsPlaying();              virtual bool IsPlaying();
117              virtual void Stop();              virtual void Stop();
             virtual void AcquireChannels(uint uiChannels);  
118              virtual uint MaxSamplesPerCycle();              virtual uint MaxSamplesPerCycle();
119              virtual uint SampleRate();              virtual uint SampleRate();
120                virtual AudioChannel* CreateChannel(uint ChannelNr);
121    
122    
123              static String Name();              static String Name();
124    
125              virtual String Driver();              virtual String Driver();
126    
127              static String Description();              static String Description();
128              static String Version();              static String Version();
             static std::map<String,DeviceCreationParameter*> AvailableParameters();  
129    
130              int Process(uint Samples);  // FIXME: should be private              int Process(uint Samples);  // FIXME: should be private
131          protected:          protected:
132              AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0);              AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0);
133          private:          private:
134              ConditionServer           csIsPlaying;              ConditionServer csIsPlaying;
135              uint                      uiMaxSamplesPerCycle;              uint            uiMaxSamplesPerCycle;
136              jack_client_t*            hJackClient;              jack_client_t*  hJackClient;
             std::vector<jack_port_t*> hJackPorts;  
137      };      };
138    
139      // Callback functions for the libjack API      // Callback functions for the libjack API
140      int  __libjack_process_callback(jack_nframes_t nframes, void* arg);      int  linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg);
141      void __libjack_shutdown_callback(void* arg);      void linuxsampler_libjack_shutdown_callback(void* arg);
142    
143    
144        /** JACK client
145         *
146         * Represents a jack client. This class is shared by
147         * AudioOutputDeviceJack and MidiInputDeviceJack. The jack server
148         * calls JackClient::Process, which in turn calls
149         * AudioOutputDeviceJack::Process and/or
150         * MidiInputDeviceJack::Process.
151         */
152        class JackClient {
153            public:
154                static JackClient* CreateAudio(String Name);
155                static JackClient* CreateMidi(String Name);
156                static void ReleaseAudio(String Name);
157                static void ReleaseMidi(String Name);
158                int Process(uint Samples);
159                void Stop();
160                void SetAudioOutputDevice(AudioOutputDeviceJack* device);
161                void SetMidiInputDevice(MidiInputDeviceJack* device);
162    
163                jack_client_t* hJackClient;
164    
165            private:
166                static std::map<String, JackClient*> Clients;
167                struct config_t {
168                    AudioOutputDeviceJack* AudioDevice;
169                    MidiInputDeviceJack* MidiDevice;
170                };
171                SynchronizedConfig<config_t> Config;
172                SynchronizedConfig<config_t>::Reader ConfigReader;
173                bool audio;
174                bool midi;
175    
176                JackClient(String Name);
177                ~JackClient();
178        };
179  }  }
180    
181  #endif // HAVE_JACK  #endif // HAVE_JACK

Legend:
Removed from v.221  
changed lines
  Added in v.1651

  ViewVC Help
Powered by ViewVC