initial import
This commit is contained in:
58
portmidi/PKGBUILD
Normal file
58
portmidi/PKGBUILD
Normal file
@@ -0,0 +1,58 @@
|
||||
# Maintainer: Jesus E. <heckyel@riseup.net>
|
||||
|
||||
pkgname=portmidi
|
||||
pkgver=217
|
||||
_debver=217
|
||||
_debrel=6
|
||||
pkgrel=2
|
||||
pkgdesc="Platform independent library for real-time MIDI input/output"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://portmedia.sourceforge.net/"
|
||||
license=('Expat')
|
||||
depends=('alsa-lib' 'libsndio')
|
||||
makedepends=('cmake' 'quilt')
|
||||
optdepends=('sndio: audio and MIDI server')
|
||||
options=('!makeflags')
|
||||
source=(https://deb.debian.org/debian/pool/main/p/portmidi/portmidi_$pkgver.orig.tar.gz
|
||||
https://deb.debian.org/debian/pool/main/p/portmidi/portmidi_$_debver-$_debrel.debian.tar.xz
|
||||
remove-java-support.patch
|
||||
sndio.patch)
|
||||
sha512sums=('ae534b5e9128b586044ce4ac2625d1763fa5abacacac7eb36ba050309c282de453ab403499ca13fd02e1e2fff18f1a3932b78063bc28c37c69f2b45905b4c78e'
|
||||
'0fedc8115e42954eff090ba545903070188adbb882e7d3ef9c4918ca8daef19292419f970cb35e52530b79cea1e00a73a99d9ed0a78dcd673307511be4891f48'
|
||||
'75219a938ecabc03999af4639bce4b8ded77d267cbb08fa308f74d684047445b27e1c30e1fd96038df1ad6768ad36530b15415bf41603bb9f92921ae1bb05122'
|
||||
'a6ec49a1dd472d3cbfe00a5606744e4c2a7d05c0b17f65af6724bd303acbe405b8db38c51fb95feb459de839f6584c97e9c24536f1e01472fff35836764c7bfc')
|
||||
|
||||
prepare() {
|
||||
cd ${pkgname}
|
||||
if [[ ${pkgver%.*} = ${_debver%.*} ]]; then
|
||||
# Debian patches
|
||||
export QUILT_PATCHES=debian/patches
|
||||
export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
|
||||
export QUILT_DIFF_ARGS='--no-timestamps'
|
||||
|
||||
mv "$srcdir"/debian .
|
||||
|
||||
# Doesn't apply and seems unimportant
|
||||
rm -v debian/patches/13-disablejni.patch || true
|
||||
|
||||
quilt push -av
|
||||
fi
|
||||
patch -p1 -i ../remove-java-support.patch
|
||||
patch -p1 -i ../sndio.patch
|
||||
}
|
||||
|
||||
build() {
|
||||
cd ${pkgname}
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=Release \
|
||||
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=Release \
|
||||
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=Release
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd ${pkgname}
|
||||
make DESTDIR="${pkgdir}" install
|
||||
|
||||
install -Dm644 license.txt "${pkgdir}/usr/lib/licenses/${pkgname}/license.txt"
|
||||
}
|
||||
87
portmidi/remove-java-support.patch
Normal file
87
portmidi/remove-java-support.patch
Normal file
@@ -0,0 +1,87 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 4919b78..d4b5ec2 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -72,6 +72,3 @@ add_subdirectory(pm_test)
|
||||
|
||||
add_subdirectory(pm_dylib)
|
||||
|
||||
-# Cannot figure out how to make an xcode Java application with CMake
|
||||
-add_subdirectory(pm_java)
|
||||
-
|
||||
diff --git a/pm_common/CMakeLists.txt b/pm_common/CMakeLists.txt
|
||||
index e171047..421a68c 100644
|
||||
--- a/pm_common/CMakeLists.txt
|
||||
+++ b/pm_common/CMakeLists.txt
|
||||
@@ -66,15 +66,6 @@ if(UNIX)
|
||||
set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
|
||||
message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
|
||||
else(APPLE)
|
||||
- # LINUX settings...
|
||||
- include(FindJNI)
|
||||
- message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
|
||||
- message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
|
||||
- message(STATUS "JAVA_INCLUDE_PATH2 is " ${JAVA_INCLUDE_PATH2})
|
||||
- message(STATUS "JAVA_JVM_LIBRARY is " ${JAVA_JVM_LIBRARY})
|
||||
- set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
|
||||
- # libjvm.so is found relative to JAVA_INCLUDE_PATH:
|
||||
- set(JAVAVM_LIB ${JAVA_JVM_LIBRARY}/libjvm.so)
|
||||
|
||||
set(LINUXSRC pmlinuxalsa pmlinux finddefault)
|
||||
prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
|
||||
@@ -99,7 +90,6 @@ else(UNIX)
|
||||
set(PM_NEEDED_LIBS winmm.lib)
|
||||
endif(WIN32)
|
||||
endif(UNIX)
|
||||
-set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVA_JVM_LIBRARY})
|
||||
|
||||
# this completes the list of library sources by adding shared code
|
||||
list(APPEND LIBSRC pmutil portmidi)
|
||||
@@ -109,17 +99,10 @@ add_library(portmidi-static ${LIBSRC})
|
||||
set_target_properties(portmidi-static PROPERTIES OUTPUT_NAME "portmidi_s")
|
||||
target_link_libraries(portmidi-static ${PM_NEEDED_LIBS})
|
||||
|
||||
-# define the jni library
|
||||
-include_directories(${JAVA_INCLUDE_PATHS})
|
||||
-
|
||||
-set(JNISRC ${LIBSRC} ../pm_java/pmjni/pmjni.c)
|
||||
-add_library(pmjni SHARED ${JNISRC})
|
||||
-target_link_libraries(pmjni ${JNI_EXTRA_LIBS})
|
||||
-set_target_properties(pmjni PROPERTIES EXECUTABLE_EXTENSION "jnilib")
|
||||
|
||||
# install the libraries (Linux and Mac OS X command line)
|
||||
if(UNIX)
|
||||
- INSTALL(TARGETS portmidi-static pmjni
|
||||
+ INSTALL(TARGETS portmidi-static
|
||||
LIBRARY DESTINATION /usr/local/lib
|
||||
ARCHIVE DESTINATION /usr/local/lib)
|
||||
# .h files installed by pm_dylib/CMakeLists.txt, so don't need them here
|
||||
diff --git a/pm_dylib/CMakeLists.txt b/pm_dylib/CMakeLists.txt
|
||||
index f693dd6..fcadf1d 100644
|
||||
--- a/pm_dylib/CMakeLists.txt
|
||||
+++ b/pm_dylib/CMakeLists.txt
|
||||
@@ -63,24 +63,6 @@ if(UNIX)
|
||||
message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
|
||||
else(APPLE)
|
||||
# LINUX settings...
|
||||
- include(FindJNI)
|
||||
- # message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
|
||||
- # message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
|
||||
- # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
|
||||
- # note: user might need to set JAVA_INCLUDE_PATH manually
|
||||
- #
|
||||
- # this will probably break on BSD and other Unix systems; the fix
|
||||
- # depends on whether FindJNI can find Java or not. If yes, then
|
||||
- # we should try to rely on automatically set JAVA_INCLUDE_PATH and
|
||||
- # JAVA_INCLUDE_PATH2; if no, then we need to make both JAVA_INCLUDE_PATH
|
||||
- # and JAVA_INCLUDE_PATH2 set by user (will need clear documentation
|
||||
- # because JAVA_INCLUDE_PATH2 is pretty obscure)
|
||||
- set(JAVA_INCLUDE_PATH ${JAVA_INCLUDE_PATH-UNKNOWN}
|
||||
- CACHE STRING "where to find Java SDK include directory")
|
||||
- set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH}/linux)
|
||||
- # libjvm.so is found relative to JAVA_INCLUDE_PATH:
|
||||
- set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../jre/lib/i386/client/libjvm.so)
|
||||
-
|
||||
set(LINUXSRC pmlinuxalsa pmlinux finddefault)
|
||||
prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
|
||||
list(APPEND LIBSRC ../porttime/ptlinux)
|
||||
419
portmidi/sndio.patch
Normal file
419
portmidi/sndio.patch
Normal file
@@ -0,0 +1,419 @@
|
||||
diff --git a/pm_common/CMakeLists.txt b/pm_common/CMakeLists.txt
|
||||
index 421a68c..c7d1636 100644
|
||||
--- a/pm_common/CMakeLists.txt
|
||||
+++ b/pm_common/CMakeLists.txt
|
||||
@@ -70,8 +70,11 @@ if(UNIX)
|
||||
set(LINUXSRC pmlinuxalsa pmlinux finddefault)
|
||||
prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
|
||||
list(APPEND LIBSRC ../porttime/ptlinux)
|
||||
+ set(SNDIOSRC pmsndio)
|
||||
+ prepend_path(LIBSRC ../pm_sndio/ ${SNDIOSRC})
|
||||
+ list(APPEND LIBSRC ../porttime/ptlinux)
|
||||
|
||||
- set(PM_NEEDED_LIBS pthread asound)
|
||||
+ set(PM_NEEDED_LIBS pthread asound sndio)
|
||||
endif(APPLE)
|
||||
else(UNIX)
|
||||
if(WIN32)
|
||||
diff --git a/pm_dylib/CMakeLists.txt b/pm_dylib/CMakeLists.txt
|
||||
index fcadf1d..79ecb82 100644
|
||||
--- a/pm_dylib/CMakeLists.txt
|
||||
+++ b/pm_dylib/CMakeLists.txt
|
||||
@@ -66,8 +66,11 @@ if(UNIX)
|
||||
set(LINUXSRC pmlinuxalsa pmlinux finddefault)
|
||||
prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
|
||||
list(APPEND LIBSRC ../porttime/ptlinux)
|
||||
+ set(SNDIOSRC pmsndio)
|
||||
+ prepend_path(LIBSRC ../pm_sndio/ ${SNDIOSRC})
|
||||
+ list(APPEND LIBSRC ../porttime/ptlinux)
|
||||
|
||||
- set(PM_NEEDED_LIBS pthread asound)
|
||||
+ set(PM_NEEDED_LIBS pthread asound sndio)
|
||||
endif(APPLE)
|
||||
else(UNIX)
|
||||
if(WIN32)
|
||||
diff --git b/pm_sndio/pmsndio.c b/pm_sndio/pmsndio.c
|
||||
new file mode 100644
|
||||
index 0000000..7cfb330
|
||||
--- /dev/null
|
||||
+++ b/pm_sndio/pmsndio.c
|
||||
@@ -0,0 +1,368 @@
|
||||
+/* pmsndio.c -- PortMidi os-dependent code */
|
||||
+
|
||||
+#include <stdlib.h>
|
||||
+#include <stdio.h>
|
||||
+#include <sndio.h>
|
||||
+#include <string.h>
|
||||
+#include <poll.h>
|
||||
+#include <errno.h>
|
||||
+#include <pthread.h>
|
||||
+#include "portmidi.h"
|
||||
+#include "pmutil.h"
|
||||
+#include "pminternal.h"
|
||||
+#include "porttime.h"
|
||||
+
|
||||
+#define NDEVS 9
|
||||
+#define SYSEX_MAXLEN 1024
|
||||
+
|
||||
+#define SYSEX_START 0xf0
|
||||
+#define SYSEX_END 0xf7
|
||||
+
|
||||
+PmDeviceID pm_default_input_device_id = -1;
|
||||
+PmDeviceID pm_default_output_device_id = -1;
|
||||
+
|
||||
+extern pm_fns_node pm_sndio_in_dictionary;
|
||||
+extern pm_fns_node pm_sndio_out_dictionary;
|
||||
+
|
||||
+/* length of voice and common messages (status byte included) */
|
||||
+unsigned int voice_len[] = { 3, 3, 3, 3, 2, 2, 3 };
|
||||
+unsigned int common_len[] = { 0, 2, 3, 2, 0, 0, 1, 1 };
|
||||
+
|
||||
+struct mio_dev {
|
||||
+ char name[16];
|
||||
+ struct mio_hdl *hdl;
|
||||
+ int mode;
|
||||
+ char errmsg[PM_HOST_ERROR_MSG_LEN];
|
||||
+ pthread_t thread;
|
||||
+} devs[NDEVS];
|
||||
+
|
||||
+static void set_mode(struct mio_dev *, unsigned int);
|
||||
+
|
||||
+void pm_init()
|
||||
+{
|
||||
+ int i, j, k = 0;
|
||||
+ char devices[][16] = {"midithru", "rmidi", "midi", "snd"};
|
||||
+
|
||||
+ /* default */
|
||||
+ strcpy(devs[0].name, MIO_PORTANY);
|
||||
+ pm_add_device("SNDIO", devs[k].name, TRUE, (void *) &devs[k],
|
||||
+ &pm_sndio_in_dictionary);
|
||||
+ pm_add_device("SNDIO", devs[k].name, FALSE, (void *) &devs[k],
|
||||
+ &pm_sndio_out_dictionary);
|
||||
+ k++;
|
||||
+
|
||||
+ for (i = 0; i < 4; i++) {
|
||||
+ for (j = 0; j < 2; j++) {
|
||||
+ sprintf(devs[k].name, "%s/%d", devices[i], j);
|
||||
+ pm_add_device("SNDIO", devs[k].name, TRUE, (void *) &devs[k],
|
||||
+ &pm_sndio_in_dictionary);
|
||||
+ pm_add_device("SNDIO", devs[k].name, FALSE, (void *) &devs[k],
|
||||
+ &pm_sndio_out_dictionary);
|
||||
+ k++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // this is set when we return to Pm_Initialize, but we need it
|
||||
+ // now in order to (successfully) call Pm_CountDevices()
|
||||
+ pm_initialized = TRUE;
|
||||
+ pm_default_input_device_id = 0;
|
||||
+ pm_default_output_device_id = 1;
|
||||
+}
|
||||
+
|
||||
+void pm_term(void)
|
||||
+{
|
||||
+ int i;
|
||||
+ for(i = 0; i < NDEVS; i++) {
|
||||
+ if (devs[i].mode != 0) {
|
||||
+ set_mode(&devs[i], 0);
|
||||
+ if (devs[i].thread) {
|
||||
+ pthread_join(devs[i].thread, NULL);
|
||||
+ devs[i].thread = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+PmDeviceID Pm_GetDefaultInputDeviceID() {
|
||||
+ Pm_Initialize();
|
||||
+ return pm_default_input_device_id;
|
||||
+}
|
||||
+
|
||||
+PmDeviceID Pm_GetDefaultOutputDeviceID() {
|
||||
+ Pm_Initialize();
|
||||
+ return pm_default_output_device_id;
|
||||
+}
|
||||
+
|
||||
+void *pm_alloc(size_t s) { return malloc(s); }
|
||||
+
|
||||
+void pm_free(void *ptr) { free(ptr); }
|
||||
+
|
||||
+/* midi_message_length -- how many bytes in a message? */
|
||||
+static int midi_message_length(PmMessage message)
|
||||
+{
|
||||
+ unsigned char st = message & 0xff;
|
||||
+ if (st >= 0xf8)
|
||||
+ return 1;
|
||||
+ else if (st >= 0xf0)
|
||||
+ return common_len[st & 7];
|
||||
+ else if (st >= 0x80)
|
||||
+ return voice_len[(st >> 4) & 7];
|
||||
+ else
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void* input_thread(void *param)
|
||||
+{
|
||||
+ PmInternal *midi = (PmInternal*)param;
|
||||
+ struct mio_dev *dev = (struct mio_dev *) midi->descriptor;
|
||||
+ struct pollfd pfd[1];
|
||||
+ nfds_t nfds;
|
||||
+ unsigned char st = 0, c = 0;
|
||||
+ int rc, revents, idx = 0, len = 0;
|
||||
+ size_t todo = 0;
|
||||
+ unsigned char buf[0x200], *p;
|
||||
+ PmEvent pm_ev, pm_ev_rt;
|
||||
+ unsigned char sysex_data[SYSEX_MAXLEN];
|
||||
+
|
||||
+ while(dev->mode & MIO_IN) {
|
||||
+ if (todo == 0) {
|
||||
+ nfds = mio_pollfd(dev->hdl, pfd, POLLIN);
|
||||
+ rc = poll(pfd, nfds, 100);
|
||||
+ if (rc < 0) {
|
||||
+ if (errno == EINTR)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ }
|
||||
+ revents = mio_revents(dev->hdl, pfd);
|
||||
+ if (!(revents & POLLIN))
|
||||
+ continue;
|
||||
+
|
||||
+ todo = mio_read(dev->hdl, buf, sizeof(buf));
|
||||
+ if (todo == 0)
|
||||
+ continue;
|
||||
+ p = buf;
|
||||
+ }
|
||||
+ c = *p++;
|
||||
+ todo--;
|
||||
+
|
||||
+ if (c >= 0xf8) {
|
||||
+ pm_ev_rt.message = c;
|
||||
+ pm_ev_rt.timestamp = Pt_Time();
|
||||
+ pm_read_short(midi, &pm_ev_rt);
|
||||
+ } else if (c == SYSEX_END) {
|
||||
+ if (st == SYSEX_START) {
|
||||
+ sysex_data[idx++] = c;
|
||||
+ pm_read_bytes(midi, sysex_data, idx, Pt_Time());
|
||||
+ }
|
||||
+ st = 0;
|
||||
+ idx = 0;
|
||||
+ } else if (c == SYSEX_START) {
|
||||
+ st = c;
|
||||
+ idx = 0;
|
||||
+ sysex_data[idx++] = c;
|
||||
+ } else if (c >= 0xf0) {
|
||||
+ pm_ev.message = c;
|
||||
+ len = common_len[c & 7];
|
||||
+ st = c;
|
||||
+ idx = 1;
|
||||
+ } else if (c >= 0x80) {
|
||||
+ pm_ev.message = c;
|
||||
+ len = voice_len[(c >> 4) & 7];
|
||||
+ st = c;
|
||||
+ idx = 1;
|
||||
+ } else if (st == SYSEX_START) {
|
||||
+ if (idx == SYSEX_MAXLEN) {
|
||||
+ fprintf(stderr, "the message is too long\n");
|
||||
+ idx = st = 0;
|
||||
+ } else {
|
||||
+ sysex_data[idx++] = c;
|
||||
+ }
|
||||
+ } else if (st) {
|
||||
+ if (idx == 0 && st != SYSEX_START)
|
||||
+ pm_ev.message |= (c << (8 * idx++));
|
||||
+ pm_ev.message |= (c << (8 * idx++));
|
||||
+ if (idx == len) {
|
||||
+ pm_read_short(midi, &pm_ev);
|
||||
+ if (st >= 0xf0)
|
||||
+ st = 0;
|
||||
+ idx = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ pthread_exit(NULL);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void set_mode(struct mio_dev *dev, unsigned int mode) {
|
||||
+ if (dev->mode != 0)
|
||||
+ mio_close(dev->hdl);
|
||||
+ dev->mode = 0;
|
||||
+ if (mode != 0)
|
||||
+ dev->hdl = mio_open(dev->name, mode, 0);
|
||||
+ if (dev->hdl)
|
||||
+ dev->mode = mode;
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_out_open(PmInternal *midi, void *driverInfo)
|
||||
+{
|
||||
+ descriptor_type desc = &descriptors[midi->device_id];
|
||||
+ struct mio_dev *dev = (struct mio_dev *) desc->descriptor;
|
||||
+
|
||||
+ if (dev->mode & MIO_OUT)
|
||||
+ return pmNoError;
|
||||
+
|
||||
+ set_mode(dev, dev->mode | MIO_OUT);
|
||||
+ if (!(dev->mode & MIO_OUT)) {
|
||||
+ snprintf(dev->errmsg, PM_HOST_ERROR_MSG_LEN,
|
||||
+ "mio_open (output) failed: %s\n", dev->name);
|
||||
+ return pmHostError;
|
||||
+ }
|
||||
+
|
||||
+ midi->descriptor = (void *)dev;
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_in_open(PmInternal *midi, void *driverInfo)
|
||||
+{
|
||||
+ descriptor_type desc = &descriptors[midi->device_id];
|
||||
+ struct mio_dev *dev = (struct mio_dev *) desc->descriptor;
|
||||
+
|
||||
+ if (dev->mode & MIO_IN)
|
||||
+ return pmNoError;
|
||||
+
|
||||
+ set_mode(dev, dev->mode | MIO_IN);
|
||||
+ if (!(dev->mode & MIO_IN)) {
|
||||
+ snprintf(dev->errmsg, PM_HOST_ERROR_MSG_LEN,
|
||||
+ "mio_open (input) failed: %s\n", dev->name);
|
||||
+ return pmHostError;
|
||||
+ }
|
||||
+ midi->descriptor = (void *)dev;
|
||||
+ pthread_attr_t attr;
|
||||
+ pthread_attr_init(&attr);
|
||||
+ pthread_create(&dev->thread, &attr, input_thread, ( void* )midi);
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_out_close(PmInternal *midi)
|
||||
+{
|
||||
+ struct mio_dev *dev = (struct mio_dev *) midi->descriptor;
|
||||
+
|
||||
+ if (dev->mode & MIO_OUT)
|
||||
+ set_mode(dev, dev->mode & ~MIO_OUT);
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_in_close(PmInternal *midi)
|
||||
+{
|
||||
+ struct mio_dev *dev = (struct mio_dev *) midi->descriptor;
|
||||
+
|
||||
+ if (dev->mode & MIO_IN) {
|
||||
+ set_mode(dev, dev->mode & ~MIO_IN);
|
||||
+ pthread_join(dev->thread, NULL);
|
||||
+ dev->thread = NULL;
|
||||
+ }
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_abort(PmInternal *midi)
|
||||
+{
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static PmTimestamp sndio_synchronize(PmInternal *midi)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static PmError do_write(struct mio_dev *dev, const void *addr, size_t nbytes)
|
||||
+{
|
||||
+ size_t w = mio_write(dev->hdl, addr, nbytes);
|
||||
+
|
||||
+ if (w != nbytes) {
|
||||
+ snprintf(dev->errmsg, PM_HOST_ERROR_MSG_LEN,
|
||||
+ "mio_write failed, bytes written:%zu\n", w);
|
||||
+ return pmHostError;
|
||||
+ }
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_write_byte(PmInternal *midi, unsigned char byte,
|
||||
+ PmTimestamp timestamp)
|
||||
+{
|
||||
+ struct mio_dev *dev = (struct mio_dev *) midi->descriptor;
|
||||
+
|
||||
+ return do_write(dev, &byte, 1);
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_write_short(PmInternal *midi, PmEvent *event)
|
||||
+{
|
||||
+ struct mio_dev *dev = (struct mio_dev *) midi->descriptor;
|
||||
+ int nbytes = midi_message_length(event->message);
|
||||
+
|
||||
+ if (midi->latency > 0) {
|
||||
+ /* XXX the event should be queued for later playback */
|
||||
+ return do_write(dev, &event->message, nbytes);
|
||||
+ } else {
|
||||
+ return do_write(dev, &event->message, nbytes);
|
||||
+ }
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static PmError sndio_write_flush(PmInternal *midi, PmTimestamp timestamp)
|
||||
+{
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+PmError sndio_sysex(PmInternal *midi, PmTimestamp timestamp)
|
||||
+{
|
||||
+ return pmNoError;
|
||||
+}
|
||||
+
|
||||
+static unsigned int sndio_has_host_error(PmInternal *midi)
|
||||
+{
|
||||
+ struct mio_dev *dev = (struct mio_dev *) midi->descriptor;
|
||||
+
|
||||
+ return (dev->errmsg[0] != '\0');
|
||||
+}
|
||||
+
|
||||
+static void sndio_get_host_error(PmInternal *midi, char *msg, unsigned int len)
|
||||
+{
|
||||
+ struct mio_dev *dev = (struct mio_dev *) midi->descriptor;
|
||||
+
|
||||
+ strlcpy(msg, dev->errmsg, len);
|
||||
+ dev->errmsg[0] = '\0';
|
||||
+}
|
||||
+
|
||||
+pm_fns_node pm_sndio_in_dictionary = {
|
||||
+ none_write_short,
|
||||
+ none_sysex,
|
||||
+ none_sysex,
|
||||
+ none_write_byte,
|
||||
+ none_write_short,
|
||||
+ none_write_flush,
|
||||
+ sndio_synchronize,
|
||||
+ sndio_in_open,
|
||||
+ sndio_abort,
|
||||
+ sndio_in_close,
|
||||
+ success_poll,
|
||||
+ sndio_has_host_error,
|
||||
+ sndio_get_host_error
|
||||
+};
|
||||
+
|
||||
+pm_fns_node pm_sndio_out_dictionary = {
|
||||
+ sndio_write_short,
|
||||
+ sndio_sysex,
|
||||
+ sndio_sysex,
|
||||
+ sndio_write_byte,
|
||||
+ sndio_write_short,
|
||||
+ sndio_write_flush,
|
||||
+ sndio_synchronize,
|
||||
+ sndio_out_open,
|
||||
+ sndio_abort,
|
||||
+ sndio_out_close,
|
||||
+ none_poll,
|
||||
+ sndio_has_host_error,
|
||||
+ sndio_get_host_error
|
||||
+};
|
||||
+
|
||||
diff --git b/pm_sndio/pmsndio.h b/pm_sndio/pmsndio.h
|
||||
new file mode 100644
|
||||
index 0000000..4096d9b
|
||||
--- /dev/null
|
||||
+++ b/pm_sndio/pmsndio.h
|
||||
@@ -0,0 +1,5 @@
|
||||
+/* pmsndio.h */
|
||||
+
|
||||
+extern PmDeviceID pm_default_input_device_id;
|
||||
+extern PmDeviceID pm_default_output_device_id;
|
||||
+
|
||||
Reference in New Issue
Block a user