This commit is contained in:
2025-09-28 16:56:21 +02:00
parent fb071f95b4
commit 6905d0017d
6 changed files with 22 additions and 35 deletions
+11 -9
View File
@@ -166,14 +166,16 @@ static void init_inputs(char *video_in[MAX_VIDEO], unsigned int input_count,
}
}
static void start_video_captures(unsigned int video_count) {
static bool start_video_captures(unsigned int video_count) {
unsigned int i;
for (i = 0; i < video_count; i++) {
if (!inputs[i].error) {
video_background_read(&inputs[i], context, i);
if (!inputs[i].error && !video_background_read(&inputs[i], context, i)) {
return false;
}
}
return true;
}
static void free_video_captures(unsigned int video_count) {
@@ -253,14 +255,18 @@ void forge_run(Parameters params) {
init_inputs(params.video_in, params.video_in_count, params.video_size);
start_video_captures(params.video_in_count);
if (!start_video_captures(params.video_in_count)) {
return;
}
midi = midi_open(config_file_get_str(config, "MIDI_HW", "hw"));
if (midi.error) {
params.demo = true;
} else {
midi_background_listen(midi, context);
if (!midi_background_listen(midi, context)) {
return;
}
}
window_startup(error_callback);
@@ -311,8 +317,6 @@ void forge_run(Parameters params) {
context->stop = true;
wait(NULL);
shaders_free(program);
if (window_output != NULL) {
@@ -329,8 +333,6 @@ void forge_run(Parameters params) {
free_video_captures(params.video_in_count);
midi_close(midi);
free_context();
free_files(frag_count);
+4 -19
View File
@@ -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);
+1 -2
View File
@@ -4,7 +4,6 @@
#define MIDI_H
MidiDevice midi_open(char *name);
void midi_close(MidiDevice device);
void midi_background_listen(MidiDevice device, SharedContext *context);
bool midi_background_listen(MidiDevice device, SharedContext *context);
#endif /* MIDI_H */
+4 -3
View File
@@ -327,7 +327,7 @@ static bool read_video(VideoCapture *video_capture) {
return true;
}
void video_background_read(VideoCapture *video_capture, SharedContext *context,
bool video_background_read(VideoCapture *video_capture, SharedContext *context,
int input_index) {
pid_t pid;
Timer timer;
@@ -336,10 +336,10 @@ void video_background_read(VideoCapture *video_capture, 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)", video_capture->name,
pid);
@@ -362,6 +362,7 @@ void video_background_read(VideoCapture *video_capture, SharedContext *context,
video_capture->name, pid);
}
exit(context->stop ? EXIT_SUCCESS : EXIT_FAILURE);
return false;
}
void video_free(VideoCapture video_capture) {
+1 -1
View File
@@ -5,7 +5,7 @@
VideoCapture video_init(char *name, unsigned int preferred_height);
void video_background_read(VideoCapture *video_capture, SharedContext *context,
bool video_background_read(VideoCapture *video_capture, SharedContext *context,
int input_index);
void video_free(VideoCapture video_capture);
+1 -1
View File
@@ -21,7 +21,7 @@ static void init_glfw(void (*error_callback)(int, const char *)) {
exit(EXIT_FAILURE);
}
log_info("[GLFS] Initialized...");
log_info("[GLFW] Initialized...");
}
static GLFWmonitor *get_monitor(unsigned char monitor_index) {