wip midi
This commit is contained in:
+4
-19
@@ -4,15 +4,6 @@
|
||||
#include "log.h"
|
||||
#include "types.h"
|
||||
|
||||
void midi_close(MidiDevice device) {
|
||||
if (device.input != NULL) {
|
||||
snd_rawmidi_close(device.input);
|
||||
}
|
||||
if (device.output != NULL) {
|
||||
snd_rawmidi_close(device.input);
|
||||
}
|
||||
}
|
||||
|
||||
MidiDevice midi_open(char *name) {
|
||||
MidiDevice device;
|
||||
|
||||
@@ -24,16 +15,12 @@ MidiDevice midi_open(char *name) {
|
||||
|
||||
device.error = device.input == NULL || device.output == NULL;
|
||||
|
||||
if (device.error) {
|
||||
midi_close(device);
|
||||
}
|
||||
|
||||
log_debug("(%s) MIDI open", name);
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
void midi_background_listen(MidiDevice device, SharedContext *context) {
|
||||
bool midi_background_listen(MidiDevice device, SharedContext *context) {
|
||||
pid_t pid;
|
||||
int bytes_read;
|
||||
unsigned char buffer[3];
|
||||
@@ -41,10 +28,10 @@ void midi_background_listen(MidiDevice device, SharedContext *context) {
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
log_error("Could not create subprocess");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (pid == 0) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
log_info("(%s) background acquisition started (pid: %d)", device.name, pid);
|
||||
|
||||
@@ -57,7 +44,5 @@ void midi_background_listen(MidiDevice device, SharedContext *context) {
|
||||
|
||||
log_info("(%s) background acquisition stopped by main thread (pid: %d)",
|
||||
device.name, pid);
|
||||
return false;
|
||||
}
|
||||
|
||||
// int bytes_read = snd_rawmidi_read(input, input_buffer, sizeof(input_buffer));
|
||||
// snd_rawmidi_write(output, buffer, 3);
|
||||
Reference in New Issue
Block a user