summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-10-23 10:33:08 +0000
committerWerner Schweer <ws.seh.de>2006-10-23 10:33:08 +0000
commit782da3b949f8f0f2c0016187a2c88e665a762d7a (patch)
tree6c8d1d7d6f15a35610b197a1555cba8dc7fc1e9f
parent7209944860501af4868f166f4cff59559bdb567e (diff)
routing fixes & cleanups
-rw-r--r--muse/muse/driver/alsamidi.cpp17
-rw-r--r--muse/muse/driver/jack.cpp35
-rw-r--r--muse/muse/mixer/astrip.cpp4
-rw-r--r--muse/muse/mixer/mstrip.cpp78
-rw-r--r--muse/muse/route.cpp22
-rw-r--r--muse/muse/route.h5
-rw-r--r--muse/muse/song.cpp42
-rw-r--r--muse/muse/track.cpp71
8 files changed, 159 insertions, 115 deletions
diff --git a/muse/muse/driver/alsamidi.cpp b/muse/muse/driver/alsamidi.cpp
index e982d03a..810ace1e 100644
--- a/muse/muse/driver/alsamidi.cpp
+++ b/muse/muse/driver/alsamidi.cpp
@@ -406,12 +406,10 @@ void AlsaMidi::removeConnection(snd_seq_connect_t* ev)
Port dst = iport->alsaPort();
if (equal(dst, rd)) {
- RouteList* irl = iport->inRoutes();
- for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
- Port src = ir->port;
-
- if (equal(src, rs)) {
- irl->erase(ir);
+ RouteList* irl = iport->outRoutes();
+ for (iRoute r = irl->begin(); r != irl->end(); ++r) {
+ if (!r->disconnected && equal(r->port, rs)) {
+ iport->inRoutes()->erase(r);
break;
}
}
@@ -427,11 +425,8 @@ void AlsaMidi::removeConnection(snd_seq_connect_t* ev)
if (equal(src, rs)) {
RouteList* orl = oport->outRoutes();
for (iRoute r = orl->begin(); r != orl->end(); ++r) {
- Port dst = r->port;
-
- if (equal(dst, rd)) {
+ if (!r->disconnected && equal(r->port, rd)) {
orl->erase(r);
-printf("REMOVE OUT connection\n");
break;
}
}
@@ -678,12 +673,10 @@ bool AlsaMidi::putEvent(snd_seq_event_t* event)
error = snd_seq_event_output_direct(alsaSeq, event);
int len = snd_seq_event_length(event);
if (error == len) {
-// printf(".");fflush(stdout);
return false;
}
if (error < 0) {
if (error == -12) {
-// printf("?");fflush(stdout);
return true;
}
else {
diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp
index 014bd20b..2bccbfcf 100644
--- a/muse/muse/driver/jack.cpp
+++ b/muse/muse/driver/jack.cpp
@@ -275,21 +275,16 @@ struct RouteRoute {
void JackAudio::graphChanged()
{
- // under construction
- return;
-
QList<RouteRoute> rr;
QList<RouteRoute> ra;
-printf("graphChanged\n");
+// printf("graphChanged\n");
InputList* il = song->inputs();
for (iAudioInput ii = il->begin(); ii != il->end(); ++ii) {
AudioInput* it = *ii;
int channels = it->channels();
RouteList* irl = it->inRoutes();
-printf(" inRoutes %d\n", irl->size());
-
for (int channel = 0; channel < channels; ++channel) {
jack_port_t* port = (jack_port_t*)(it->jackPort(channel));
if (port == 0)
@@ -301,15 +296,12 @@ printf(" inRoutes %d\n", irl->size());
//---------------------------------------
foreach (Route r, *irl) {
-printf(" channel %d %d\n", r.channel, channel);
if (r.channel != channel)
continue;
const char* name = jack_port_name((jack_port_t*)r.port);
-printf(" port name <%s>\n", name);
bool found = false;
for (const char** pn = ports; pn && *pn; ++pn) {
if (strcmp(*pn, name) == 0) {
-printf(" compare <%s><%s>\n", *pn, name);
found = true;
break;
}
@@ -352,7 +344,7 @@ printf(" compare <%s><%s>\n", *pn, name);
}
}
-printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
+// printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
foreach(RouteRoute a, rr) {
audio->msgRemoveRoute1(a.src, a.dst);
}
@@ -377,10 +369,10 @@ printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
// check for disconnects
//---------------------------------------
- for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
- if (irl->channel != channel)
+ foreach(Route r, *rl) {
+ if (r.channel != channel)
continue;
- const char* name = jack_port_name((jack_port_t*)irl->port);
+ const char* name = jack_port_name((jack_port_t*)r.port);
bool found = false;
const char** pn = ports;
while (pn && *pn) {
@@ -393,7 +385,7 @@ printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
if (!found) {
RouteRoute a;
a.src = Route(it, channel);
- a.dst = Route(irl->port, channel, Route::AUDIOPORT);
+ a.dst = Route(r.port, channel, Route::AUDIOPORT);
rr.append(a);
}
}
@@ -406,12 +398,10 @@ printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
const char** pn = ports;
while (*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;
@@ -420,6 +410,7 @@ printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
if (!found) {
RouteRoute a;
a.src = Route(it, channel);
+ Port port = jack_port_by_name(_client, *pn);
a.dst = Route(port, channel, Route::AUDIOPORT);
ra.append(a);
}
@@ -429,7 +420,7 @@ printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
}
}
}
-printf(" input: remove %d add %d routes\n", rr.size(), ra.size());
+// printf(" output: remove %d add %d routes\n", rr.size(), ra.size());
foreach(RouteRoute a, rr)
audio->msgRemoveRoute1(a.src, a.dst);
foreach(RouteRoute a, ra)
@@ -653,9 +644,11 @@ QString JackAudio::portName(void* port)
void JackAudio::unregisterPort(Port p)
{
- //printf("JACK: unregister Port %p\n", p);
- if (_client)
- jack_port_unregister(_client, (jack_port_t*)p);
+ if (_client) {
+// printf("JACK: unregister Port %p\n", p);
+ if (jack_port_unregister(_client, (jack_port_t*)p))
+ fprintf(stderr, "jack unregister port %p failed\n", p);
+ }
}
//---------------------------------------------------------
diff --git a/muse/muse/mixer/astrip.cpp b/muse/muse/mixer/astrip.cpp
index 754861f1..263467b6 100644
--- a/muse/muse/mixer/astrip.cpp
+++ b/muse/muse/mixer/astrip.cpp
@@ -722,6 +722,8 @@ void AudioStrip::iRoutePressed()
addMidiInPorts(t, &pup, irl);
break;
}
+ if (pup.isEmpty())
+ return;
QAction* n = pup.exec(QCursor::pos());
if (n != 0) {
Route srcRoute = n->data().value<Route>();
@@ -785,6 +787,8 @@ void AudioStrip::oRoutePressed()
addGroupPorts(t, &pup, orl);
break;
}
+ if (pup.isEmpty())
+ return;
QAction* n = pup.exec(QCursor::pos());
if (n != 0) {
QString s(n->text());
diff --git a/muse/muse/mixer/mstrip.cpp b/muse/muse/mixer/mstrip.cpp
index 9173509f..23b873c2 100644
--- a/muse/muse/mixer/mstrip.cpp
+++ b/muse/muse/mixer/mstrip.cpp
@@ -350,8 +350,9 @@ void MidiChannelStrip::autoWriteToggled(bool val)
void MidiChannelStrip::iRoutePressed()
{
- QMenu* pup = new QMenu(iR);
- pup->addSeparator()->setText(tr("Tracks"));
+ QMenu pup(iR);
+ pup.setSeparatorsCollapsible(false);
+ pup.addSeparator()->setText(tr("Tracks"));
MidiChannel* t = (MidiChannel*)track;
RouteList* irl = t->inRoutes();
@@ -360,7 +361,7 @@ void MidiChannelStrip::iRoutePressed()
int tn = 0;
for (iMidiTrack i = tl->begin();i != tl->end(); ++i, ++tn) {
MidiTrack* track = *i;
- QAction* action = pup->addAction(track->name());
+ QAction* action = pup.addAction(track->name());
action->setCheckable(true);
Route src(track, -1, Route::TRACK);
action->setData(QVariant::fromValue(src));
@@ -371,7 +372,9 @@ void MidiChannelStrip::iRoutePressed()
}
}
}
- QAction* n = pup->exec(QCursor::pos());
+ if (pup.isEmpty())
+ return;
+ QAction* n = pup.exec(QCursor::pos());
if (n) {
Route srcRoute = n->data().value<Route>();
Route dstRoute(track, -1, Route::TRACK);
@@ -382,7 +385,6 @@ void MidiChannelStrip::iRoutePressed()
audio->msgRemoveRoute(srcRoute, dstRoute);
song->update(SC_ROUTE);
}
- delete pup;
iR->setDown(false); // pup->exec() catches mouse release event
}
@@ -540,15 +542,17 @@ void MidiStrip::recordToggled(bool val)
void MidiStrip::iRoutePressed()
{
- QMenu* pup = new QMenu(oR);
- pup->addSeparator()->setText(tr("Input Ports"));
+ QMenu pup(oR);
+ pup.setSeparatorsCollapsible(false);
+ pup.addSeparator()->setText(tr("Input Ports"));
+
MidiOutPort* t = (MidiOutPort*)track;
RouteList* irl = t->inRoutes();
MidiInPortList* ipl = song->midiInPorts();
int tn = 0;
for (iMidiInPort i = ipl->begin(); i != ipl->end(); ++i, ++tn) {
- QMenu* m = pup->addMenu((*i)->name());
+ QMenu* m = pup.addMenu((*i)->name());
m->addSeparator()->setText(tr("Channel"));
QAction* all_action = m->addAction(tr("All"));
QMap<QString, QVariant> map;
@@ -576,8 +580,9 @@ void MidiStrip::iRoutePressed()
}
}
}
-
- QAction* n = pup->exec(QCursor::pos());
+ if (pup.isEmpty())
+ return;
+ QAction* n = pup.exec(QCursor::pos());
if (n) {
QMap<QString, QVariant> data = n->data().toMap();
int trackid = data["id"].toInt();
@@ -604,7 +609,6 @@ void MidiStrip::iRoutePressed()
}
song->update(SC_ROUTE);
}
- delete pup;
iR->setDown(false); // pup->exec() catches mouse release event
}
@@ -641,6 +645,8 @@ void MidiStrip::oRoutePressed()
}
}
}
+ if (pup.isEmpty())
+ return;
QAction* n = pup.exec(QCursor::pos());
if (n) {
Route srcRoute(track, -1, Route::TRACK);
@@ -900,13 +906,14 @@ void MidiOutPortStrip::controllerChanged(int id)
void MidiOutPortStrip::oRoutePressed()
{
- QMenu* pup = new QMenu(oR);
- pup->addSeparator()->setText(tr("MidiDevices"));
+ QMenu pup(oR);
+ pup.setSeparatorsCollapsible(false);
+ pup.addSeparator()->setText(tr("MidiDevices"));
RouteList* orl = track->outRoutes();
QList<PortName> ol = midiDriver->outputPorts(true);
foreach (PortName ip, ol) {
- QAction* oa = pup->addAction(ip.name);
+ QAction* oa = pup.addAction(ip.name);
oa->setCheckable(true);
Route dst(ip.port, Route::MIDIPORT);
oa->setData(QVariant::fromValue(dst));
@@ -925,7 +932,7 @@ void MidiOutPortStrip::oRoutePressed()
SynthIList* sl = song->syntis();
for (iSynthI i = sl->begin(); i != sl->end(); ++i) {
SynthI* track = *i;
- QAction* oa = pup->addAction(track->name());
+ QAction* oa = pup.addAction(track->name());
oa->setCheckable(true);
Route dst(track, -1, Route::SYNTIPORT);
oa->setData(QVariant::fromValue(dst));
@@ -943,7 +950,7 @@ void MidiOutPortStrip::oRoutePressed()
//
ol = audioDriver->inputPorts(true);
foreach (PortName ip, ol) {
- QAction* oa = pup->addAction(ip.name);
+ QAction* oa = pup.addAction(ip.name);
oa->setCheckable(true);
Route dst(ip.port, Route::JACKMIDIPORT);
oa->setData(QVariant::fromValue(dst));
@@ -955,8 +962,9 @@ void MidiOutPortStrip::oRoutePressed()
}
}
}
-
- QAction* action = pup->exec(QCursor::pos());
+ if (pup.isEmpty())
+ return;
+ QAction* action = pup.exec(QCursor::pos());
if (action) {
Route dstRoute = action->data().value<Route>();
Route srcRoute(track);
@@ -967,7 +975,6 @@ void MidiOutPortStrip::oRoutePressed()
audio->msgRemoveRoute(srcRoute, dstRoute);
song->update(SC_ROUTE);
}
- delete pup;
oR->setDown(false); // pup->exec() catches mouse release event
}
@@ -1121,8 +1128,9 @@ void MidiInPortStrip::soloToggled(bool val)
void MidiInPortStrip::oRoutePressed()
{
- QMenu* pup = new QMenu(tr("Channel"), oR);
- pup->addSeparator()->setText(tr("Channel"));
+ QMenu pup(oR);
+ pup.setSeparatorsCollapsible(false);
+ pup.addSeparator()->setText(tr("Channel"));
MidiTrackList* tl = song->midis();
MidiSyntiList* sl = song->midiSyntis();
@@ -1131,7 +1139,7 @@ void MidiInPortStrip::oRoutePressed()
int sn = 0;
for (iSynthI i = asl->begin(); i != asl->end(); ++i,++sn) {
- QAction* action = pup->addAction((*i)->name());
+ QAction* action = pup.addAction((*i)->name());
QMap<QString, QVariant> data;
data["id"] = QVariant(0x20000 + sn);
@@ -1150,7 +1158,7 @@ void MidiInPortStrip::oRoutePressed()
}
}
for (int channel = 0; channel < MIDI_CHANNELS; ++channel) {
- QMenu* m = pup->addMenu(QString(tr("Channel %1")).arg(channel + 1));
+ QMenu* m = pup.addMenu(QString(tr("Channel %1")).arg(channel + 1));
m->addSeparator()->setText(tr("Tracks"));
//
@@ -1201,8 +1209,9 @@ void MidiInPortStrip::oRoutePressed()
}
}
}
-
- QAction* action = pup->exec(QCursor::pos());
+ if (pup.isEmpty())
+ return;
+ QAction* action = pup.exec(QCursor::pos());
if (action) {
int n = action->data().toMap()["id"].toInt();
int was_checked = action->data().toMap()["was_checked"].toInt();
@@ -1233,7 +1242,6 @@ void MidiInPortStrip::oRoutePressed()
audio->msgAddRoute(srcRoute, dstRoute);
song->update(SC_ROUTE);
}
- delete pup;
oR->setDown(false); // pup->exec() catches mouse release event
}
@@ -1243,14 +1251,15 @@ void MidiInPortStrip::oRoutePressed()
void MidiInPortStrip::iRoutePressed()
{
- QMenu* pup = new QMenu(oR);
- pup->addSeparator()->setText(tr("AlsaDevices"));
+ QMenu pup(oR);
+ pup.setSeparatorsCollapsible(false);
+ pup.addSeparator()->setText(tr("AlsaDevices"));
RouteList* irl = track->inRoutes();
QList<PortName> ol = midiDriver->inputPorts(false);
foreach (PortName ip, ol) {
- QAction* action = pup->addAction(ip.name);
+ QAction* action = pup.addAction(ip.name);
action->setCheckable(true);
Route src(ip.port, Route::MIDIPORT);
action->setData(QVariant::fromValue(src));
@@ -1266,7 +1275,7 @@ void MidiInPortStrip::iRoutePressed()
//
ol = audioDriver->outputPorts(true);
foreach (PortName ip, ol) {
- QAction* action = pup->addAction(ip.name);
+ QAction* action = pup.addAction(ip.name);
action->setCheckable(true);
Route src(ip.port, Route::JACKMIDIPORT);
action->setData(QVariant::fromValue(src));
@@ -1278,7 +1287,9 @@ void MidiInPortStrip::iRoutePressed()
}
}
}
- QAction* action = pup->exec(QCursor::pos());
+ if (pup.isEmpty())
+ return;
+ QAction* action = pup.exec(QCursor::pos());
if (action) {
Route srcRoute = action->data().value<Route>();
Route dstRoute(track, -1, Route::TRACK);
@@ -1299,7 +1310,6 @@ void MidiInPortStrip::iRoutePressed()
}
song->update(SC_ROUTE);
}
- delete pup;
iR->setDown(false); // pup->exec() catches mouse release event
}
@@ -1565,6 +1575,8 @@ void MidiSyntiStrip::oRoutePressed()
}
}
}
+ if (pup.isEmpty())
+ return;
QAction* action = pup.exec(QCursor::pos());
if (action) {
Route dstRoute = action->data().value<Route>();
@@ -1632,6 +1644,8 @@ void MidiSyntiStrip::iRoutePressed()
}
}
+ if (pup.isEmpty())
+ return;
QAction* action = pup.exec(QCursor::pos());
if (action) {
Route srcRoute = action->data().value<Route>();
diff --git a/muse/muse/route.cpp b/muse/muse/route.cpp
index 1589b480..22b6b3f1 100644
--- a/muse/muse/route.cpp
+++ b/muse/muse/route.cpp
@@ -33,11 +33,20 @@
// Route
//---------------------------------------------------------
+Route::Route()
+ {
+ track = 0;
+ channel = -1;
+ type = TRACK;
+ disconnected = false;
+ }
+
Route::Route(Port p, int ch, RouteType t)
{
port = p;
channel = ch;
type = t;
+ disconnected = false;
}
Route::Route(Port p, RouteType t)
@@ -45,6 +54,7 @@ Route::Route(Port p, RouteType t)
port = p;
channel = -1;
type = t;
+ disconnected = false;
}
Route::Route(Track* tr)
@@ -52,6 +62,7 @@ Route::Route(Track* tr)
track = tr;
channel = -1;
type = TRACK;
+ disconnected = false;
}
Route::Route(AuxPluginIF* p)
@@ -59,6 +70,7 @@ Route::Route(AuxPluginIF* p)
plugin = p;
channel = -1;
type = AUXPLUGIN;
+ disconnected = false;
}
Route::Route(Track* tr, int ch, RouteType t)
@@ -66,13 +78,7 @@ Route::Route(Track* tr, int ch, RouteType t)
track = tr;
channel = ch;
type = t;
- }
-
-Route::Route()
- {
- track = 0;
- channel = -1;
- type = TRACK;
+ disconnected = false;
}
//---------------------------------------------------------
@@ -280,6 +286,8 @@ void Song::readRoute(QDomNode n)
d.channel = s.channel;
if (s.type == Route::TRACK && s.track->type() == Track::MIDI_IN)
d.channel = s.channel;
+ s.disconnected = true;
+ d.disconnected = true;
addRoute(s, d);
}
diff --git a/muse/muse/route.h b/muse/muse/route.h
index 54b574bc..5d17c5c0 100644
--- a/muse/muse/route.h
+++ b/muse/muse/route.h
@@ -66,7 +66,10 @@ struct Route {
Port port;
AuxPluginIF* plugin;
};
- int channel; // route to/from JACK can specify a channel to connect to
+ int channel; // route to/from JACK can specify a channel to connect to
+ bool disconnected; // if true, do not remove route in graphChanged()
+ // or removeConnection()
+
RouteType type;
Route();
diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp
index d3bde0e3..429019f0 100644
--- a/muse/muse/song.cpp
+++ b/muse/muse/song.cpp
@@ -1705,34 +1705,33 @@ void Song::insertTrack2(Track* track)
if (track->type() == Track::AUDIO_SOFTSYNTH)
src.type = Route::SYNTIPORT;
if (track->type() == Track::AUDIO_OUTPUT || track->type() == Track::MIDI_OUT) {
- const RouteList* rl = track->inRoutes();
- for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
- src.channel = r->channel;
- r->track->outRoutes()->push_back(src);
+ foreach(Route r, *(track->inRoutes())) {
+ if (r.type != Route::AUXPLUGIN) {
+ src.channel = r.channel;
+ r.track->outRoutes()->push_back(src);
+ }
}
}
else if (track->type() == Track::AUDIO_INPUT || track->type() == Track::MIDI_IN) {
- const RouteList* rl = track->outRoutes();
- for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
- src.channel = r->channel;
- r->track->inRoutes()->push_back(src);
+ foreach(Route r, *(track->outRoutes())) {
+ if (r.type != Route::AUXPLUGIN) {
+ src.channel = r.channel;
+ r.track->inRoutes()->push_back(src);
+ }
}
}
else {
- const RouteList* rl = track->inRoutes();
- for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
- Route rt = *r;
- src.channel = rt.channel;
- if (rt.type == Route::AUXPLUGIN)
- continue;
- rt.track->outRoutes()->push_back(src);
+ foreach(Route r, *(track->inRoutes())) {
+ if (r.type != Route::AUXPLUGIN) {
+ src.channel = r.channel;
+ r.track->outRoutes()->push_back(src);
+ }
}
- rl = track->outRoutes();
- for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
- src.channel = r->channel;
- if (r->type == Route::AUXPLUGIN)
- continue;
- r->track->inRoutes()->push_back(src);
+ foreach(Route r, *(track->outRoutes())) {
+ if (r.type != Route::AUXPLUGIN) {
+ src.channel = r.channel;
+ r.track->inRoutes()->push_back(src);
+ }
}
}
}
@@ -1760,7 +1759,6 @@ void Song::removeTrack(Track* track)
void Song::removeTrack1(Track* track)
{
-// if (track->type() != Track::MIDI_OUT && track->type() != Track::MIDI_IN)
track->deactivate();
_tracks.erase(track);
}
diff --git a/muse/muse/track.cpp b/muse/muse/track.cpp
index 7a55cd8d..bcb3ff3c 100644
--- a/muse/muse/track.cpp
+++ b/muse/muse/track.cpp
@@ -970,7 +970,8 @@ void Track::resetAllMeter()
}
//---------------------------------------------------------
-// activate
+// activate1
+// register JACK and ALSA ports
//---------------------------------------------------------
void Track::activate1()
@@ -990,6 +991,7 @@ void Track::activate1()
}
return;
}
+
for (int i = 0; i < channels(); ++i) {
if (jackPort(i))
printf("Track::activate1(): already active!\n");
@@ -1005,7 +1007,7 @@ void Track::activate1()
//---------------------------------------------------------
// activate2
-// connect all in/out routes
+// connect all JACK/ALSA in/out routes
// connect to JACK only works if JACK is running
//---------------------------------------------------------
@@ -1015,55 +1017,84 @@ void Track::activate2()
printf("Track::activate2(): no audio running !\n");
abort();
}
- foreach(Route r, _outRoutes) {
- if (r.type == Route::JACKMIDIPORT)
+ for (iRoute ri = _outRoutes.begin(); ri != _outRoutes.end(); ++ri) {
+ Route& r = *ri;
+ if (r.type == Route::JACKMIDIPORT) {
audioDriver->connect(_jackPort[0], r.port);
- else if (r.type == Route::MIDIPORT)
+ r.disconnected = false;
+ }
+ else if (r.type == Route::AUDIOPORT) {
+ audioDriver->connect(_jackPort[r.channel], r.port);
+ r.disconnected = false;
+ }
+ else if (r.type == Route::MIDIPORT) {
midiDriver->connect(_alsaPort[0], r.port);
+ r.disconnected = false;
+ }
}
- foreach(Route r, _inRoutes) {
- if (r.type == Route::JACKMIDIPORT)
+ for (iRoute ri = _inRoutes.begin(); ri != _inRoutes.end(); ++ri) {
+ Route& r = *ri;
+ if (r.type == Route::JACKMIDIPORT) {
audioDriver->connect(r.port, _jackPort[0]);
- else if (r.type == Route::MIDIPORT)
+ r.disconnected = false;
+ }
+ else if (r.type == Route::AUDIOPORT) {
+ audioDriver->connect(r.port, _jackPort[r.channel]);
+ r.disconnected = false;
+ }
+ else if (r.type == Route::MIDIPORT) {
midiDriver->connect(r.port, _alsaPort[0]);
+ r.disconnected = false;
+ }
}
}
//---------------------------------------------------------
// deactivate
+// disconnect and unregister JACK and ALSA ports
//---------------------------------------------------------
void Track::deactivate()
{
- foreach (Route r, _outRoutes) {
- if (r.type == Route::JACKMIDIPORT)
+ for (iRoute ri = _outRoutes.begin(); ri != _outRoutes.end(); ++ri) {
+ Route& r = *ri;
+ if (r.type == Route::JACKMIDIPORT) {
+ r.disconnected = true;
audioDriver->disconnect(_jackPort[0], r.port);
- else if (r.type == Route::AUDIOPORT)
+ }
+ else if (r.type == Route::AUDIOPORT) {
audioDriver->disconnect(_jackPort[r.channel], r.port);
- else if (r.type == Route::MIDIPORT)
+ r.disconnected = true;
+ }
+ else if (r.type == Route::MIDIPORT) {
+ r.disconnected = true;
midiDriver->disconnect(_alsaPort[0], r.port);
+ }
}
- foreach (Route r, _inRoutes) {
- if (r.type == Route::JACKMIDIPORT)
+ for (iRoute ri = _inRoutes.begin(); ri != _inRoutes.end(); ++ri) {
+ Route& r = *ri;
+ if (r.type == Route::JACKMIDIPORT) {
+ r.disconnected = true;
audioDriver->disconnect(r.port, _jackPort[0]);
- else if (r.type == Route::AUDIOPORT)
+ }
+ else if (r.type == Route::AUDIOPORT) {
+ r.disconnected = true;
audioDriver->disconnect(r.port, _jackPort[r.channel]);
- else if (r.type == Route::MIDIPORT)
+ }
+ else if (r.type == Route::MIDIPORT) {
+ r.disconnected = true;
midiDriver->disconnect(r.port, _alsaPort[0]);
+ }
}
for (int i = 0; i < channels(); ++i) {
if (_jackPort[i]) {
audioDriver->unregisterPort(_jackPort[i]);
_jackPort[i] = 0;
}
- else
- printf("Track::deactivate(): jack port not active!\n");
if (_alsaPort[i]) {
midiDriver->unregisterPort(_alsaPort[i]);
_alsaPort[i] = 0;
}
- else
- printf("Track::deactivate(): alsa port not active!\n");
}
}