Beispiel #1
0
void
clear_outs(GtkWidget * widget, gpointer * data) {

	const char ** ports;
	int i = 0;
	int res;

	ports = jack_port_get_connections(out_L_port);
	if (ports) {
		while (ports[i] != NULL) {
			if ((res = jack_disconnect(jack_client, jack_port_name(out_L_port), ports[i])) != 0) {
				fprintf(stderr, "ERROR: jack_disconnect() returned %d\n", res);
			}
			i++;
		}
		free(ports);
	}
	i = 0;
	ports = jack_port_get_connections(out_R_port);
	if (ports) {
		while (ports[i] != NULL) {
			if ((res = jack_disconnect(jack_client, jack_port_name(out_R_port), ports[i])) != 0) {
				fprintf(stderr, "ERROR: jack_disconnect() returned %d\n", res);
			}
			i++;
		}
		free(ports);
	}
	gtk_list_store_clear(store_out_L);
	gtk_list_store_clear(store_out_R);
}
Beispiel #2
0
static jack_port_t *
update_connection(jack_port_t *remote_port, int connected,
                  jack_port_t *local_port, jack_port_t *current_port,
                  const char *target_name)
{
    if (connected) {
        if (current_port) {
            return current_port;
        }
        if (target_name) {
            char *aliases[2];
            if (! strcmp(target_name, jack_port_name(remote_port))) {
                return remote_port;
            }
            aliases[0] = alias1;
            aliases[1] = alias2;
            switch (jack_port_get_aliases(remote_port, aliases)) {
            case -1:
                /* Sigh ... */
                die("jack_port_get_aliases", "Failed to get port aliases");
            case 2:
                if (! strcmp(target_name, alias2)) {
                    return remote_port;
                }
                /* Fallthrough on purpose */
            case 1:
                if (! strcmp(target_name, alias1)) {
                    return remote_port;
                }
                /* Fallthrough on purpose */
            case 0:
                return NULL;
            }
            /* This shouldn't happen. */
            assert(0);
        }
        return remote_port;
    }
    if (! strcmp(jack_port_name(remote_port), jack_port_name(current_port))) {
        const char **port_names;
        if (target_name) {
            return NULL;
        }
        port_names = jack_port_get_connections(local_port);
        if (port_names == NULL) {
            return NULL;
        }

        /* If a connected port is disconnected and other ports are still
           connected, then we take the first port name in the array and use it
           as our remote port.  It's a dumb implementation. */
        current_port = jack_port_by_name(client, port_names[0]);
        jack_free(port_names);
        if (current_port == NULL) {
            /* Sigh */
            die("jack_port_by_name", "failed to get port by name");
        }
    }
    return current_port;
}
Beispiel #3
0
bool JackAudio::stop()
      {
      if (preferences.useJackMidi && preferences.rememberLastMidiConnections) {
            QSettings settings;
            //settings.setValue("midiPorts", midiOutputPorts.size());
            int port = 0;
            foreach(jack_port_t* mp, midiOutputPorts) {
                  const char** cc = jack_port_get_connections(mp);
                  const char** c = cc;
                  int idx = 0;
                  while (c) {
                        const char* p = *c++;
                        if (p == 0)
                              break;
                        settings.setValue(QString("midi-%1-%2").arg(port).arg(idx), p);
                        ++idx;
                        }
                  settings.setValue(QString("midi-%1-connections").arg(port), idx);
                  free((void*)cc);
                  ++port;
                  }
            // We don't use it now
            //settings.setValue("midiInputPorts", midiInputPorts.size());
            port = 0;
            foreach(jack_port_t* mp, midiInputPorts) {
                  const char** cc = jack_port_get_connections(mp);
                  const char** c = cc;
                  int idx = 0;
                  while (c) {
                        const char* p = *c++;
                        if (p == 0)
                              break;
                        settings.setValue(QString("midiin-%1-%2").arg(idx).arg(port), p);
                        ++idx;
                        }
                  settings.setValue(QString("midiin-%1-connections").arg(port), idx);
                  free((void*)cc);
                  ++port;
                  }
            }
Beispiel #4
0
void
scan_connections(jack_port_t * port, GtkListStore * store) {

	GtkTreeIter iter;
	const char ** ports;
	int i = 0;

	ports = jack_port_get_connections(port);

	if (!ports)
		return;
	
	while (ports[i] != NULL) {
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter, 0, ports[i], -1);
		i++;
	}
	free(ports);
}