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

« back to all changes in this revision

Viewing changes to libecasound/eca-control-objects.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2008-03-23 21:42:49 UTC
  • mfrom: (3.1.6 hardy)
  • Revision ID: james.westby@ubuntu.com-20080323214249-evlfv3y1o8q747la
Tags: 2.4.6.1-2
* Bug fix: "FTBFS with GCC 4.3: missing #includes", thanks to Martin
  Michlmayr (Closes: #454890).
- 13_gcc4: updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// ------------------------------------------------------------------------
2
2
// eca-control-objects.cpp: Class for configuring libecasound objects
3
 
// Copyright (C) 2000-2004 Kai Vehmanen
 
3
// Copyright (C) 2000-2004,2006 Kai Vehmanen
4
4
// Copyright (C) 2005 Stuart Allie
5
5
//
6
6
// Attributes:
7
 
//     eca-style-version: 3
 
7
//     eca-style-version: 3 (see Ecasound Programmer's Guide)
8
8
//
9
9
// This program is free software; you can redistribute it and/or modify
10
10
// it under the terms of the GNU General Public License as published by
322
322
  else {
323
323
    /* 6. reload the edited chainsetup and reset runtime state */
324
324
    load_chainsetup(filename);
325
 
    remove(filename.c_str());
326
 
    if (origfilename.empty() != true) {
327
 
      set_chainsetup_filename(origfilename);
 
325
 
 
326
    if (is_selected() != true) {
 
327
      ECA_LOG_MSG(ECA_LOGGER::info, 
 
328
                  std::string("Unable to parse chainsetup, keeping the temporary file ") + filename);
328
329
    }
329
 
    selected_chainsetup_repp->seek_position_in_samples(origpos);
330
 
    
331
 
    if (hot_swap == true) {
332
 
      /* 6.1 disconnect the chainsetup to be replaced */
333
 
      disconnect_chainsetup();
334
 
 
335
 
      /* 6.2 try to connect the edited chainsetup */
336
 
      select_chainsetup("cs-edit-temp");
337
 
      if (is_valid() == true) {
338
 
        connect_chainsetup();
339
 
        /* should succeed as is_valid() is true */
340
 
        DBC_CHECK(is_connected() == true);
341
 
        if (is_connected() == true) {
342
 
          if (restart == true) {
343
 
            DBC_CHECK(is_running() != true);
344
 
            start();
 
330
    else {
 
331
      remove(filename.c_str());
 
332
      if (origfilename.empty() != true) {
 
333
        set_chainsetup_filename(origfilename);
 
334
      }
 
335
 
 
336
      if (selected_chainsetup_repp)
 
337
        selected_chainsetup_repp->seek_position_in_samples(origpos);
 
338
 
 
339
      if (hot_swap == true) {
 
340
        /* 6.1 disconnect the chainsetup to be replaced */
 
341
        disconnect_chainsetup();
 
342
        
 
343
        /* 6.2 try to connect the edited chainsetup */
 
344
        select_chainsetup("cs-edit-temp");
 
345
        if (is_valid() == true) {
 
346
          connect_chainsetup();
 
347
          /* should succeed as is_valid() is true */
 
348
          DBC_CHECK(is_connected() == true);
 
349
          if (is_connected() == true) {
 
350
            if (restart == true) {
 
351
              DBC_CHECK(is_running() != true);
 
352
              start();
 
353
            }
345
354
          }
346
355
        }
347
 
      }
348
356
 
349
 
      /* 6.3 if connecting the modified chainsetup fails */
350
 
      if (is_connected() != true) {
351
 
        ECA_LOG_MSG(ECA_LOGGER::info, "Can't connect; edited chainsetup is not valid.");
352
 
      }
 
357
        /* 6.3 if connecting the modified chainsetup fails */
 
358
        if (is_connected() != true) {
 
359
          ECA_LOG_MSG(ECA_LOGGER::info, "Can't connect; edited chainsetup is not valid.");
 
360
        }
353
361
      
354
 
      /* 6.4 remove the old chainsetup */
355
 
      select_chainsetup(origname);
356
 
      remove_chainsetup();
357
 
      select_chainsetup("cs-edit-temp");
358
 
      selected_chainsetup_repp->set_name(origname);
 
362
        /* 6.4 remove the old chainsetup */
 
363
        select_chainsetup(origname);
 
364
        remove_chainsetup();
 
365
        select_chainsetup("cs-edit-temp");
 
366
        selected_chainsetup_repp->set_name(origname);
 
367
      }
359
368
    }
360
369
  }
361
370
}
1002
1011
 * require:
1003
1012
 *  is_selected() == true
1004
1013
 */
1005
 
const std::vector<string>& ECA_CONTROL_OBJECTS::selected_chains(void) const {
 
1014
const std::vector<string>& ECA_CONTROL_OBJECTS::selected_chains(void) const
 
1015
{
1006
1016
  // --------
1007
1017
  DBC_REQUIRE(is_selected() == true);
1008
1018
  // --------
1090
1100
  selected_chainsetup_repp->rename_chain(name);     
1091
1101
}
1092
1102
 
1093
 
void ECA_CONTROL_OBJECTS::send_chain_commands_to_engine(int command, double value) {
 
1103
void ECA_CONTROL_OBJECTS::send_chain_commands_to_engine(int command, double value)
 
1104
{
1094
1105
  // --------
1095
1106
  DBC_CHECK(is_engine_started() == true);
1096
1107
  // --------
1155
1166
  }
1156
1167
}
1157
1168
 
1158
 
void ECA_CONTROL_OBJECTS::audio_input_as_selected(void) {
 
1169
void ECA_CONTROL_OBJECTS::audio_input_as_selected(void)
 
1170
{
1159
1171
  /* note, here we check that the pointer is still a valid one */
1160
1172
  if (selected_chainsetup_repp->ok_audio_object(selected_audio_input_repp) != true)
1161
1173
    selected_audio_input_repp = 0;
1239
1251
                           format.interleaved_channels());
1240
1252
}
1241
1253
 
 
1254
static AUDIO_IO* priv_select_audio_object(const std::vector<AUDIO_IO*>& objects, const std::string& name)
 
1255
{
 
1256
  AUDIO_IO* result = 0;
 
1257
 
 
1258
  /* NOTE: ugly, but needed to maintain compability with older 2.4.x 
 
1259
   *       releases that allowed double-quoted filenames to ai/ao-select */
 
1260
  std::string stripped_name;
 
1261
  if (name.size() > 0 &&
 
1262
      name[0] == '"') {
 
1263
    stripped_name = name;
 
1264
    kvu_string_strip_outer_quotes(&stripped_name, '"');
 
1265
  }
 
1266
 
 
1267
  std::vector<AUDIO_IO*>::size_type p = 0;  
 
1268
  for(p = 0; p != objects.size(); p++) {
 
1269
    if (objects[p]->label() == name ||
 
1270
        objects[p]->label() == stripped_name) {
 
1271
      result = objects[p];
 
1272
      /* note: in case 'name' is not unique, the first matching
 
1273
       *       instance is selected */
 
1274
      break;
 
1275
    }
 
1276
  }
 
1277
 
 
1278
  return result;
 
1279
}
 
1280
 
1242
1281
/**
1243
1282
 * Selects an audio input
1244
1283
 *
1251
1290
  DBC_REQUIRE(is_selected() == true);
1252
1291
  // --------
1253
1292
 
1254
 
  selected_audio_input_repp = 0;
1255
 
  std::vector<AUDIO_IO*>::size_type p = 0;  
1256
 
  for(p = 0; p != selected_chainsetup_repp->inputs.size(); p++) {
1257
 
    if (selected_chainsetup_repp->inputs[p]->label() == name) {
1258
 
      selected_audio_input_repp = selected_chainsetup_repp->inputs[p];
1259
 
    }
1260
 
  }
 
1293
  selected_audio_input_repp = 
 
1294
    priv_select_audio_object(selected_chainsetup_repp->inputs, name);
1261
1295
}
1262
1296
 
1263
1297
/**
1266
1300
 * require:
1267
1301
 *  is_selected() == true
1268
1302
 */
1269
 
void ECA_CONTROL_OBJECTS::select_audio_output(const string& name) { 
 
1303
void ECA_CONTROL_OBJECTS::select_audio_output(const string& name)
 
1304
{
1270
1305
  // --------
1271
1306
  DBC_REQUIRE(is_selected() == true);
1272
1307
  // --------
1273
1308
 
1274
 
  selected_audio_output_repp = 0;
1275
 
  std::vector<AUDIO_IO*>::size_type p = 0;  
1276
 
  for(p = 0; p != selected_chainsetup_repp->outputs.size(); p++) {
1277
 
    if (selected_chainsetup_repp->outputs[p]->label() == name) {
1278
 
      selected_audio_output_repp = selected_chainsetup_repp->outputs[p];
1279
 
    }
1280
 
  }
 
1309
  selected_audio_output_repp = 
 
1310
    priv_select_audio_object(selected_chainsetup_repp->outputs, name);
1281
1311
}
1282
1312
 
1283
1313
/**