/[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 226 by schoenebeck, Wed Aug 25 22:00:33 2004 UTC revision 227 by schoenebeck, Thu Aug 26 22:05:44 2004 UTC
# Line 43  namespace LinuxSampler { Line 43  namespace LinuxSampler {
43      }      }
44    
45      void AudioOutputDeviceJack::AudioChannelJack::ParameterName::OnSetValue(String s) {      void AudioOutputDeviceJack::AudioChannelJack::ParameterName::OnSetValue(String s) {
46          String name = "LinuxSampler:" + s;          if (jack_port_set_name(pChannel->hJackPort, s.c_str())) throw AudioOutputException("Failed to rename JACK port");
         if (jack_port_set_name(pChannel->hJackPort, name.c_str())) throw AudioOutputException("Failed to rename JACK port");  
47      }      }
48    
49    
# Line 65  namespace LinuxSampler { Line 64  namespace LinuxSampler {
64      }      }
65    
66      std::vector<String> AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::PossibilitiesAsString() {      std::vector<String> AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::PossibilitiesAsString() {
67          const char** pPortNames = jack_get_ports(pChannel->pDevice->hJackClient, NULL, NULL, 0);          const char** pPortNames = jack_get_ports(pChannel->pDevice->hJackClient, NULL, NULL, JackPortIsInput);
68          if (!pPortNames) return std::vector<String>();          if (!pPortNames) return std::vector<String>();
69          std::vector<String> result;          std::vector<String> result;
70          for (int i = 0; pPortNames[i]; i++) result.push_back(pPortNames[i]);          for (int i = 0; pPortNames[i]; i++) result.push_back(pPortNames[i]);
# Line 74  namespace LinuxSampler { Line 73  namespace LinuxSampler {
73      }      }
74    
75      void AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::OnSetValue(std::vector<String> vS) {      void AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::OnSetValue(std::vector<String> vS) {
76          String src_name = "LinuxSampler:" + pChannel->Parameters["NAME"]->Value();          // TODO: we should remove all existing bindings before we connect new ones here
77            String src_name = "LinuxSampler:" + ((DeviceRuntimeParameterString*)pChannel->Parameters["NAME"])->ValueAsString();
78          for (int i = 0; i < vS.size(); i++) {          for (int i = 0; i < vS.size(); i++) {
79              String dst_name = vS[i];              String dst_name = vS[i];
80              if (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());
81                  throw AudioOutputException("Jack: Cannot connect to port '" + dst_name + "'");              if (res == EEXIST) throw AudioOutputException("Jack: Connection to port '" + dst_name + "' already established");
82              }              else if (res)      throw AudioOutputException("Jack: Cannot connect port '" + src_name + "' to port '" + dst_name + "'");
83          }          }
84      }      }
85    
# Line 104  namespace LinuxSampler { Line 104  namespace LinuxSampler {
104      }      }
105    
106      float* AudioOutputDeviceJack::AudioChannelJack::CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException) {      float* AudioOutputDeviceJack::AudioChannelJack::CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException) {
107          String port_id = "LinuxSampler:" + ToString(ChannelNr);          String port_id = ToString(ChannelNr);
108          hJackPort = jack_port_register(pDevice->hJackClient, port_id.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);          hJackPort = jack_port_register(pDevice->hJackClient, port_id.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
109          if (!hJackPort) throw AudioOutputException("Jack: Cannot register Jack output port.");          if (!hJackPort) throw AudioOutputException("Jack: Cannot register Jack output port.");
110          return (float*) jack_port_get_buffer(hJackPort, pDevice->uiMaxSamplesPerCycle);          return (float*) jack_port_get_buffer(hJackPort, pDevice->uiMaxSamplesPerCycle);
# Line 135  namespace LinuxSampler { Line 135  namespace LinuxSampler {
135    
136          // create audio channels          // create audio channels
137          AcquireChannels(((DeviceCreationParameterInt*)Parameters["CHANNELS"])->ValueAsInt());          AcquireChannels(((DeviceCreationParameterInt*)Parameters["CHANNELS"])->ValueAsInt());
138    
139            // finally activate device if desired
140            if (((DeviceCreationParameterBool*)Parameters["ACTIVE"])->ValueAsBool()) Play();
141      }      }
142    
143      AudioOutputDeviceJack::~AudioOutputDeviceJack() {      AudioOutputDeviceJack::~AudioOutputDeviceJack() {
# Line 194  namespace LinuxSampler { Line 197  namespace LinuxSampler {
197      }      }
198    
199      String AudioOutputDeviceJack::Version() {      String AudioOutputDeviceJack::Version() {
200         String s = "$Revision: 1.11 $";         String s = "$Revision: 1.12 $";
201         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
202      }      }
203    

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

  ViewVC Help
Powered by ViewVC