summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-10-12 17:39:07 +0000
committerWerner Schweer <ws.seh.de>2006-10-12 17:39:07 +0000
commit9e4632dce3f2798306a98ad53a49c736daddc130 (patch)
tree88df67a09e40836ed186e3b679bbb448ed221d9d
parent1146c82d56ffa68a4d13dddfe3dd373793865ef0 (diff)
updates
-rw-r--r--muse/muse/driver/jack.cpp134
-rw-r--r--muse/muse/seqmsg.cpp2
-rw-r--r--muse/muse/track.cpp6
3 files changed, 72 insertions, 70 deletions
diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp
index 733cd70d..5df57475 100644
--- a/muse/muse/driver/jack.cpp
+++ b/muse/muse/driver/jack.cpp
@@ -306,8 +306,16 @@ static int graph_callback(void*)
// by graph_callback()
//---------------------------------------------------------
+struct RouteRoute {
+ Route src;
+ Route dst;
+ };
+
void JackAudio::graphChanged()
{
+ QList<RouteRoute> rr;
+ QList<RouteRoute> ra;
+
InputList* il = song->inputs();
for (iAudioInput ii = il->begin(); ii != il->end(); ++ii) {
AudioInput* it = *ii;
@@ -318,38 +326,30 @@ void JackAudio::graphChanged()
continue;
const char** ports = jack_port_get_all_connections(_client, port);
RouteList* rl = it->inRoutes();
-
//---------------------------------------
// check for disconnects
//---------------------------------------
- bool erased;
- for (;;) {
- erased = false;
- for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
- if (irl->channel != channel)
- continue;
- const char* name = jack_port_name((jack_port_t*)irl->port);
- bool found = false;
- const char** pn = ports;
- while (pn && *pn) {
- if (strcmp(*pn, name) == 0) {
- found = true;
- break;
- }
- ++pn;
- }
- if (!found) {
- audio->msgRemoveRoute1(
- Route(irl->port, channel, Route::AUDIOPORT),
- Route(it, channel)
- );
- erased = true;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ if (irl->channel != channel)
+ continue;
+ Route r = *irl;
+ const char* name = jack_port_name((jack_port_t*)r.port);
+ bool found = false;
+ const char** pn = ports;
+ while (pn && *pn) {
+ if (strcmp(*pn, name) == 0) {
+ found = true;
break;
}
+ ++pn;
+ }
+ if (!found) {
+ RouteRoute a;
+ a.src = Route(irl->port, channel, Route::AUDIOPORT);
+ a.dst = Route(it, channel);
+ rr.append(a);
}
- if (!erased)
- break;
}
//---------------------------------------
@@ -357,33 +357,40 @@ void JackAudio::graphChanged()
//---------------------------------------
if (ports) {
- const char** pn = ports;
- while (*pn) {
+ for (const char** pn = ports; *pn; ++pn) {
bool found = false;
- Port port;
for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
if (irl->channel != channel)
continue;
- port = irl->port;
- const char* name = jack_port_name((jack_port_t*)port);
+ const char* name = jack_port_name((jack_port_t*)irl->port);
if (strcmp(*pn, name) == 0) {
found = true;
break;
}
}
if (!found) {
- audio->msgAddRoute1(
- Route(port, channel, Route::AUDIOPORT),
- Route(it, channel)
- );
+ RouteRoute a;
+ Port port = jack_port_by_name(_client, *pn);
+ a.src = Route(port, channel, Route::AUDIOPORT);
+ a.dst = Route(it, channel);
+ ra.append(a);
}
- ++pn;
}
- delete ports;
+ free(ports);
}
}
}
+
+ foreach(RouteRoute a, rr) {
+ audio->msgRemoveRoute1(a.src, a.dst);
+ }
+ foreach(RouteRoute a, ra) {
+ audio->msgAddRoute1(a.src, a.dst);
+ }
+ rr.clear();
+ ra.clear();
+
OutputList* ol = song->outputs();
for (iAudioOutput ii = ol->begin(); ii != ol->end(); ++ii) {
AudioOutput* it = *ii;
@@ -399,33 +406,25 @@ void JackAudio::graphChanged()
// check for disconnects
//---------------------------------------
- bool erased;
- for (;;) {
- erased = false;
- for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
- if (irl->channel != channel)
- continue;
- const char* name = jack_port_name((jack_port_t*)irl->port);
- bool found = false;
- const char** pn = ports;
- while (pn && *pn) {
- if (strcmp(*pn, name) == 0) {
- found = true;
- break;
- }
- ++pn;
- }
- if (!found) {
- audio->msgRemoveRoute1(
- Route(it, channel),
- Route(irl->port, channel, Route::AUDIOPORT)
- );
- erased = true;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ if (irl->channel != channel)
+ continue;
+ const char* name = jack_port_name((jack_port_t*)irl->port);
+ bool found = false;
+ const char** pn = ports;
+ while (pn && *pn) {
+ if (strcmp(*pn, name) == 0) {
+ found = true;
break;
}
+ ++pn;
+ }
+ if (!found) {
+ RouteRoute a;
+ a.src = Route(it, channel);
+ a.dst = Route(irl->port, channel, Route::AUDIOPORT);
+ rr.append(a);
}
- if (!erased)
- break;
}
//---------------------------------------
@@ -448,18 +447,21 @@ void JackAudio::graphChanged()
}
}
if (!found) {
- audio->msgAddRoute1(
- Route(it, channel),
- Route(port, channel, Route::AUDIOPORT)
- );
+ RouteRoute a;
+ a.src = Route(it, channel);
+ a.dst = Route(port, channel, Route::AUDIOPORT);
+ ra.append(a);
}
++pn;
}
-
- delete ports;
+ free(ports);
}
}
}
+ foreach(RouteRoute a, rr)
+ audio->msgRemoveRoute1(a.src, a.dst);
+ foreach(RouteRoute a, ra)
+ audio->msgAddRoute1(a.src, a.dst);
}
//static int xrun_callback(void*)
diff --git a/muse/muse/seqmsg.cpp b/muse/muse/seqmsg.cpp
index 7c427d15..356745d1 100644
--- a/muse/muse/seqmsg.cpp
+++ b/muse/muse/seqmsg.cpp
@@ -117,7 +117,6 @@ void Audio::msgAddRoute(Route src, Route dst)
msgAddRoute1(src, dst);
if (src.type == Route::AUDIOPORT) {
AudioInput* ai = (AudioInput*)dst.track;
-printf(" dst channel: %d\n", dst.channel);
audioDriver->connect(src.port, ai->jackPort(dst.channel));
}
if (src.type == Route::MIDIPORT) {
@@ -125,7 +124,6 @@ printf(" dst channel: %d\n", dst.channel);
}
else if (dst.type == Route::AUDIOPORT) {
AudioOutput* ao = (AudioOutput*)src.track;
-printf(" src channel: %d\n", src.channel);
audioDriver->connect(ao->jackPort(src.channel), dst.port);
}
else if (dst.type == Route::MIDIPORT) {
diff --git a/muse/muse/track.cpp b/muse/muse/track.cpp
index 67a5014f..4cc19ee3 100644
--- a/muse/muse/track.cpp
+++ b/muse/muse/track.cpp
@@ -681,9 +681,11 @@ void Track::writeRouting(Xml& xml) const
}
}
for (ciRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r) {
- Route dst((Track*)this);
+ Route src((Track*)this);
+ if (type() == AUDIO_OUTPUT)
+ src.channel = r->channel;
xml.tag("Route");
- dst.write(xml, "src");
+ src.write(xml, "src");
r->write(xml, "dst");
xml.etag("Route");
}