feat: video auto reconnect
Clang Lint CI / lint-no-video (push) Successful in 56s
Clang Build CI / run-no-video (push) Successful in 59s
Clang Build CI / run-video (push) Successful in 1m15s
Clang Build CI / build-release (push) Successful in 2m23s
Clang Lint CI / lint-video (push) Successful in 2m14s

This commit is contained in:
2026-05-14 13:16:55 +02:00
parent 25b7134a43
commit d4565fa507
18 changed files with 305 additions and 328 deletions
+10 -19
View File
@@ -1,6 +1,6 @@
#include <alsa/asoundlib.h>
#include <log.h>
#include <stdlib.h>
#include <pthread.h>
#include "types.h"
@@ -33,32 +33,23 @@ void midi_write(const MidiDevice *device, unsigned char code,
snd_rawmidi_write(device->output, buffer, 3);
}
bool midi_background_listen(const MidiDevice *device,
const SharedContext *context,
void (*event_callback)(unsigned char code,
unsigned char value)) {
pid_t pid;
void *midi_background_listen(void *args) {
MidiBackgroundReadArgs *process_args = (MidiBackgroundReadArgs *)args;
MidiDevice *device = process_args->device;
Context *context = process_args->context;
int bytes_read;
unsigned char buffer[3];
pid = fork();
if (pid < 0) {
log_error("Could not create subprocess");
return false;
}
if (pid == 0) {
return true;
}
log_info("(%s) background acquisition started (pid: %d)", device->name, pid);
log_info("(%s) background acquisition started", device->name);
while (!context->stop) {
bytes_read = snd_rawmidi_read(device->input, buffer, 3);
if (bytes_read == 3) {
event_callback(buffer[1], buffer[2]);
process_args->event_callback(buffer[1], buffer[2]);
}
}
log_info("(%s) background acquisition stopped by main thread (pid: %d)",
device->name, pid);
exit(EXIT_SUCCESS);
log_info("(%s) background acquisition stopped by main thread", device->name);
pthread_exit(NULL);
}