Browse Source

Add jack2 patches

Signed-off-by: falkTX <falktx@falktx.com>
main
falkTX 2 months ago
parent
commit
1153ea5339
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 225 additions and 0 deletions
  1. +53
    -0
      patches/jack2/01_ignore-missing-internals.patch
  2. +25
    -0
      patches/jack2/02_skip-alsa-jack-plugins.patch
  3. +147
    -0
      patches/jack2/03_portaudio-midi-hack.patch

+ 53
- 0
patches/jack2/01_ignore-missing-internals.patch View File

@@ -0,0 +1,53 @@
From 3bc08a79629fe22b2cbf4acb4a69bfe79403a6a6 Mon Sep 17 00:00:00 2001
From: falkTX <falktx@falktx.com>
Date: Thu, 14 Mar 2024 18:26:30 +0100
Subject: [PATCH] Ignore missing internals

Signed-off-by: falkTX <falktx@falktx.com>
---
common/JackControlAPI.cpp | 3 ---
common/JackDriverLoader.cpp | 9 ---------
2 files changed, 12 deletions(-)

diff --git a/common/JackControlAPI.cpp b/common/JackControlAPI.cpp
index c13640a97..0e005353b 100644
--- a/common/JackControlAPI.cpp
+++ b/common/JackControlAPI.cpp
@@ -458,10 +458,7 @@ jackctl_internals_load(
descriptor_node_ptr = jack_internals_load(NULL);
if (descriptor_node_ptr == NULL)
- {
- jack_error("Could not find any internals in driver directory!");
return false;
- }
while (descriptor_node_ptr != NULL)
{
diff --git a/common/JackDriverLoader.cpp b/common/JackDriverLoader.cpp
index 77150435c..9a1be518b 100644
--- a/common/JackDriverLoader.cpp
+++ b/common/JackDriverLoader.cpp
@@ -670,10 +670,6 @@ JSList* jack_internals_load(JSList * internals)
} while (FindNextFileW(file, &filedata));
- if (!driver_list) {
- jack_error ("Could not find any internals in %s!", driver_dir);
- }
-
error:
if (driver_dir) {
free(driver_dir);
@@ -738,11 +734,6 @@ JSList* jack_internals_load(JSList * internals)
driver_dir, strerror (errno));
}
- if (!driver_list) {
- jack_error ("Could not find any internals in %s!", driver_dir);
- return NULL;
- }
-
return driver_list;
}

+ 25
- 0
patches/jack2/02_skip-alsa-jack-plugins.patch View File

@@ -0,0 +1,25 @@
From 912ed316fdec187005f4172d06093baa1a791c2a Mon Sep 17 00:00:00 2001
From: falkTX <falktx@falktx.com>
Date: Thu, 14 Mar 2024 18:27:05 +0100
Subject: [PATCH] Skip alsa-jack from alsa-plugins

Signed-off-by: falkTX <falktx@falktx.com>
---
common/JackInternalClient.cpp | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/common/JackInternalClient.cpp b/common/JackInternalClient.cpp
index 6b4dd75bd..a428c975d 100644
--- a/common/JackInternalClient.cpp
+++ b/common/JackInternalClient.cpp
@@ -73,6 +73,10 @@ int JackInternalClient::Open(const char* server_name, const char* name, jack_uui
int result;
jack_log("JackInternalClient::Open name = %s", name);
+ // ignore client from alsa-plugins
+ if (strncmp(name, "alsa-jack.", 10) == 0)
+ return -1;
+
if (strlen(name) >= JACK_CLIENT_NAME_SIZE) {
jack_error("\"%s\" is too long to be used as a JACK client name.\n"
"Please use %lu characters or less",

+ 147
- 0
patches/jack2/03_portaudio-midi-hack.patch View File

@@ -0,0 +1,147 @@
From 6c283bab3570af9e059745aec6a7f41bfa8e37df Mon Sep 17 00:00:00 2001
From: falkTX <falktx@falktx.com>
Date: Thu, 14 Mar 2024 18:27:29 +0100
Subject: [PATCH] portaudio driver midi bridge

Signed-off-by: falkTX <falktx@falktx.com>
---
windows/portaudio/JackPortAudioDriver.cpp | 64 +++++++++++++++++++++++
windows/portaudio/JackPortAudioDriver.h | 7 +++
2 files changed, 71 insertions(+)

diff --git a/windows/portaudio/JackPortAudioDriver.cpp b/windows/portaudio/JackPortAudioDriver.cpp
index 67829abac..0f428cf0d 100644
--- a/windows/portaudio/JackPortAudioDriver.cpp
+++ b/windows/portaudio/JackPortAudioDriver.cpp
@@ -26,6 +26,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackTime.h"
#include "JackTools.h"
#include "JackCompilerDeps.h"
+#include "JackLockedEngine.h"
+#include "JackMidiPort.h"
#include <iostream>
#include <assert.h>
@@ -33,6 +35,31 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackServerGlobals.h"
#endif
+typedef uint32_t (*jacksym_midi_get_event_count)(void*);
+typedef int (*jacksym_midi_event_get)(jack_midi_event_t*, void*, uint32_t);
+typedef int (*jacksym_midi_event_write)(void*, jack_nframes_t, const jack_midi_data_t*, size_t);
+
+extern "C"
+{
+LIB_EXPORT uint32_t jack_midi_get_event_count(void* port_buffer);
+
+LIB_EXPORT int jack_midi_event_get(jack_midi_event_t* event,
+ void* port_buffer, uint32_t event_index);
+
+LIB_EXPORT int jack_midi_event_write(void* port_buffer,
+ jack_nframes_t time, const jack_midi_data_t* data, size_t data_size);
+
+void PaJack_SetMidiCallbacks(PaStream* s,
+ jacksym_midi_get_event_count get_count,
+ jacksym_midi_event_get get,
+ jacksym_midi_event_write write);
+
+void PaJack_SetMidiBuffers(PaStream* s,
+ void* get_ptr,
+ void* write_ptr);
+
+}
+
using namespace std;
namespace Jack
@@ -109,6 +136,14 @@ int JackPortAudioDriver::Read()
for (int i = 0; i < fCaptureChannels; i++) {
memcpy(GetInputBuffer(i), fInputBuffer[i], sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize);
}
+
+#ifdef __linux__
+ JackMidiBuffer* cbuf = (JackMidiBuffer*)fGraphManager->GetBuffer(fCaptureMidiPort, fEngineControl->fBufferSize);
+ JackMidiBuffer* pbuf = (JackMidiBuffer*)fGraphManager->GetBuffer(fPlaybackMidiPort, fEngineControl->fBufferSize);
+ pbuf->Reset(fEngineControl->fBufferSize);
+ PaJack_SetMidiBuffers(fStream, pbuf, cbuf);
+#endif
+
return 0;
}
@@ -117,6 +152,12 @@ int JackPortAudioDriver::Write()
for (int i = 0; i < fPlaybackChannels; i++) {
memcpy(fOutputBuffer[i], GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize);
}
+
+#ifdef __linux__
+ JackMidiBuffer* cbuf = (JackMidiBuffer*)fGraphManager->GetBuffer(fCaptureMidiPort, fEngineControl->fBufferSize);
+ cbuf->Reset(fEngineControl->fBufferSize);
+#endif
+
return 0;
}
@@ -303,6 +344,23 @@ int JackPortAudioDriver::Open(jack_nframes_t buffer_size,
device_reservation_loop_running = false;
}
}
+
+ jack_port_id_t port_index;
+ JackPort* port;
+ if (fEngine->PortRegister(fClientControl.fRefNum, "system:midi_capture_1", JACK_DEFAULT_MIDI_TYPE,
+ CaptureDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) {
+ goto error;
+ }
+ fCaptureMidiPort = port_index;
+ port = fGraphManager->GetPort(port_index);
+ port->SetAlias("MOD Desktop MIDI Capture");
+ if (fEngine->PortRegister(fClientControl.fRefNum, "system:midi_playback_1", JACK_DEFAULT_MIDI_TYPE,
+ PlaybackDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) {
+ goto error;
+ }
+ fPlaybackMidiPort = port_index;
+ port = fGraphManager->GetPort(port_index);
+ port->SetAlias("MOD Desktop MIDI Playback");
#endif
return 0;
@@ -387,6 +445,12 @@ int JackPortAudioDriver::Start()
if (JackAudioDriver::Start() == 0) {
PaError err;
if ((err = Pa_StartStream(fStream)) == paNoError) {
+#ifdef __linux__
+ PaJack_SetMidiCallbacks(fStream,
+ jack_midi_get_event_count,
+ jack_midi_event_get,
+ jack_midi_event_write);
+#endif
return 0;
}
jack_error("Pa_StartStream error = %s", Pa_GetErrorText(err));
diff --git a/windows/portaudio/JackPortAudioDriver.h b/windows/portaudio/JackPortAudioDriver.h
index 7b16d6ea6..f366189b7 100644
--- a/windows/portaudio/JackPortAudioDriver.h
+++ b/windows/portaudio/JackPortAudioDriver.h
@@ -49,7 +49,11 @@ class JackPortAudioDriver :
PaDeviceIndex fInputDevice;
PaDeviceIndex fOutputDevice;
PortAudioDevices* fPaDevices;
+#ifdef __linux__
+ int fCaptureMidiPort;
+ int fPlaybackMidiPort;
jack_native_thread_t fReservationLoopThread;
+#endif
static int Render(const void* inputBuffer, void* outputBuffer,
unsigned long framesPerBuffer,
@@ -69,6 +73,9 @@ class JackPortAudioDriver :
#endif
JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL),
fInputDevice(paNoDevice), fOutputDevice(paNoDevice), fPaDevices(pa_devices)
+#ifdef __linux__
+ , fCaptureMidiPort(0), fPlaybackMidiPort(0)
+#endif
{}
virtual ~JackPortAudioDriver()

Loading…
Cancel
Save