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

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

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

revision 227 by schoenebeck, Thu Aug 26 22:05:44 2004 UTC revision 403 by schoenebeck, Tue Feb 22 20:37:59 2005 UTC
# Line 23  Line 23 
23  #include "AudioOutputDeviceJack.h"  #include "AudioOutputDeviceJack.h"
24  #include "AudioOutputDeviceFactory.h"  #include "AudioOutputDeviceFactory.h"
25    
26  #if HAVE_JACK  #include <errno.h>
   
 namespace LinuxSampler {  
27    
28      REGISTER_AUDIO_OUTPUT_DRIVER(AudioOutputDeviceJack);  #if HAVE_JACK
29    
30      /* Common parameters for now they'll have to be registered here. */  #ifndef HAVE_JACK_CLIENT_NAME_SIZE
31      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterActive);  #define jack_client_name_size() 33
32      REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterChannels);  #endif
33    
34    namespace LinuxSampler {
35    
36        /// number of currently existing JACK audio output devices in LinuxSampler
37        static int existingJackDevices = 0;
38    
39  // *************** ParameterName ***************  // *************** AudioChannelJack::ParameterName ***************
40  // *  // *
41    
42      AudioOutputDeviceJack::AudioChannelJack::ParameterName::ParameterName(AudioChannelJack* pChannel) : AudioChannel::ParameterName(ToString(pChannel->ChannelNr)) {      AudioOutputDeviceJack::AudioChannelJack::ParameterName::ParameterName(AudioChannelJack* pChannel) : AudioChannel::ParameterName(ToString(pChannel->ChannelNr)) {
# Line 48  namespace LinuxSampler { Line 49  namespace LinuxSampler {
49    
50    
51    
52  // *************** ParameterJackBindings ***************  // *************** AudioChannelJack::ParameterJackBindings ***************
53  // *  // *
54    
55      AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::ParameterJackBindings(AudioChannelJack* pChannel) : DeviceRuntimeParameterStrings(std::vector<String>()) {      AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::ParameterJackBindings(AudioChannelJack* pChannel) : DeviceRuntimeParameterStrings(std::vector<String>()) {
# Line 74  namespace LinuxSampler { Line 75  namespace LinuxSampler {
75    
76      void AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::OnSetValue(std::vector<String> vS) {      void AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::OnSetValue(std::vector<String> vS) {
77          // TODO: we should remove all existing bindings before we connect new ones here          // TODO: we should remove all existing bindings before we connect new ones here
78          String src_name = "LinuxSampler:" + ((DeviceRuntimeParameterString*)pChannel->Parameters["NAME"])->ValueAsString();          String src_name = ((DeviceCreationParameterString*)pChannel->pDevice->Parameters["NAME"])->ValueAsString() + ":" +
79                              ((DeviceRuntimeParameterString*)pChannel->Parameters["NAME"])->ValueAsString();
80          for (int i = 0; i < vS.size(); i++) {          for (int i = 0; i < vS.size(); i++) {
81              String dst_name = vS[i];              String dst_name = vS[i];
82              int res = jack_connect(pChannel->pDevice->hJackClient, src_name.c_str(), dst_name.c_str());              int res = jack_connect(pChannel->pDevice->hJackClient, src_name.c_str(), dst_name.c_str());
# Line 112  namespace LinuxSampler { Line 114  namespace LinuxSampler {
114    
115    
116    
117    // *************** AudioOutputDeviceJack::ParameterName ***************
118    // *
119    
120        AudioOutputDeviceJack::ParameterName::ParameterName() : DeviceCreationParameterString() {
121            InitWithDefault(); // use default name
122        }
123    
124        AudioOutputDeviceJack::ParameterName::ParameterName(String s) throw (LinuxSamplerException) : DeviceCreationParameterString(s) {
125        }
126    
127        String AudioOutputDeviceJack::ParameterName::Description() {
128            return "Arbitrary JACK client name";
129        }
130    
131        bool AudioOutputDeviceJack::ParameterName::Fix() {
132            return true;
133        }
134    
135        bool AudioOutputDeviceJack::ParameterName::Mandatory() {
136            return false;
137        }
138    
139        std::map<String,DeviceCreationParameter*> AudioOutputDeviceJack::ParameterName::DependsAsParameters() {
140            return std::map<String,DeviceCreationParameter*>(); // no dependencies
141        }
142    
143        std::vector<String> AudioOutputDeviceJack::ParameterName::PossibilitiesAsString(std::map<String,String> Parameters) {
144            return std::vector<String>();
145        }
146    
147        optional<String> AudioOutputDeviceJack::ParameterName::DefaultAsString(std::map<String,String> Parameters) {
148            return (existingJackDevices) ? "LinuxSampler" + ToString(existingJackDevices) : "LinuxSampler";
149        }
150    
151        void AudioOutputDeviceJack::ParameterName::OnSetValue(String s) throw (LinuxSamplerException) {
152            // not possible, as parameter is fix
153        }
154    
155        String AudioOutputDeviceJack::ParameterName::Name() {
156            return "NAME";
157        }
158    
159    
160    
161  // *************** AudioOutputDeviceJack ***************  // *************** AudioOutputDeviceJack ***************
162  // *  // *
163    
# Line 123  namespace LinuxSampler { Line 169  namespace LinuxSampler {
169       * @see AcquireChannels()       * @see AcquireChannels()
170       */       */
171      AudioOutputDeviceJack::AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) {      AudioOutputDeviceJack::AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) {
172          if ((hJackClient = jack_client_new("LinuxSampler")) == 0)          if (((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().size() >= jack_client_name_size())
173                throw LinuxSamplerException("JACK client name too long");
174    
175            if ((hJackClient = jack_client_new(((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().c_str())) == 0)
176              throw AudioOutputException("Seems Jack server not running.");              throw AudioOutputException("Seems Jack server not running.");
177    
178            existingJackDevices++;
179    
180          jack_set_process_callback(hJackClient, __libjack_process_callback, this);          jack_set_process_callback(hJackClient, __libjack_process_callback, this);
181          jack_on_shutdown(hJackClient, __libjack_shutdown_callback, this);          jack_on_shutdown(hJackClient, __libjack_shutdown_callback, this);
182          if (jack_activate(hJackClient))          if (jack_activate(hJackClient))
# Line 143  namespace LinuxSampler { Line 194  namespace LinuxSampler {
194      AudioOutputDeviceJack::~AudioOutputDeviceJack() {      AudioOutputDeviceJack::~AudioOutputDeviceJack() {
195          // destroy jack client          // destroy jack client
196          jack_client_close(hJackClient);          jack_client_close(hJackClient);
197            existingJackDevices--;
198      }      }
199    
200      /**      /**
# Line 197  namespace LinuxSampler { Line 249  namespace LinuxSampler {
249      }      }
250    
251      String AudioOutputDeviceJack::Version() {      String AudioOutputDeviceJack::Version() {
252         String s = "$Revision: 1.12 $";         String s = "$Revision: 1.17 $";
253         return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword         return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
254      }      }
255    

Legend:
Removed from v.227  
changed lines
  Added in v.403

  ViewVC Help
Powered by ViewVC