diff options
author | Florian Jung <flo@windfisch.org> | 2011-12-21 17:39:57 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-12-21 17:39:57 +0000 |
commit | 1057d7190242cdf9248671b316a398db805f5f56 (patch) | |
tree | ab50268a7db2f80cfb45a7ad6578fe735ab84ce5 /muse2/muse/driver | |
parent | 9977c7114089b8708d310268833b83343caa0fd1 (diff) | |
parent | c36a5508aa42e596b005425208054af9a60734b4 (diff) |
merged with trunk (that is, pulled the fixes from release_2_0)
only quickly tested, seems okay on the first glance
Diffstat (limited to 'muse2/muse/driver')
-rw-r--r-- | muse2/muse/driver/alsamidi.cpp | 273 | ||||
-rw-r--r-- | muse2/muse/driver/jack.cpp | 164 | ||||
-rw-r--r-- | muse2/muse/driver/jackaudio.h | 1 | ||||
-rw-r--r-- | muse2/muse/driver/jackmidi.cpp | 18 |
4 files changed, 348 insertions, 108 deletions
diff --git a/muse2/muse/driver/alsamidi.cpp b/muse2/muse/driver/alsamidi.cpp index eae695db..4687f17f 100644 --- a/muse2/muse/driver/alsamidi.cpp +++ b/muse2/muse/driver/alsamidi.cpp @@ -39,6 +39,8 @@ #include "part.h" #include "gconfig.h" +#include <QApplication> + namespace MusECore { static int alsaSeqFdi = -1; @@ -46,6 +48,7 @@ static int alsaSeqFdo = -1; snd_seq_t* alsaSeq = 0; static snd_seq_addr_t musePort; +static snd_seq_addr_t announce_adr; //--------------------------------------------------------- // MidiAlsaDevice @@ -83,42 +86,55 @@ QString MidiAlsaDevice::open() QString estr; int wer = 0; int rer = 0; + + snd_seq_port_info_t *pinfo; + snd_seq_port_info_alloca(&pinfo); + //snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); + snd_seq_port_info_set_addr(pinfo, &adr); + + int cap = snd_seq_port_info_get_capability(pinfo); // subscribe for writing if (_openFlags & 1) { - snd_seq_port_subscribe_set_sender(subs, &musePort); - snd_seq_port_subscribe_set_dest(subs, &adr); - // Not already subscribed (or error)? Then try subscribing. - if(snd_seq_get_port_subscription(alsaSeq, subs) < 0) - { - //int error = snd_seq_subscribe_port(alsaSeq, subs); - wer = snd_seq_subscribe_port(alsaSeq, subs); - //if (error < 0) - if(wer < 0) - //return QString("Play: ")+QString(snd_strerror(error)); - estr += (QString("Play: ") + QString(snd_strerror(wer)) + QString(" ")); - } - if(!wer) + if(cap & SND_SEQ_PORT_CAP_SUBS_WRITE) + { + snd_seq_port_subscribe_set_sender(subs, &musePort); + snd_seq_port_subscribe_set_dest(subs, &adr); + // Not already subscribed (or error)? Then try subscribing. + if(snd_seq_get_port_subscription(alsaSeq, subs) < 0) + { + //int error = snd_seq_subscribe_port(alsaSeq, subs); + wer = snd_seq_subscribe_port(alsaSeq, subs); + //if (error < 0) + if(wer < 0) + //return QString("Play: ")+QString(snd_strerror(error)); + estr += (QString("Play: ") + QString(snd_strerror(wer)) + QString(" ")); + } + } + if(!wer && (cap & SND_SEQ_PORT_CAP_WRITE)) _writeEnable = true; } // subscribe for reading if (_openFlags & 2) { - snd_seq_port_subscribe_set_dest(subs, &musePort); - snd_seq_port_subscribe_set_sender(subs, &adr); - // Not already subscribed (or error)? Then try subscribing. - if(snd_seq_get_port_subscription(alsaSeq, subs) < 0) - { - //int error = snd_seq_subscribe_port(alsaSeq, subs); - rer = snd_seq_subscribe_port(alsaSeq, subs); - //if (error < 0) - if(rer < 0) - //return QString("Rec: ") + QString(snd_strerror(error)); - estr += (QString("Rec: ") + QString(snd_strerror(rer))); - } - if(!rer) + if(cap & SND_SEQ_PORT_CAP_SUBS_READ) + { + snd_seq_port_subscribe_set_dest(subs, &musePort); + snd_seq_port_subscribe_set_sender(subs, &adr); + // Not already subscribed (or error)? Then try subscribing. + if(snd_seq_get_port_subscription(alsaSeq, subs) < 0) + { + //int error = snd_seq_subscribe_port(alsaSeq, subs); + rer = snd_seq_subscribe_port(alsaSeq, subs); + //if (error < 0) + if(rer < 0) + //return QString("Rec: ") + QString(snd_strerror(error)); + estr += (QString("Rec: ") + QString(snd_strerror(rer))); + } + } + if(!rer && (cap & SND_SEQ_PORT_CAP_READ)) _readEnable = true; } @@ -139,6 +155,16 @@ void MidiAlsaDevice::close() // Allocated on stack, no need to call snd_seq_port_subscribe_free() later. snd_seq_port_subscribe_alloca(&subs); + int wer = 0; + int rer = 0; + + snd_seq_port_info_t *pinfo; + snd_seq_port_info_alloca(&pinfo); + //snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); + snd_seq_port_info_set_addr(pinfo, &adr); + + int cap = snd_seq_port_info_get_capability(pinfo); + // This function appears to be called only by MidiPort::setMidiDevice(), // which closes then opens the device. // Because the open flags are set BEFORE setMidiDevice() is called, we must ignore the flags. @@ -158,37 +184,49 @@ void MidiAlsaDevice::close() //if (_openFlags & 1) { //if (!(_openFlags & 1)) { - snd_seq_port_subscribe_set_sender(subs, &musePort); - snd_seq_port_subscribe_set_dest(subs, &adr); - - // Already subscribed? Then unsubscribe. - if(!snd_seq_get_port_subscription(alsaSeq, subs)) - { - if(!snd_seq_unsubscribe_port(alsaSeq, subs)) - _writeEnable = false; - else - printf("MidiAlsaDevice::close Error unsubscribing alsa midi port for writing\n"); + if(cap & SND_SEQ_PORT_CAP_SUBS_WRITE) + { + snd_seq_port_subscribe_set_sender(subs, &musePort); + snd_seq_port_subscribe_set_dest(subs, &adr); + + // Already subscribed? Then unsubscribe. + if(!snd_seq_get_port_subscription(alsaSeq, subs)) + { + wer = snd_seq_unsubscribe_port(alsaSeq, subs); + //if(!wer) + // _writeEnable = false; + //else + if(wer < 0) + printf("MidiAlsaDevice::close Error unsubscribing alsa midi port %d:%d for writing: %s\n", adr.client, adr.port, snd_strerror(wer)); + } + //else + //_writeEnable = false; } - else - _writeEnable = false; + _writeEnable = false; } //if (_openFlags & 2) { //if (!(_openFlags & 2)) { - snd_seq_port_subscribe_set_dest(subs, &musePort); - snd_seq_port_subscribe_set_sender(subs, &adr); - - // Already subscribed? Then unsubscribe. - if(!snd_seq_get_port_subscription(alsaSeq, subs)) - { - if(!snd_seq_unsubscribe_port(alsaSeq, subs)) - _readEnable = false; - else - printf("MidiAlsaDevice::close Error unsubscribing alsa midi port for reading\n"); - } - else - _readEnable = false; + if(cap & SND_SEQ_PORT_CAP_SUBS_READ) + { + snd_seq_port_subscribe_set_dest(subs, &musePort); + snd_seq_port_subscribe_set_sender(subs, &adr); + + // Already subscribed? Then unsubscribe. + if(!snd_seq_get_port_subscription(alsaSeq, subs)) + { + rer = snd_seq_unsubscribe_port(alsaSeq, subs); + //if(!rer) + // _readEnable = false; + //else + if(rer < 0) + printf("MidiAlsaDevice::close Error unsubscribing alsa midi port %d:%d for reading: %s\n", adr.client, adr.port, snd_strerror(rer)); + } + //else + // _readEnable = false; + } + _readEnable = false; } } @@ -208,18 +246,18 @@ void MidiAlsaDevice::writeRouting(int level, Xml& xml) const { if(!r->name().isEmpty()) { - s = QT_TRANSLATE_NOOP("@default", "Route"); + s = "Route"; if(r->channel != -1) - s += QString(QT_TRANSLATE_NOOP("@default", " channel=\"%1\"")).arg(r->channel); + s += QString(" channel=\"%1\"").arg(r->channel); xml.tag(level++, s.toLatin1().constData()); xml.tag(level, "source devtype=\"%d\" name=\"%s\"/", MidiDevice::ALSA_MIDI, Xml::xmlString(name()).toLatin1().constData()); - s = QT_TRANSLATE_NOOP("@default", "dest"); + s = "dest"; if(r->type == Route::MIDI_DEVICE_ROUTE) - s += QString(QT_TRANSLATE_NOOP("@default", " devtype=\"%1\"")).arg(r->device->deviceType()); + s += QString(" devtype=\"%1\"").arg(r->device->deviceType()); else if(r->type != Route::TRACK_ROUTE) - s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type); - s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name())); + s += QString(" type=\"%1\"").arg(r->type); + s += QString(" name=\"%1\"/").arg(Xml::xmlString(r->name())); xml.tag(level, s.toLatin1().constData()); xml.etag(level--, "Route"); @@ -696,6 +734,13 @@ bool initMidiAlsa() snd_seq_client_info_set_client(cinfo, -1); while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { + const char* cname = snd_seq_client_info_get_name(cinfo); + //printf( "ALSA client name: %s\n", cname); + + // Put Midi Through and user clients after others. Insert other unwanted clients here: // p4.0.41 + if(snd_seq_client_info_get_type(cinfo) == SND_SEQ_USER_CLIENT || strcmp("Midi Through", cname) == 0) + continue; + snd_seq_port_info_t *pinfo; snd_seq_port_info_alloca(&pinfo); snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); @@ -703,6 +748,8 @@ bool initMidiAlsa() while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { unsigned int capability = snd_seq_port_info_get_capability(pinfo); + if (capability & SND_SEQ_PORT_CAP_NO_EXPORT) // Ignore ports like "qjackctl" or "port". p4.0.41 + continue; if ((capability & outCap) == 0) { const char *name = snd_seq_port_info_get_name(pinfo); if (strcmp("Timer", name) == 0 || @@ -724,29 +771,52 @@ bool initMidiAlsa() adr.client, adr.port, flags, capability); MusEGlobal::midiDevices.add(dev); - - /* - // Experimental... Need to list 'sensible' devices first and ignore unwanted ones... - // Add instance last in midi device list. - for(int i = 0; i < MIDI_PORTS; ++i) - { - MidiPort* mp = &MusEGlobal::midiPorts[i]; - if(mp->device() == 0) - { - // midiSeq might not be initialzed yet! - //MusEGlobal::midiSeq->msgSetMidiDevice(mp, dev); - mp->setMidiDevice(dev); - - //muse->changeConfig(true); // save configuration file - //update(); - break; - } } - */ - + } + + snd_seq_client_info_set_client(cinfo, -1); // Reset + while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { + const char* cname = snd_seq_client_info_get_name(cinfo); + //printf( "ALSA client name: %s\n", cname); + + // Put Midi Through and user clients after others. Insert other unwanted clients here: // p4.0.41 + if( !(snd_seq_client_info_get_type(cinfo) == SND_SEQ_USER_CLIENT || strcmp("Midi Through", cname) == 0) ) + continue; + + snd_seq_port_info_t *pinfo; + snd_seq_port_info_alloca(&pinfo); + snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); + snd_seq_port_info_set_port(pinfo, -1); + + while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { + unsigned int capability = snd_seq_port_info_get_capability(pinfo); + if (capability & SND_SEQ_PORT_CAP_NO_EXPORT) // Ignore ports like "qjackctl" or "port". p4.0.41 + continue; + if ((capability & outCap) == 0) { + const char *name = snd_seq_port_info_get_name(pinfo); + if (strcmp("Timer", name) == 0 || + strcmp("Announce", name) == 0 || + strcmp("Receiver", name) == 0) + continue; + } + snd_seq_addr_t adr = *snd_seq_port_info_get_addr(pinfo); + MidiAlsaDevice* dev = new MidiAlsaDevice(adr, QString(snd_seq_port_info_get_name(pinfo))); + int flags = 0; + if (capability & outCap) + flags |= 1; + if (capability & inCap) + flags |= 2; + dev->setrwFlags(flags); + if (MusEGlobal::debugMsg) + printf("ALSA port add: <%s>, %d:%d flags %d 0x%0x\n", + snd_seq_port_info_get_name(pinfo), + adr.client, adr.port, + flags, capability); + MusEGlobal::midiDevices.add(dev); } } - + + //snd_seq_set_client_name(alsaSeq, "MusE Sequencer"); snd_seq_set_client_name(alsaSeq, MusEGlobal::audioDevice->clientName()); @@ -781,14 +851,14 @@ bool initMidiAlsa() // alsa port changes //----------------------------------------- - snd_seq_addr_t aadr; - aadr.client = SND_SEQ_CLIENT_SYSTEM; - aadr.port = SND_SEQ_PORT_SYSTEM_ANNOUNCE; + //snd_seq_addr_t aadr; + announce_adr.client = SND_SEQ_CLIENT_SYSTEM; + announce_adr.port = SND_SEQ_PORT_SYSTEM_ANNOUNCE; snd_seq_port_subscribe_t* subs; snd_seq_port_subscribe_alloca(&subs); snd_seq_port_subscribe_set_dest(subs, &musePort); - snd_seq_port_subscribe_set_sender(subs, &aadr); + snd_seq_port_subscribe_set_sender(subs, &announce_adr); error = snd_seq_subscribe_port(alsaSeq, subs); if (error < 0) { printf("Alsa: Subscribe System failed: %s", snd_strerror(error)); @@ -805,12 +875,35 @@ bool initMidiAlsa() void exitMidiAlsa() { if(alsaSeq) - { - int error = snd_seq_close(alsaSeq); // FIXME Hm, this did not get rid of a buch of valgrind leaks. - if(error < 0) + { + int error = 0; + snd_seq_port_subscribe_t* subs; + // Allocated on stack, no need to call snd_seq_port_subscribe_free() later. + snd_seq_port_subscribe_alloca(&subs); + + snd_seq_port_info_t *pinfo; + snd_seq_port_info_alloca(&pinfo); + //snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); + snd_seq_port_info_set_addr(pinfo, &announce_adr); + + snd_seq_port_subscribe_set_dest(subs, &musePort); + snd_seq_port_subscribe_set_sender(subs, &announce_adr); + + // Already subscribed? Then unsubscribe. + if(!snd_seq_get_port_subscription(alsaSeq, subs)) { - fprintf(stderr, "Could not close ALSA sequencer: %s\n", snd_strerror(error)); - } + error = snd_seq_unsubscribe_port(alsaSeq, subs); + if(error < 0) + printf("MusE: exitMidiAlsa: Error unsubscribing alsa midi Announce port %d:%d for reading: %s\n", announce_adr.client, announce_adr.port, snd_strerror(error)); + } + + error = snd_seq_delete_simple_port(alsaSeq, musePort.port); + if(error < 0) + fprintf(stderr, "MusE: Could not delete ALSA simple port: %s\n", snd_strerror(error)); + + error = snd_seq_close(alsaSeq); + if(error < 0) + fprintf(stderr, "MusE: Could not close ALSA sequencer: %s\n", snd_strerror(error)); } } @@ -850,7 +943,9 @@ void alsaScanMidiPorts() snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); snd_seq_port_info_set_port(pinfo, -1); while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { - unsigned int capability = snd_seq_port_info_get_capability(pinfo); + unsigned int capability = snd_seq_port_info_get_capability(pinfo); + if (capability & SND_SEQ_PORT_CAP_NO_EXPORT) // Ignore ports like "qjackctl" or "port". p4.0.41 + continue; if (((capability & outCap) == 0) && ((capability & inCap) == 0)) continue; @@ -900,6 +995,8 @@ void alsaScanMidiPorts() // // check for devices to add // + // TODO: Possibly auto-add them to available midi ports. p4.0.41 + // for (std::list<AlsaPort>::iterator k = portList.begin(); k != portList.end(); ++k) { iMidiDevice i = MusEGlobal::midiDevices.begin(); // printf("ALSA port: <%s>\n", k->name); @@ -920,6 +1017,8 @@ void alsaScanMidiPorts() // printf("add device\n"); } } + + } //--------------------------------------------------------- diff --git a/muse2/muse/driver/jack.cpp b/muse2/muse/driver/jack.cpp index 733353d8..421152a7 100644 --- a/muse2/muse/driver/jack.cpp +++ b/muse2/muse/driver/jack.cpp @@ -735,7 +735,11 @@ void JackAudioDevice::connectJackMidiPorts() { RouteList* rl = md->outRoutes(); for (ciRoute r = rl->begin(); r != rl->end(); ++r) + { + if(r->type != Route::JACK_ROUTE) + continue; connect(port, r->jackPort); + } } } @@ -748,7 +752,11 @@ void JackAudioDevice::connectJackMidiPorts() { RouteList* rl = md->inRoutes(); for (ciRoute r = rl->begin(); r != rl->end(); ++r) + { + if(r->type != Route::JACK_ROUTE) + continue; connect(r->jackPort, port); + } } } } @@ -939,6 +947,8 @@ void JackAudioDevice::graphChanged() for (int i = 0;i < 20;i++) { erased = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; if (irl->channel != channel) continue; QString name = irl->name(); @@ -977,6 +987,8 @@ void JackAudioDevice::graphChanged() while (*pn) { bool found = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; if (irl->channel != channel) continue; QString name = irl->name(); @@ -1027,6 +1039,8 @@ void JackAudioDevice::graphChanged() for (int i = 0; i < 20 ; i++) { erased = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; if (irl->channel != channel) continue; QString name = irl->name(); @@ -1064,6 +1078,8 @@ void JackAudioDevice::graphChanged() while (*pn) { bool found = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; if (irl->channel != channel) continue; QString name = irl->name(); @@ -1139,6 +1155,8 @@ void JackAudioDevice::graphChanged() { erased = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; //if (irl->channel != channel) // continue; QString name = irl->name(); @@ -1181,6 +1199,8 @@ void JackAudioDevice::graphChanged() while (*pn) { bool found = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; //if (irl->channel != channel) // continue; QString name = irl->name(); @@ -1239,6 +1259,8 @@ void JackAudioDevice::graphChanged() { erased = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; //if (irl->channel != channel) // continue; QString name = irl->name(); @@ -1280,6 +1302,8 @@ void JackAudioDevice::graphChanged() while (*pn) { bool found = false; for (ciRoute irl = rl->begin(); irl != rl->end(); ++irl) { + if(irl->type != Route::JACK_ROUTE) + continue; //if (irl->channel != channel) // continue; QString name = irl->name(); @@ -1482,6 +1506,8 @@ void JackAudioDevice::start(int /*priority*/) RouteList* rl = ai->inRoutes(); void* port = ai->jackPort(ch); for (ciRoute ir = rl->begin(); ir != rl->end(); ++ir) { + if(ir->type != Route::JACK_ROUTE) + continue; if (ir->channel == ch) connect(ir->jackPort, port); } @@ -1495,6 +1521,8 @@ void JackAudioDevice::start(int /*priority*/) RouteList* rl = ai->outRoutes(); void* port = ai->jackPort(ch); for (ciRoute r = rl->begin(); r != rl->end(); ++r) { + if(r->type != Route::JACK_ROUTE) + continue; if (r->channel == ch) { connect(port, r->jackPort); } @@ -1603,6 +1631,107 @@ int JackAudioDevice::frameDelay() const #endif //--------------------------------------------------------- +// getJackPorts +//--------------------------------------------------------- + +void JackAudioDevice::getJackPorts(const char** ports, std::list<QString>& name_list, bool midi, bool physical, int aliases) + { + if (JACK_DEBUG) + printf("JackAudioDevice::getJackPorts()\n"); + //std::list<QString> clientList; + //if(!checkJackClient(_client)) return clientList; + //if(!checkJackClient(_client)) return; + QString qname; + //const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE; + //const char** ports = jack_get_ports(_client, 0, type, JackPortIsInput); + //const char** ports = jack_get_ports(_client, 0, type, jflags); + + QString cname(jack_get_client_name(_client)); + + for (const char** p = ports; p && *p; ++p) { + jack_port_t* port = jack_port_by_name(_client, *p); + //int flags = jack_port_flags(port); + //if (!(flags & JackPortIsInput)) + // continue; + //char buffer[128]; + + int port_flags = jack_port_flags(port); + //printf("JackAudioDevice::getJackPorts port: %s flags: %d\n", *p, port_flags); + + // Ignore our own client ports. + if(jack_port_is_mine(_client, port)) + { + if(MusEGlobal::debugMsg) + printf("JackAudioDevice::getJackPorts ignoring own port: %s\n", *p); + continue; + } + + int nsz = jack_port_name_size(); + char buffer[nsz]; + + bool mthrough = false; + + if(midi) + { + strncpy(buffer, *p, nsz); + char a2[nsz]; + char* al[2]; + al[0] = buffer; + al[1] = a2; + int na = jack_port_get_aliases(port, al); + if(na >= 1) + { + qname = QString(al[0]); + //printf("Checking port name for: %s\n", (QString("alsa_pcm:") + cname + QString("/")).toLatin1().constData()); + // Ignore our own ALSA client! + if(qname.startsWith(QString("alsa_pcm:") + cname + QString("/"))) + continue; + // Put Midi Through after all others. + mthrough = qname.startsWith(QString("alsa_pcm:Midi-Through/")); + //if((physical && mthrough) || (!physical && !mthrough)) + //if(physical && mthrough) + // continue; + } + } + // Put physical/terminal ports before others. + bool is_phys = (port_flags & (JackPortIsTerminal | JackPortIsPhysical)) && !mthrough; + if((physical && !is_phys) || (!physical && is_phys)) + continue; + + + strncpy(buffer, *p, nsz); + if((aliases == 0) || (aliases == 1)) + { + char a2[nsz]; + char* al[2]; + al[0] = buffer; + al[1] = a2; + int na = jack_port_get_aliases(port, al); + int a = aliases; + if(a >= na) + { + a = na; + if(a > 0) + a--; + } + qname = QString(al[a]); + } + else + qname = QString(buffer); + + //clientList.push_back(QString(buffer)); + name_list.push_back(qname); + } + + // p3.3.37 + //if(ports) + //free(ports); + // jack_free(ports); // p4.0.29 + + //return clientList; + } + +//--------------------------------------------------------- // outputPorts //--------------------------------------------------------- @@ -1612,9 +1741,11 @@ std::list<QString> JackAudioDevice::outputPorts(bool midi, int aliases) printf("JackAudioDevice::outputPorts()\n"); std::list<QString> clientList; if(!checkJackClient(_client)) return clientList; - QString qname; const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE; const char** ports = jack_get_ports(_client, 0, type, JackPortIsOutput); + + /* + QString qname; for (const char** p = ports; p && *p; ++p) { jack_port_t* port = jack_port_by_name(_client, *p); //int flags = jack_port_flags(port); @@ -1666,12 +1797,15 @@ std::list<QString> JackAudioDevice::outputPorts(bool midi, int aliases) //clientList.push_back(QString(buffer)); clientList.push_back(qname); } - - // p3.3.37 - if(ports) - //free(ports); - jack_free(ports); // p4.0.29 + */ + if(ports) + { + getJackPorts(ports, clientList, midi, true, aliases); // Get physical ports first. + getJackPorts(ports, clientList, midi, false, aliases); // Get non-physical ports last. + jack_free(ports); + } + return clientList; } @@ -1683,11 +1817,14 @@ std::list<QString> JackAudioDevice::inputPorts(bool midi, int aliases) { if (JACK_DEBUG) printf("JackAudioDevice::inputPorts()\n"); + std::list<QString> clientList; if(!checkJackClient(_client)) return clientList; - QString qname; const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE; const char** ports = jack_get_ports(_client, 0, type, JackPortIsInput); + + /* + QString qname; for (const char** p = ports; p && *p; ++p) { jack_port_t* port = jack_port_by_name(_client, *p); //int flags = jack_port_flags(port); @@ -1739,12 +1876,15 @@ std::list<QString> JackAudioDevice::inputPorts(bool midi, int aliases) //clientList.push_back(QString(buffer)); clientList.push_back(qname); } - - // p3.3.37 - if(ports) - //free(ports); - jack_free(ports); // p4.0.29 + */ + if(ports) + { + getJackPorts(ports, clientList, midi, true, aliases); // Get physical ports first. + getJackPorts(ports, clientList, midi, false, aliases); // Get non-physical ports last. + jack_free(ports); + } + return clientList; } diff --git a/muse2/muse/driver/jackaudio.h b/muse2/muse/driver/jackaudio.h index bd78d481..c4d37db9 100644 --- a/muse2/muse/driver/jackaudio.h +++ b/muse2/muse/driver/jackaudio.h @@ -50,6 +50,7 @@ class JackAudioDevice : public AudioDevice { // Free-running frame counter incremented always in process. jack_nframes_t _frameCounter; + void getJackPorts(const char** ports, std::list<QString>& name_list, bool midi, bool physical, int aliases); static int processAudio(jack_nframes_t frames, void*); public: diff --git a/muse2/muse/driver/jackmidi.cpp b/muse2/muse/driver/jackmidi.cpp index fa23d336..7a12b92d 100644 --- a/muse2/muse/driver/jackmidi.cpp +++ b/muse2/muse/driver/jackmidi.cpp @@ -276,10 +276,10 @@ void MidiJackDevice::writeRouting(int level, Xml& xml) const if(!r->name().isEmpty()) { xml.tag(level++, "Route"); - s = QT_TRANSLATE_NOOP("@default", "source"); + s = "source"; if(r->type != Route::TRACK_ROUTE) - s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type); - s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name())); + s += QString(" type=\"%1\"").arg(r->type); + s += QString(" name=\"%1\"/").arg(Xml::xmlString(r->name())); xml.tag(level, s.toLatin1().constData()); xml.tag(level, "dest devtype=\"%d\" name=\"%s\"/", MidiDevice::JACK_MIDI, Xml::xmlString(name()).toLatin1().constData()); xml.etag(level--, "Route"); @@ -291,18 +291,18 @@ void MidiJackDevice::writeRouting(int level, Xml& xml) const { if(!r->name().isEmpty()) { - s = QT_TRANSLATE_NOOP("@default", "Route"); + s = "Route"; if(r->channel != -1) - s += QString(QT_TRANSLATE_NOOP("@default", " channel=\"%1\"")).arg(r->channel); + s += QString(" channel=\"%1\"").arg(r->channel); xml.tag(level++, s.toLatin1().constData()); xml.tag(level, "source devtype=\"%d\" name=\"%s\"/", MidiDevice::JACK_MIDI, Xml::xmlString(name()).toLatin1().constData()); - s = QT_TRANSLATE_NOOP("@default", "dest"); + s = "dest"; if(r->type == Route::MIDI_DEVICE_ROUTE) - s += QString(QT_TRANSLATE_NOOP("@default", " devtype=\"%1\"")).arg(r->device->deviceType()); + s += QString(" devtype=\"%1\"").arg(r->device->deviceType()); else if(r->type != Route::TRACK_ROUTE) - s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type); - s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name())); + s += QString(" type=\"%1\"").arg(r->type); + s += QString(" name=\"%1\"/").arg(Xml::xmlString(r->name())); xml.tag(level, s.toLatin1().constData()); |