~ubuntu-branches/ubuntu/natty/ecasound2.2/natty

« back to all changes in this revision

Viewing changes to libecasound/plugins/audioio_jack.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2009-05-06 15:18:46 UTC
  • mfrom: (5.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090506151846-dvp8mirqmxwhve66
Tags: 2.6.0-1
* New upstream release
- 08_fix_header_install: remove
- 07_configure_in_maintainer_mode: update
- do not install manpage copies, and just install symlinks for
  ecatools.1
* Build-Depend on texlive-latex-recommended too for ecrm1000 font.
  (closes: #526535)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// ------------------------------------------------------------------------
2
2
// audioio-jack.cpp: Interface to JACK audio framework
3
 
// Copyright (C) 2001-2003 Kai Vehmanen
 
3
// Copyright (C) 2001-2003,2008 Kai Vehmanen
4
4
//
5
5
// Attributes:
6
 
//     eca-style-version: 3
 
6
//     eca-style-version: 3 (see Ecasound Programmer's Guide)
7
7
//
8
8
// This program is free software; you can redistribute it and/or modify
9
9
// it under the terms of the GNU General Public License as published by
54
54
  
55
55
  jackmgr_rep = 0;
56
56
  myid_rep = 0;
57
 
  secondparam_rep = "";
58
57
}
59
58
 
60
59
AUDIO_IO_JACK::~AUDIO_IO_JACK(void)
93
92
  if (jackmgr_rep != 0) {
94
93
    string my_in_portname ("in"), my_out_portname ("out");
95
94
 
96
 
    if (label() == "jack_generic") {
97
 
      my_in_portname = my_out_portname = secondparam_rep;
98
 
    }
99
 
 
100
 
    // FIXME: required?
101
 
    // if (workstring.size() == 0) workstring = label();
 
95
    if (label() == "jack" &&
 
96
        params_rep.size() > 2 && 
 
97
        params_rep[2].size() > 0) {
 
98
      my_in_portname = my_out_portname = params_rep[2];
 
99
    }
 
100
    /* note: deprecated interface */
 
101
    else if (label() == "jack_generic" &&
 
102
             params_rep.size() > 1) {
 
103
      my_in_portname = my_out_portname = params_rep[1];
 
104
    }
102
105
 
103
106
    jackmgr_rep->open(myid_rep);
104
107
 
132
135
 
133
136
    /* - make automatic connections */
134
137
 
135
 
    if (label() == "jack_alsa") {
 
138
    if (label() == "jack" &&
 
139
        params_rep.size() > 1 &&
 
140
        params_rep[1].size() > 0) {
 
141
      /* note: if 2nd param given, use it as the client to autoconnect to */
 
142
      jackmgr_rep->auto_connect_jack_port_client(myid_rep, params_rep[1], channels());
 
143
    }
 
144
    else if (label() == "jack_multi") {
 
145
      int i;
 
146
      for(i = 0; i < channels(); i++) {
 
147
        if (static_cast<int>(params_rep.size()) > i + 1 &&
 
148
            params_rep[i + 1].size() > 0) {
 
149
          ECA_LOG_MSG(ECA_LOGGER::user_objects, 
 
150
                      "adding auto connection from " +
 
151
                      my_out_portname + "_" + kvu_numtostr(i + 1) + 
 
152
                      " to " + 
 
153
                      params_rep[i + 1]);
 
154
          jackmgr_rep->auto_connect_jack_port(myid_rep, i + 1, params_rep[i + 1]);
 
155
        }
 
156
 
 
157
 
 
158
      }
 
159
    }
 
160
    else if (label() == "jack_alsa") {
 
161
      /* note: deprecated feature: 'alsa_pcm' is hidden in the port
 
162
         list returned by jack_get_ports(), but as you can still
 
163
         connect with the direct backend names, we have to keep this
 
164
         code around to be backward compatible */
136
165
      string in_aconn_portprefix, out_aconn_portprefix;
137
166
 
138
167
      in_aconn_portprefix = "alsa_pcm:capture_";
147
176
        }
148
177
      }
149
178
    }
150
 
    else if (label() == "jack_auto") {
151
 
      jackmgr_rep->auto_connect_jack_port_client(myid_rep, secondparam_rep, channels());
 
179
    /* note: deprecated interface, plain "jack" should be used now */
 
180
    else if (label() == "jack_auto" &&
 
181
             params_rep.size() > 1 &&
 
182
             params_rep[1].size() > 0) {
 
183
      jackmgr_rep->auto_connect_jack_port_client(myid_rep, params_rep[1], channels());
152
184
    }
153
185
  }
154
186
 
227
259
  if (label() == "jack_generic")
228
260
    return "label,portname";
229
261
 
230
 
  if (label() == "jack_auto")
 
262
  else if (label() == "jack_auto")
231
263
    return "label,client";
232
264
 
233
 
  /* jack, jack_alsa */
234
 
  return "label";
 
265
  else if (label() == "jack_multi") {
 
266
    string paramlist = "label,";
 
267
    int i;
 
268
    for(i = 0; i < channels(); i++) {
 
269
      paramlist += ",dstport" + kvu_numtostr(i + 1);
 
270
    }
 
271
    return paramlist;
 
272
  }
 
273
 
 
274
  /* jack */
 
275
  return "label,client,portprefix";
235
276
}
236
277
 
237
278
void AUDIO_IO_JACK::set_parameter(int param, std::string value)
238
279
{
239
 
  switch(param) 
240
 
    {
241
 
    case 1: { set_label(value); break; }
242
 
    case 2: { secondparam_rep = value; break; }
243
 
    }
 
280
  if (param > static_cast<int>(params_rep.size()))
 
281
    params_rep.resize(param);
 
282
 
 
283
  params_rep[param - 1] = value;
 
284
 
 
285
  if (param == 1) {
 
286
    set_label(value);
 
287
  }
244
288
}
245
289
 
246
290
std::string AUDIO_IO_JACK::get_parameter(int param) const
247
291
{
248
 
  switch(param) 
249
 
    {
250
 
    case 1: { return label(); }
251
 
    case 2: { return secondparam_rep; }
252
 
    }  
 
292
  if (param > 0 && param <= static_cast<int>(params_rep.size()))
 
293
    return params_rep[param - 1];
253
294
 
254
 
  return "";
 
295
  return AUDIO_IO::get_parameter(param);
255
296
}