Logo Search packages:      
Sourcecode: ecasound version File versions  Download package

void ECA_CONTROL::check_action_preconditions ( int  action_id ) [private]

Checks action preconditions.

Returns:
Sets status of private data members 'action_ok', 'action_restart', and 'action_reconnect'.

Definition at line 302 of file eca-control.cpp.

References connect_chainsetup(), connected_chainsetup(), disconnect_chainsetup(), get_audio_input(), get_audio_output(), is_connected(), is_running(), is_selected(), is_valid(), and selected_chainsetup().

{
  action_ok = true;
  action_reconnect = false;
  action_restart = false;

  /* case 1: action requiring arguments, but not arguments available */
  if (action_arg_f_set_rep == false && 
      first_action_argument_as_string().size() == 0 &&
      action_requires_params(action_id)) {
    set_last_error("Can't perform requested action; argument omitted.");
    action_ok = false;
  }
  /* case 2: action requires an audio input, but no input available */
  else if (is_selected() == true &&
         get_audio_input() == 0 &&
         action_requires_selected_audio_input(action_id)) {
    set_last_error("Can't perform requested action; no audio input selected.");
    action_ok = false;
  }
  /* case 3: action requires an audio output, but no output available */
  else if (is_selected() == true &&
         get_audio_output() == 0 &&
         action_requires_selected_audio_output(action_id)) {
    set_last_error("Can't perform requested action; no audio output selected.");
    action_ok = false;
  }
  /* case 4: action requires a select chainsetup, but none selected */
  else if (is_selected() == false &&
         action_requires_selected(action_id)) {
    if (!is_connected()) {
      set_last_error("Can't perform requested action; no chainsetup selected.");
      action_ok = false;
    }
    else {
      ECA_LOG_MSG(ECA_LOGGER::info, "WARNING: No chainsetup selected. Connected chainsetup will be selected.");
      select_chainsetup(connected_chainsetup());
    }
  }
  /* case 5: action requires a connected chainsetup, but none connected */
  else if (is_connected() == false &&
         action_requires_connected(action_id)) {
    if (!is_selected()) {
      set_last_error("Can't perform requested action; no chainsetup connected.");
      action_ok = false;
    }
    else {
      if (is_valid() == true) {
      ECA_LOG_MSG(ECA_LOGGER::info, 
                "NOTE: No chainsetup connected. Trying to connect currently selected chainsetup \""
                + selected_chainsetup_repp->name() 
                + "\"");
      connect_chainsetup(0);
      }
      if (is_connected() != true) {
      /* connect_chainsetup() sets last_error() so we just add to it */
      set_last_error(last_error() + " Selected chainsetup cannot be connected. Can't perform requested action. ");
      action_ok = false;
      }
    }
  }
  /* case 6: action can't be performed on a connected setup, 
   *         but selected chainsetup is also connected */
  else if (selected_chainsetup() == connected_chainsetup() &&
         action_requires_selected_not_connected(action_id)) {
    ECA_LOG_MSG(ECA_LOGGER::info, "WARNING: This operation requires that chainsetup is disconnected. Temporarily disconnecting...");
    if (is_running()) action_restart = true;
    disconnect_chainsetup();
    action_reconnect = true;
  }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index