Commit 2bdec3d05deab8bcdf0bf95168dd4cbd580387b2

Thomas de Grivel 2022-03-16T20:25:57

fix compilation with new clang

diff --git a/.gitignore b/.gitignore
index 5e039ad..4514d59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,19 +1,11 @@
+.deps/
 .libs/
 config.mk
 /cli/rtbuf
 /gtk3/rtbuf-gtk3
 /gtk3/rtbuf_gtk3_resources.c
-/lib/music_type
-/lib/music_type.h
-/lib/portaudio_type
-/lib/portaudio_type.h
-/lib/reverb_type
-/lib/reverb_type.h
-/lib/signal_type
-/lib/signal_type.h
-/lib/sndio_type
-/lib/sndio_type.h
-/lib/synth_type
-/lib/synth_type.h
+/lib/*_type
+/lib/*_type.h
+/lib/.*.log
 *.la
 *.lo
diff --git a/lib/.lib.portaudio.config.log b/lib/.lib.portaudio.config.log
deleted file mode 100644
index 565966a..0000000
--- a/lib/.lib.portaudio.config.log
+++ /dev/null
@@ -1 +0,0 @@
-cc -DGL_SILENCE_DEPRECATION=1 -DNDEBUG -O3 -W -Wall -Werror -std=c89 -pedantic -I/opt/homebrew/Cellar/portaudio/19.7.0/include ./portaudio/config.c -o /dev/null -L/opt/homebrew/Cellar/portaudio/19.7.0/lib -lportaudio -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices
diff --git a/lib/.lib.sndio.config.log b/lib/.lib.sndio.config.log
deleted file mode 100644
index 04b5090..0000000
--- a/lib/.lib.sndio.config.log
+++ /dev/null
@@ -1,52 +0,0 @@
-./sndio/config.c:1:10: error: 'sndio.h' file not found with <angled> include; use "quotes" instead
-#include <sndio.h>
-         ^~~~~~~~~
-         "sndio.h"
-In file included from ./sndio/config.c:1:
-./sndio/sndio.h:19:10: error: 'sndio.h' file not found with <angled> include; use "quotes" instead
-#include <sndio.h>
-         ^~~~~~~~~
-         "sndio.h"
-./sndio/sndio.h:22:28: error: declaration of 'struct sio_par' will not be visible outside of this function [-Werror,-Wvisibility]
-void print_sio_par (struct sio_par *par);
-                           ^
-./sndio/sndio.h:35:52: error: use of undeclared identifier 'RTBUF_SIGNAL_SAMPLES'
-typedef t_rtbuf_sndio_sample t_rtbuf_sndio_samples[RTBUF_SNDIO_SAMPLES];
-                                                   ^
-./sndio/sndio.h:32:27: note: expanded from macro 'RTBUF_SNDIO_SAMPLES'
-  (RTBUF_SNDIO_CHANNELS * RTBUF_SIGNAL_SAMPLES)
-                          ^
-./sndio/sndio.h:39:3: error: unknown type name 't_rtbuf_signal'
-  t_rtbuf_signal signal[RTBUF_SNDIO_CHANNELS];
-  ^
-./sndio/sndio.h:44:24: error: unknown type name 's_rtbuf'
-int rtbuf_sndio_input (s_rtbuf *rtb);
-                       ^
-./sndio/sndio.h:45:30: error: unknown type name 's_rtbuf'
-int rtbuf_sndio_input_start (s_rtbuf *rtb);
-                             ^
-./sndio/sndio.h:46:29: error: unknown type name 's_rtbuf'
-int rtbuf_sndio_input_stop (s_rtbuf *rtb);
-                            ^
-./sndio/sndio.h:50:18: error: field has incomplete type 'struct sio_par'
-  struct sio_par want;
-                 ^
-./sndio/sndio.h:50:10: note: forward declaration of 'struct sio_par'
-  struct sio_par want;
-         ^
-./sndio/sndio.h:51:18: error: field has incomplete type 'struct sio_par'
-  struct sio_par have;
-                 ^
-./sndio/sndio.h:50:10: note: forward declaration of 'struct sio_par'
-  struct sio_par want;
-         ^
-./sndio/sndio.h:64:25: error: unknown type name 's_rtbuf'
-int rtbuf_sndio_output (s_rtbuf *rtb);
-                        ^
-./sndio/sndio.h:65:31: error: unknown type name 's_rtbuf'
-int rtbuf_sndio_output_start (s_rtbuf *rtb);
-                              ^
-./sndio/sndio.h:66:30: error: unknown type name 's_rtbuf'
-int rtbuf_sndio_output_stop (s_rtbuf *rtb);
-                             ^
-13 errors generated.
diff --git a/lib/glfw3/keyboard.c b/lib/glfw3/keyboard.c
index ca22ce6..324b4a5 100644
--- a/lib/glfw3/keyboard.c
+++ b/lib/glfw3/keyboard.c
@@ -41,7 +41,6 @@ int rtbuf_lib_init (s_rtbuf_lib *lib)
 {
   (void) lib;
   rtbuf_music_init();
-  glfwInitHint(GLFW_COCOA_MENUBAR, GLFW_TRUE);
   if (!glfwInit()) {
     const char* description;
     int code = glfwGetError(&description);
@@ -241,8 +240,10 @@ void rtbuf_glfw3_keyboard_close (GLFWwindow *window)
 GLFWwindow * rtbuf_glfw3_keyboard_window (s_rtbuf *rtb)
 {
   GLFWwindow *window;
-  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
-  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
+  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
+  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
   window = glfwCreateWindow(RTBUF_GLFW3_KEYBOARD_WIDTH,
                             RTBUF_GLFW3_KEYBOARD_HEIGHT,
                             "rtbuf_glfw3_keyboard",
diff --git a/lib/portaudio/.lib.portaudio.config.log b/lib/portaudio/.lib.portaudio.config.log
deleted file mode 100644
index ea82422..0000000
--- a/lib/portaudio/.lib.portaudio.config.log
+++ /dev/null
@@ -1 +0,0 @@
-cc -DGL_SILENCE_DEPRECATION=1 -DNDEBUG -O3 -W -Wall -Werror -std=c89 -pedantic -I/opt/homebrew/Cellar/portaudio/19.7.0/include ./../portaudio/config.c -o /dev/null -L/opt/homebrew/Cellar/portaudio/19.7.0/lib -lportaudio -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices
diff --git a/lib/portaudio/input.c b/lib/portaudio/input.c
index 1bd73b1..cd94689 100644
--- a/lib/portaudio/input.c
+++ b/lib/portaudio/input.c
@@ -42,8 +42,9 @@ int rtbuf_portaudio_input (s_rtbuf *rtb)
 int rtbuf_portaudio_input_start (s_rtbuf *rtb)
 {
   s_rtbuf_portaudio_input_data *data;
-  assert(rtb->proc->out_bytes == sizeof(*data));
-  data = (s_rtbuf_portaudio_input_data*) rtb->data;
+  if (rtb->proc->out_bytes < sizeof(*data))
+    return 1;
+  /* data = (s_rtbuf_portaudio_input_data*) rtb->data; */
   return 0;
 }
 
diff --git a/lib/synth/synth.c b/lib/synth/synth.c
index 23fd17b..bcd6220 100644
--- a/lib/synth/synth.c
+++ b/lib/synth/synth.c
@@ -256,8 +256,9 @@ int rtbuf_synth_synth (s_rtbuf *rtb)
 int rtbuf_synth_synth_start (s_rtbuf *rtb)
 {
   s_rtbuf_synth_synth_data *data;
-  assert(rtb->proc->out_bytes == sizeof(*data));
-  data = (s_rtbuf_synth_synth_data*) rtb->data;
+  if (rtb->proc->out_bytes < sizeof(*data))
+    return 1;
+  /* data = (s_rtbuf_synth_synth_data*) rtb->data; */
   return 0;
 }
 
diff --git a/librtbuf/rtbuf_lib.c b/librtbuf/rtbuf_lib.c
index 40ec424..7ad9ee8 100644
--- a/librtbuf/rtbuf_lib.c
+++ b/librtbuf/rtbuf_lib.c
@@ -162,7 +162,10 @@ s_rtbuf_lib * rtbuf_lib_load (const char *name)
   }
   ver = dlsym(lib->lib, "rtbuf_lib_ver");
   /* printf("lib_load ver %lu\n", *ver); */
-  assert(*ver == RTBUF_LIB_VER);
+  if (*ver != RTBUF_LIB_VER) {
+    rtbuf_lib_delete(lib);
+    return 0;
+  }
   lib->name = symbol_intern(name);
   /* printf("lib_load name %s\n", lib->name); */
   if ((init_ptr.ptr = dlsym(lib->lib, "rtbuf_lib_init")))