feat(video): can build without video
This commit is contained in:
@@ -16,7 +16,7 @@ jobs:
|
||||
- name: install libs
|
||||
run: sudo apt install -y libglfw3-dev libgl-dev libv4l-dev libasound2-dev libbsd-dev
|
||||
- name: gcc
|
||||
run: mkdir -p build && gcc -v -Wall -Wextra -Werror -Wno-format-truncation src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE
|
||||
run: mkdir -p build && gcc -v -Wall -Wextra -Werror -Wno-format-truncation src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DVIDEO_IN
|
||||
|
||||
build-release:
|
||||
needs: lint
|
||||
|
||||
@@ -125,6 +125,7 @@ make -f Makefile.dev release-arch
|
||||
- [x] Configurable key codes
|
||||
- [x] Monitor improvements
|
||||
- [ ] Ignore some values in auto random
|
||||
- [x] build without video in
|
||||
- [ ] Update README monitor/keymap
|
||||
- [ ] Auto reconnect midi input
|
||||
- [ ] Auto reconnect video device
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects -Wall
|
||||
bin_PROGRAMS = forge
|
||||
forge_SOURCES = src/args.c src/arr.c src/config_file.c src/file.c src/forge.c src/main.c src/midi.c src/project.c src/rand.c src/shaders.c src/shared.c src/state.c src/string.c src/tempo.c src/timer.c src/video.c src/window.c $(top_srcdir)/include/glad/gl.h $(top_srcdir)/include/glad/egl.h $(top_srcdir)/hashmap.c/hashmap.c $(top_srcdir)/log.c/src/log.c
|
||||
forge_CFLAGS = -Ofast -march=native -flto -funroll-loops -fprefetch-loop-arrays -fno-exceptions -fopenmp -I$(top_srcdir)/include -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DLOG_USE_COLOR -DDATADIR=\"$(datadir)/$(PACKAGE)\"
|
||||
forge_CFLAGS = -Ofast -march=native -flto -funroll-loops -fprefetch-loop-arrays -fno-exceptions -fopenmp -I$(top_srcdir)/include -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DLOG_USE_COLOR -DVIDEO_IN -DDATADIR=\"$(datadir)/$(PACKAGE)\"
|
||||
forge_LDADD = -lm -lGL -lglfw -lasound -lbsd
|
||||
include_HEADERS = src/args.h src/arr.h src/config.h src/config_file.h src/constants.h src/file.h src/forge.h src/main.h src/midi.h src/project.h src/rand.h src/shaders.h src/shared.h src/state.h src/string.h src/tempo.h src/timer.h src/types.h src/video.h src/window.h $(top_srcdir)/include/glad/gl.h $(top_srcdir)/include/glad/egl.h $(top_srcdir)/include/linmath.h $(top_srcdir)/include/hashmap.h $(top_srcdir)/include/log.h
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ build:
|
||||
-DGLFW_EXPOSE_NATIVE_EGL \
|
||||
-DGLFW_NATIVE_INCLUDE_NONE \
|
||||
-DLOG_USE_COLOR \
|
||||
-DVIDEO_IN \
|
||||
-o build/$(TARGET) \
|
||||
-g -Og
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
-Iinclude
|
||||
-DGLFW_INCLUDE_NONE
|
||||
-DGLFW_EXPOSE_NATIVE_EGL
|
||||
-DGLFW_NATIVE_INCLUDE_NONE
|
||||
-DGLFW_NATIVE_INCLUDE_NONE
|
||||
-DVIDEO_IN
|
||||
+14
-5
@@ -82,6 +82,7 @@ static void reload_shader(unsigned int i) {
|
||||
shaders_update(&program, &project.fragment_shaders[i][0], i, &project);
|
||||
}
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
static void init_inputs(const StringArray *video_in, unsigned int video_size) {
|
||||
inputs.length = video_in->length;
|
||||
|
||||
@@ -97,7 +98,6 @@ static bool start_video_captures(unsigned int video_count, bool trace_fps) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ static void free_video_captures(unsigned int video_count) {
|
||||
video_free(&inputs.values[i]);
|
||||
}
|
||||
}
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
static void error_callback(int error, const char *description) {
|
||||
log_error("[GLFW] %d: %s", error, description);
|
||||
@@ -177,13 +178,15 @@ void forge_run(const Parameters *params) {
|
||||
return;
|
||||
}
|
||||
|
||||
init_inputs(¶ms->video_in, params->video_size);
|
||||
|
||||
init_context(params, project.in_count);
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
init_inputs(¶ms->video_in, params->video_size);
|
||||
|
||||
if (!start_video_captures(params->video_in.length, params->trace_fps)) {
|
||||
return;
|
||||
}
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
midi_open(&midi, config_file_get_str(&project.config, "MIDI_HW", "hw"));
|
||||
|
||||
@@ -211,7 +214,7 @@ void forge_run(const Parameters *params) {
|
||||
|
||||
window_use(window_output, context);
|
||||
|
||||
shaders_init(&program, &project, context, &inputs, false);
|
||||
shaders_init(&program, &project, context, false);
|
||||
} else {
|
||||
window_output = NULL;
|
||||
}
|
||||
@@ -223,11 +226,15 @@ void forge_run(const Parameters *params) {
|
||||
|
||||
window_use(window_monitor, context);
|
||||
|
||||
shaders_init(&program, &project, context, &inputs, window_output != NULL);
|
||||
shaders_init(&program, &project, context, window_output != NULL);
|
||||
} else {
|
||||
window_monitor = NULL;
|
||||
}
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
shaders_link_inputs(&program, &project, &inputs);
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
if (program.error) {
|
||||
context->stop = true;
|
||||
window_terminate();
|
||||
@@ -263,7 +270,9 @@ void forge_run(const Parameters *params) {
|
||||
shaders_free_window(&program, params->output);
|
||||
}
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
free_video_captures(params->video_in.length);
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
free_context();
|
||||
|
||||
|
||||
+10
-8
@@ -534,8 +534,7 @@ static void use_program(const ShaderProgram *program, int i, bool output,
|
||||
}
|
||||
|
||||
void shaders_init(ShaderProgram *program, const Project *project,
|
||||
const SharedContext *context, VideoCaptureArray *inputs,
|
||||
bool rebind) {
|
||||
const SharedContext *context, bool rebind) {
|
||||
if (!rebind) {
|
||||
program->error = false;
|
||||
program->last_resolution[0] = context->resolution[0];
|
||||
@@ -571,12 +570,6 @@ void shaders_init(ShaderProgram *program, const Project *project,
|
||||
return;
|
||||
}
|
||||
|
||||
init_input(program, &project->config, inputs);
|
||||
|
||||
if (check_glerror(program)) {
|
||||
return;
|
||||
}
|
||||
|
||||
init_framebuffers(program, &project->config);
|
||||
|
||||
if (check_glerror(program)) {
|
||||
@@ -603,6 +596,15 @@ void shaders_init(ShaderProgram *program, const Project *project,
|
||||
}
|
||||
}
|
||||
|
||||
void shaders_link_inputs(ShaderProgram *program, const Project *project,
|
||||
VideoCaptureArray *inputs) {
|
||||
init_input(program, &project->config, inputs);
|
||||
|
||||
if (check_glerror(program)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void shaders_update(ShaderProgram *program, const File *fragment_shader,
|
||||
unsigned int i, const Project *project) {
|
||||
bool result;
|
||||
|
||||
+4
-2
@@ -4,8 +4,10 @@
|
||||
#define SHADERS_H
|
||||
|
||||
void shaders_init(ShaderProgram *program, const Project *project,
|
||||
const SharedContext *context, VideoCaptureArray *inputs,
|
||||
bool rebind);
|
||||
const SharedContext *context, bool rebind);
|
||||
|
||||
void shaders_link_inputs(ShaderProgram *program, const Project *project,
|
||||
VideoCaptureArray *inputs);
|
||||
|
||||
void shaders_update(ShaderProgram *program, const File *fragment_shader,
|
||||
unsigned int i, const Project *project);
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
#include <glad/gl.h>
|
||||
#include <hashmap.h>
|
||||
#include <linmath.h>
|
||||
#ifdef VIDEO_IN
|
||||
#include <linux/videodev2.h>
|
||||
#else
|
||||
struct v4l2_buffer {};
|
||||
#endif /* VIDEO_IN */
|
||||
#include <stdbool.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
+5
-1
@@ -1,3 +1,5 @@
|
||||
#ifdef VIDEO_IN
|
||||
|
||||
#include <bsd/string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -373,4 +375,6 @@ void video_free(const VideoCapture *video_capture) {
|
||||
if (video_capture->fd != -1) {
|
||||
close(video_capture->fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* VIDEO_IN */
|
||||
Reference in New Issue
Block a user