|
|
ce871cf |
--- MuseScore-3.6.2/audio/drivers/alsa.cpp.orig 2021-02-08 05:16:37.000000000 -0700
|
|
|
ce871cf |
+++ MuseScore-3.6.2/audio/drivers/alsa.cpp 2022-11-30 10:08:06.384582516 -0700
|
|
|
ce871cf |
@@ -615,7 +615,10 @@ int AlsaAudio::sampleRate() const
|
|
|
ce871cf |
AlsaAudio::~AlsaAudio()
|
|
|
ce871cf |
{
|
|
|
ce871cf |
stop();
|
|
|
ce871cf |
- delete alsa;
|
|
|
ce871cf |
+ if (alsa != nullptr)
|
|
|
ce871cf |
+ delete alsa;
|
|
|
ce871cf |
+ if (midiDriver != nullptr)
|
|
|
ce871cf |
+ delete midiDriver;
|
|
|
ce871cf |
}
|
|
|
ce871cf |
|
|
|
ce871cf |
//---------------------------------------------------------
|
|
|
ce871cf |
--- MuseScore-3.6.2/audio/drivers/alsamidi.h.orig 2021-02-08 05:16:37.000000000 -0700
|
|
|
ce871cf |
+++ MuseScore-3.6.2/audio/drivers/alsamidi.h 2022-11-29 15:52:51.398045780 -0700
|
|
|
ce871cf |
@@ -39,15 +39,17 @@ struct PortName {
|
|
|
ce871cf |
|
|
|
ce871cf |
class AlsaMidiDriver : public MidiDriver {
|
|
|
ce871cf |
snd_seq_t* alsaSeq;
|
|
|
ce871cf |
+ QList<QSocketNotifier*> notifiers;
|
|
|
ce871cf |
|
|
|
ce871cf |
bool putEvent(snd_seq_event_t* event);
|
|
|
ce871cf |
QList<PortName> outputPorts();
|
|
|
ce871cf |
QList<PortName> inputPorts();
|
|
|
ce871cf |
bool connect(Port src, Port dst);
|
|
|
ce871cf |
+ bool disconnect(Port src, Port dst);
|
|
|
ce871cf |
|
|
|
ce871cf |
public:
|
|
|
ce871cf |
AlsaMidiDriver(Seq* s);
|
|
|
ce871cf |
- virtual ~AlsaMidiDriver() {}
|
|
|
ce871cf |
+ virtual ~AlsaMidiDriver();
|
|
|
ce871cf |
virtual bool init();
|
|
|
ce871cf |
virtual Port registerOutPort(const QString& name);
|
|
|
ce871cf |
virtual Port registerInPort(const QString& name);
|
|
|
ce871cf |
--- MuseScore-3.6.2/audio/drivers/mididriver.cpp.orig 2021-02-08 05:16:37.000000000 -0700
|
|
|
ce871cf |
+++ MuseScore-3.6.2/audio/drivers/mididriver.cpp 2022-11-29 16:32:47.008159978 -0700
|
|
|
ce871cf |
@@ -116,6 +116,25 @@ AlsaMidiDriver::AlsaMidiDriver(Seq* s)
|
|
|
ce871cf |
{
|
|
|
ce871cf |
}
|
|
|
ce871cf |
|
|
|
ce871cf |
+AlsaMidiDriver::~AlsaMidiDriver()
|
|
|
ce871cf |
+ {
|
|
|
ce871cf |
+ // disconnect all midi sources from mscore
|
|
|
ce871cf |
+ QList<PortName> il = inputPorts();
|
|
|
ce871cf |
+ foreach(PortName pn, il) {
|
|
|
ce871cf |
+ if (MScore::debugMode)
|
|
|
ce871cf |
+ qDebug("connect to midi input <%s>", qPrintable(pn.name));
|
|
|
ce871cf |
+ disconnect(pn.port, midiInPort);
|
|
|
ce871cf |
+ }
|
|
|
ce871cf |
+
|
|
|
ce871cf |
+ // deallocate the notifiers
|
|
|
ce871cf |
+ foreach(QSocketNotifier *s, notifiers) {
|
|
|
ce871cf |
+ delete s;
|
|
|
ce871cf |
+ }
|
|
|
ce871cf |
+
|
|
|
ce871cf |
+ // Close the ALSA sequencer
|
|
|
ce871cf |
+ snd_seq_close(alsaSeq);
|
|
|
ce871cf |
+ }
|
|
|
ce871cf |
+
|
|
|
ce871cf |
//---------------------------------------------------------
|
|
|
ce871cf |
// init
|
|
|
ce871cf |
// return false on error
|
|
|
ce871cf |
@@ -173,6 +192,7 @@ bool AlsaMidiDriver::init()
|
|
|
ce871cf |
if (fd != -1) {
|
|
|
ce871cf |
QSocketNotifier* s = new QSocketNotifier(fd, QSocketNotifier::Read, mscore);
|
|
|
ce871cf |
s->connect(s, SIGNAL(activated(int)), seq, SLOT(midiInputReady()));
|
|
|
ce871cf |
+ notifiers.append(s);
|
|
|
ce871cf |
}
|
|
|
ce871cf |
}
|
|
|
ce871cf |
#if 0
|
|
|
ce871cf |
@@ -286,6 +306,35 @@ bool AlsaMidiDriver::connect(Port src, P
|
|
|
ce871cf |
src.alsaClient(), src.alsaPort(),
|
|
|
ce871cf |
dst.alsaClient(), dst.alsaPort(),
|
|
|
ce871cf |
snd_strerror(rv));
|
|
|
ce871cf |
+ return false;
|
|
|
ce871cf |
+ }
|
|
|
ce871cf |
+ return true;
|
|
|
ce871cf |
+ }
|
|
|
ce871cf |
+
|
|
|
ce871cf |
+//---------------------------------------------------------
|
|
|
ce871cf |
+// disconnect
|
|
|
ce871cf |
+// return false if disconnect fails
|
|
|
ce871cf |
+//---------------------------------------------------------
|
|
|
ce871cf |
+
|
|
|
ce871cf |
+bool AlsaMidiDriver::disconnect(Port src, Port dst)
|
|
|
ce871cf |
+ {
|
|
|
ce871cf |
+ snd_seq_port_subscribe_t* sub;
|
|
|
ce871cf |
+ snd_seq_port_subscribe_alloca(&sub);
|
|
|
ce871cf |
+
|
|
|
ce871cf |
+ snd_seq_addr_t s, d;
|
|
|
ce871cf |
+ s.port = src.alsaPort();
|
|
|
ce871cf |
+ s.client = src.alsaClient();
|
|
|
ce871cf |
+ d.port = dst.alsaPort();
|
|
|
ce871cf |
+ d.client = dst.alsaClient();
|
|
|
ce871cf |
+ snd_seq_port_subscribe_set_sender(sub, &s);
|
|
|
ce871cf |
+ snd_seq_port_subscribe_set_dest(sub, &d);
|
|
|
ce871cf |
+
|
|
|
ce871cf |
+ int rv = snd_seq_unsubscribe_port(alsaSeq, sub);
|
|
|
ce871cf |
+ if (rv < 0) {
|
|
|
ce871cf |
+ qDebug("AlsaMidi::disconnect(%d:%d, %d:%d) failed: %s",
|
|
|
ce871cf |
+ src.alsaClient(), src.alsaPort(),
|
|
|
ce871cf |
+ dst.alsaClient(), dst.alsaPort(),
|
|
|
ce871cf |
+ snd_strerror(rv));
|
|
|
ce871cf |
return false;
|
|
|
ce871cf |
}
|
|
|
ce871cf |
return true;
|
|
|
ce871cf |
--- MuseScore-3.6.2/audio/drivers/pm.cpp.orig 2021-02-08 05:16:37.000000000 -0700
|
|
|
ce871cf |
+++ MuseScore-3.6.2/audio/drivers/pm.cpp 2022-11-30 10:15:47.520402385 -0700
|
|
|
ce871cf |
@@ -55,6 +55,9 @@ PortMidiDriver::~PortMidiDriver()
|
|
|
ce871cf |
Pt_Stop();
|
|
|
ce871cf |
Pm_Close(inputStream);
|
|
|
ce871cf |
}
|
|
|
ce871cf |
+ if (outputStream) {
|
|
|
ce871cf |
+ Pm_Close(outputStream);
|
|
|
ce871cf |
+ }
|
|
|
ce871cf |
}
|
|
|
ce871cf |
|
|
|
ce871cf |
//---------------------------------------------------------
|
|
|
ce871cf |
--- MuseScore-3.6.2/audio/drivers/pulseaudio.cpp.orig 2021-02-08 05:16:37.000000000 -0700
|
|
|
ce871cf |
+++ MuseScore-3.6.2/audio/drivers/pulseaudio.cpp 2022-11-30 10:21:39.688303296 -0700
|
|
|
ce871cf |
@@ -33,6 +33,8 @@ class PulseAudio : public Driver {
|
|
|
ce871cf |
int _sampleRate;
|
|
|
ce871cf |
pa_sample_spec ss;
|
|
|
ce871cf |
pa_mainloop* pa_ml;
|
|
|
ce871cf |
+ pa_context* pa_ctx;
|
|
|
ce871cf |
+ pa_stream *playstream;
|
|
|
ce871cf |
pa_buffer_attr bufattr;
|
|
|
ce871cf |
float buffer[FRAMES * 2];
|
|
|
ce871cf |
pthread_t thread;
|
|
|
ce871cf |
@@ -87,6 +89,10 @@ PulseAudio::PulseAudio(Seq* s)
|
|
|
ce871cf |
PulseAudio::~PulseAudio()
|
|
|
ce871cf |
{
|
|
|
ce871cf |
stop();
|
|
|
ce871cf |
+ pa_stream_unref(playstream);
|
|
|
ce871cf |
+ pa_context_disconnect(pa_ctx);
|
|
|
ce871cf |
+ pa_context_unref(pa_ctx);
|
|
|
ce871cf |
+ pa_mainloop_free(pa_ml);
|
|
|
ce871cf |
}
|
|
|
ce871cf |
|
|
|
ce871cf |
//---------------------------------------------------------
|
|
|
ce871cf |
@@ -123,7 +129,7 @@ bool PulseAudio::init(bool)
|
|
|
ce871cf |
{
|
|
|
ce871cf |
pa_ml = pa_mainloop_new();
|
|
|
ce871cf |
pa_mainloop_api* pa_mlapi = pa_mainloop_get_api(pa_ml);
|
|
|
ce871cf |
- pa_context* pa_ctx = pa_context_new(pa_mlapi, "MuseScore");
|
|
|
ce871cf |
+ pa_ctx = pa_context_new(pa_mlapi, "MuseScore");
|
|
|
ce871cf |
if (pa_context_connect(pa_ctx, NULL, pa_context_flags_t(0), NULL) != 0) {
|
|
|
ce871cf |
qDebug("PulseAudio Context Connect Failed with Error: %s", pa_strerror(pa_context_errno(pa_ctx)));
|
|
|
ce871cf |
return false;
|
|
|
ce871cf |
@@ -141,7 +147,7 @@ bool PulseAudio::init(bool)
|
|
|
ce871cf |
ss.channels = 2;
|
|
|
ce871cf |
ss.format = PA_SAMPLE_FLOAT32LE;
|
|
|
ce871cf |
|
|
|
ce871cf |
- pa_stream* playstream = pa_stream_new(pa_ctx, "Playback", &ss, NULL);
|
|
|
ce871cf |
+ playstream = pa_stream_new(pa_ctx, "Playback", &ss, NULL);
|
|
|
ce871cf |
if (!playstream) {
|
|
|
ce871cf |
qDebug("pa_stream_new failed: %s", pa_strerror(pa_context_errno(pa_ctx)));
|
|
|
ce871cf |
return false;
|
|
|
ce871cf |
--- MuseScore-3.6.2/mscore/seq.h.orig 2021-02-08 05:16:37.000000000 -0700
|
|
|
ce871cf |
+++ MuseScore-3.6.2/mscore/seq.h 2022-11-30 10:10:11.632514412 -0700
|
|
|
ce871cf |
@@ -270,7 +270,7 @@ class Seq : public QObject, public Seque
|
|
|
ce871cf |
void initInstruments(bool realTime = false);
|
|
|
ce871cf |
|
|
|
ce871cf |
Driver* driver() { return _driver; }
|
|
|
ce871cf |
- void setDriver(Driver* d) { _driver = d; }
|
|
|
ce871cf |
+ void setDriver(Driver* d) { if (_driver != nullptr) delete _driver; _driver = d; }
|
|
|
ce871cf |
MasterSynthesizer* synti() const { return _synti; }
|
|
|
ce871cf |
void setMasterSynthesizer(MasterSynthesizer* ms) { _synti = ms; }
|
|
|
ce871cf |
|