]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve driver header
authorfennecdjay <astor.jeremie@wanadoo.fr>
Tue, 5 Mar 2019 23:32:35 +0000 (00:32 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Tue, 5 Mar 2019 23:32:35 +0000 (00:32 +0100)
include/driver.h
include/plug.h
src/gwion.c
src/plug.c

index 758d0bf37ac3ac24d829cebe8cc60b780eb9d157..e5e6509b409855630dee09083a6232f5d2892147 100644 (file)
@@ -1,57 +1,22 @@
 #ifndef __DRIVER
 #define __DRIVER
-typedef struct driver_wrapper* Driver_;
-typedef struct containing_driver_info {
-  uint8_t in, out;
+
+struct _driver;
+typedef struct DriverInfo_ {
   uint32_t   sr;
   m_str arg;
-  void (*func)(Driver_);
+  void (*func)(struct _driver*);
   void (*run)(const VM*);
   void* data;
+  uint8_t in, out;
 } DriverInfo;
 
-
-typedef struct driver_wrapper {
-  m_bool (*ini)(VM* vm, DriverInfo* info);
-  void   (*run)(VM* vm, DriverInfo* info);
-  void   (*del)(VM* vm, DriverInfo* info);
+typedef struct _driver {
+  m_bool (*ini)(VM* vm, DriverInfo*);
+  void   (*run)(VM* vm, struct DriverInfo_*);
+  void   (*del)(VM* vm, struct DriverInfo_*);
 } Driver;
 
-extern void select_driver(DriverInfo* di, const m_str d);
-extern void select_backend(DriverInfo* di, const m_str d);
-extern void select_format(DriverInfo* di, const m_str d);
-
-void dummy_driver(Driver* d);
-#ifdef HAVE_SPA
-void spa_driver(Driver* d);
-#endif
-#ifdef HAVE_SNDFILE
-void sndfile_driver(Driver* d);
-#endif
-void silent_driver(Driver* d);
-#ifdef HAVE_ALSA
-void alsa_driver(Driver* d);
-#include <alsa/asoundlib.h>
-#endif
-#ifdef HAVE_JACK
-void jack_driver(Driver* d);
-#endif
-#ifdef HAVE_SOUNDIO
-#include <soundio/soundio.h>
-void sio_driver(Driver* d);
-#endif
-#ifdef HAVE_PORTAUDIO
-void pa_driver(Driver* d);
-#include <portaudio.h>
-#endif
-#ifdef HAVE_PULSE
-void pulse_driver(Driver* d);
-#endif
-#ifdef HAVE_PLOT
-void plot_driver(Driver* d);
-#endif
-#ifdef HAVE_SLES
-void sles_driver(Driver* d);
-#endif
-ANN struct BBQ_* new_bbq(DriverInfo* di);
+void dummy_driver(Driver*);
+ANN struct BBQ_* new_bbq(DriverInfo*);
 #endif
index 2bebfc8f360b480657e0013ca40947ab62018ba0..4d11d435359a34ee9c3abf8603fb88844efe18c4 100644 (file)
@@ -8,7 +8,6 @@ enum plug_t {
   GWPLUG_LAST
 };
 
-//typedef struct Vector_ PlugInfo[GWPLUG_LAST];
 typedef struct {
   struct Vector_ vec[GWPLUG_LAST];
   struct Map_ drv;
@@ -24,7 +23,7 @@ void plug_end(const Gwion gwion);
 #define GWMODSTR(a) m_str GWMODSTR_NAME() { return #a; }
 #define GWMODINI(a)  ANN void* GWMODINI_NAME(const Gwion gwion, const Vector args)
 #define GWMODEND(a)  ANN void  GWMODEND_NAME(const Gwion gwion, void* self)
-#define GWDRIVER(a)  ANN void  GWDRIVER_NAME(struct driver_wrapper* d)
+#define GWDRIVER(a)  ANN void  GWDRIVER_NAME(struct _driver* d)
 
 ANN void plug_ini(const Gwion gwion, const Vector);
 ANN Vector split_args(const m_str str);
index 82cc492d37e97b22e7ee2d247ab8a9d560176478..014803db5922f52286e273afc9e11759e37553d9 100644 (file)
@@ -37,14 +37,13 @@ ANN void gwion_init(const Gwion gwion, const Vector args) {
 }
 
 ANN m_bool gwion_audio(const Gwion gwion, DriverInfo* di) {
-  di->func = dummy_driver;
   // get driver from string.
   if(di->arg) {
     for(m_uint i = 0; i < map_size(&gwion->plug->drv); ++i) {
       const m_str name = (m_str)VKEY(&gwion->plug->drv, i);
       const size_t len = strlen(name);
       if(!strncmp(name, di->arg, len)) {
-        di->func = (void (*)(struct driver_wrapper *))VVAL(&gwion->plug->drv, i);
+        di->func = (void (*)(struct _driver*))VVAL(&gwion->plug->drv, i);
         break;
       }
     }
index e1c2e2960f1a45cf2110fb56236bac25dd64531c..9259b8894c05b9c85efd5f8eec683d64f9baee72 100644 (file)
@@ -22,7 +22,7 @@ typedef m_str  (*modstr)(void);
 typedef void*  (*modini)(const Gwion, const Vector);
 typedef void*  (*modend)(const Gwion, void*);
 typedef void*  (*modend)(const Gwion, void*);
-typedef void   (*driver)(struct driver_wrapper*);
+typedef void   (*driver)(struct _driver*);
 struct Plug_ {
   m_str name;
   modini ini;