grz0zrg / fas

C Pixels-based graphical audio synthesizer implemented as a WebSocket server
https://www.fsynth.com
BSD 2-Clause "Simplified" License
131 stars 10 forks source link

liblfds version ? #4

Closed simdax closed 4 years ago

simdax commented 5 years ago

Hello,

In the doc, it is said that we have to clone liblfds711, but it seems that liblfds720 is needed. Unhopefully, liblfds's last version seems to be 711. And the error log discourages me simply trying to rename the thing

In file included from main.c:45:
fas.h:45:43: error: field ‘fe’ has incomplete type
         struct lfds720_freelist_n_element fe;
                                           ^~
fas.h:144:10: warning: ISO C forbids forward references to ‘enum’ types [-Wpedantic]
     enum lfds720_misc_flag overwrite_occurred_flag;
          ^~~~~~~~~~~~~~~~~
fas.h:161:106: warning: ISO C forbids forward references to ‘enum’ types [-Wpedantic]
     void rb_element_cleanup_callback(struct lfds720_ringbuffer_n_state *rs, void *key, void *value, enum lfds720_misc_flag unread_flag) {
                                                                                                          ^~~~~~~~~~~~~~~~~
fas.h:161:124: error: parameter 4 (‘unread_flag’) has incomplete type
     void rb_element_cleanup_callback(struct lfds720_ringbuffer_n_state *rs, void *key, void *value, enum lfds720_misc_flag unread_flag) {
                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from main.c:45:
fas.h: In function ‘rb_element_cleanup_callback’:
fas.h:162:28: error: ‘LFDS720_MISC_FLAG_RAISED’ undeclared (first use in this function); did you mean ‘LFDS711_MISC_FLAG_RAISED’?
         if (unread_flag == LFDS720_MISC_FLAG_RAISED) {
                            ^~~~~~~~~~~~~~~~~~~~~~~~
                            LFDS711_MISC_FLAG_RAISED
fas.h:162:28: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function ‘flf_element_cleanup_callback’:
main.c:52:28: warning: implicit declaration of function ‘LFDS720_FREELIST_N_GET_VALUE_FROM_ELEMENT’; did you mean ‘LFDS711_FREELIST_GET_VALUE_FROM_ELEMENT’? [-Wimplicit-function-declaration]
     freelist_frames_data = LFDS720_FREELIST_N_GET_VALUE_FROM_ELEMENT(*fe);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            LFDS711_FREELIST_GET_VALUE_FROM_ELEMENT
main.c:52:70: error: dereferencing pointer to incomplete type ‘struct lfds720_freelist_n_element’
     freelist_frames_data = LFDS720_FREELIST_N_GET_VALUE_FROM_ELEMENT(*fe);
                                                                      ^~~
main.c: In function ‘paCallback’:
main.c:83:5: error: ‘LFDS720_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_PHYSICAL_CORE’ undeclared (first use in this function); did you mean ‘LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE’?
     LFDS720_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_PHYSICAL_CORE;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE
main.c:90:9: warning: implicit declaration of function ‘lfds720_queue_bss_dequeue’; did you mean ‘lfds711_queue_bss_dequeue’? [-Wimplicit-function-declaration]
     if (lfds720_queue_bss_dequeue(&synth_commands_queue_state, NULL, &queue_synth_void) == 1) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~
         lfds711_queue_bss_dequeue
main.c:557:27: warning: implicit declaration of function ‘lfds720_ringbuffer_n_read’; did you mean ‘lfds711_ringbuffer_read’? [-Wimplicit-function-declaration]
             read_status = lfds720_ringbuffer_n_read(&rs, &key, NULL);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~
                           lfds711_ringbuffer_read
main.c:564:21: warning: implicit declaration of function ‘LFDS720_FREELIST_N_SET_VALUE_IN_ELEMENT’; did you mean ‘LFDS711_FREELIST_SET_VALUE_IN_ELEMENT’? [-Wimplicit-function-declaration]
                     LFDS720_FREELIST_N_SET_VALUE_IN_ELEMENT(curr_freelist_frames_data->fe, curr_freelist_frames_data);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     LFDS711_FREELIST_SET_VALUE_IN_ELEMENT
main.c:565:21: warning: implicit declaration of function ‘lfds720_freelist_n_threadsafe_push’; did you mean ‘lfds711_freelist_push’? [-Wimplicit-function-declaration]
                     lfds720_freelist_n_threadsafe_push(&freelist_frames, NULL, &curr_freelist_frames_data->fe);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     lfds711_freelist_push
main.c: In function ‘setHeight’:
main.c:758:12: warning: implicit declaration of function ‘lfds720_freelist_n_threadsafe_pop’; did you mean ‘lfds711_freelist_pop’? [-Wimplicit-function-declaration]
     while (lfds720_freelist_n_threadsafe_pop(&freelist_frames, NULL, &fe)) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            lfds711_freelist_pop
main.c: In function ‘ws_callback’:
main.c:933:5: error: ‘LFDS720_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_PHYSICAL_CORE’ undeclared (first use in this function); did you mean ‘LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE’?
     LFDS720_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_PHYSICAL_CORE;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE
main.c:1169:25: warning: implicit declaration of function ‘lfds720_queue_bss_enqueue’; did you mean ‘lfds711_queue_bss_enqueue’? [-Wimplicit-function-declaration]
                     if (lfds720_queue_bss_enqueue(&synth_commands_queue_state, NULL, (void *)usd->synth) == 0) {
                         ^~~~~~~~~~~~~~~~~~~~~~~~~
                         lfds711_queue_bss_enqueue
main.c:1214:5: error: unknown type name ‘lfds720_pal_uint_t’; did you mean ‘lfds711_pal_uint_t’?
     lfds720_pal_uint_t frames_data_freelist_count;
     ^~~~~~~~~~~~~~~~~~
     lfds711_pal_uint_t
main.c:1215:5: warning: implicit declaration of function ‘lfds720_freelist_n_query’; did you mean ‘lfds711_freelist_query’? [-Wimplicit-function-declaration]
     lfds720_freelist_n_query(&freelist_frames, LFDS720_FREELIST_N_QUERY_SINGLETHREADED_GET_COUNT, NULL, (void *)&frames_data_freelist_count);
     ^~~~~~~~~~~~~~~~~~~~~~~~
     lfds711_freelist_query
main.c:1215:48: error: ‘LFDS720_FREELIST_N_QUERY_SINGLETHREADED_GET_COUNT’ undeclared (first use in this function); did you mean ‘LFDS711_FREELIST_QUERY_SINGLETHREADED_GET_COUNT’?
     lfds720_freelist_n_query(&freelist_frames, LFDS720_FREELIST_N_QUERY_SINGLETHREADED_GET_COUNT, NULL, (void *)&frames_data_freelist_count);
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                LFDS711_FREELIST_QUERY_SINGLETHREADED_GET_COUNT
main.c:1281:21: warning: implicit declaration of function ‘lfds720_ringbuffer_n_write’; did you mean ‘lfds711_ringbuffer_write’? [-Wimplicit-function-declaration]
                     lfds720_ringbuffer_n_write(&rs, (void *) (lfds720_pal_uint_t) freelist_frames_data, NULL, &overwrite_occurred_flag, (void *)&overwritten_notes, NULL);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
                     lfds711_ringbuffer_write
main.c:1281:63: error: ‘lfds720_pal_uint_t’ undeclared (first use in this function); did you mean ‘lfds711_pal_uint_t’?
                     lfds720_ringbuffer_n_write(&rs, (void *) (lfds720_pal_uint_t) freelist_frames_data, NULL, &overwrite_occurred_flag, (void *)&overwritten_notes, NULL);
                                                               ^~~~~~~~~~~~~~~~~~
                                                               lfds711_pal_uint_t
main.c:1281:82: error: expected ‘)’ before ‘freelist_frames_data’
                     lfds720_ringbuffer_n_write(&rs, (void *) (lfds720_pal_uint_t) freelist_frames_data, NULL, &overwrite_occurred_flag, (void *)&overwritten_notes, NULL);
                                                                                  ^~~~~~~~~~~~~~~~~~~~~
                                                                                  )
main.c:1282:52: error: ‘LFDS720_MISC_FLAG_RAISED’ undeclared (first use in this function); did you mean ‘LFDS711_MISC_FLAG_RAISED’?
                     if (overwrite_occurred_flag == LFDS720_MISC_FLAG_RAISED) {
                                                    ^~~~~~~~~~~~~~~~~~~~~~~~
                                                    LFDS711_MISC_FLAG_RAISED
main.c:1282:21: error: ‘overwrite_occurred_flag’ has an incomplete type ‘enum lfds720_misc_flag’
                     if (overwrite_occurred_flag == LFDS720_MISC_FLAG_RAISED) {
                     ^~
main.c: In function ‘main’:
main.c:2046:9: warning: implicit declaration of function ‘PaAlsa_EnableRealtimeScheduling’ [-Wimplicit-function-declaration]
         PaAlsa_EnableRealtimeScheduling(&stream, fas_realtime);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:2077:23: error: ‘LFDS720_PAL_ATOMIC_ISOLATION_LENGTH_IN_BYTES’ undeclared (first use in this function); did you mean ‘LFDS711_PAL_ATOMIC_ISOLATION_IN_BYTES’?
         aligned_alloc(LFDS720_PAL_ATOMIC_ISOLATION_LENGTH_IN_BYTES, sizeof(struct lfds720_ringbuffer_n_element) * (fas_frames_queue_size + 1));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       LFDS711_PAL_ATOMIC_ISOLATION_IN_BYTES
main.c:2077:76: error: invalid application of ‘sizeof’ to incomplete type ‘struct lfds720_ringbuffer_n_element’
         aligned_alloc(LFDS720_PAL_ATOMIC_ISOLATION_LENGTH_IN_BYTES, sizeof(struct lfds720_ringbuffer_n_element) * (fas_frames_queue_size + 1));
                                                                            ^~~~~~
main.c:2080:76: error: invalid application of ‘sizeof’ to incomplete type ‘struct lfds720_queue_bss_element’
         aligned_alloc(LFDS720_PAL_ATOMIC_ISOLATION_LENGTH_IN_BYTES, sizeof(struct lfds720_queue_bss_element) * fas_commands_queue_size);
                                                                            ^~~~~~
main.c:2094:5: warning: implicit declaration of function ‘lfds720_ringbuffer_n_init_valid_on_current_logical_core’; did you mean ‘lfds711_ringbuffer_init_valid_on_current_logical_core’? [-Wimplicit-function-declaration]
     lfds720_ringbuffer_n_init_valid_on_current_logical_core(&rs, re, (fas_frames_queue_size + 1), NULL);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     lfds711_ringbuffer_init_valid_on_current_logical_core
main.c:2095:5: warning: implicit declaration of function ‘lfds720_queue_bss_init_valid_on_current_logical_core’; did you mean ‘lfds711_queue_bss_init_valid_on_current_logical_core’? [-Wimplicit-function-declaration]
     lfds720_queue_bss_init_valid_on_current_logical_core(&synth_commands_queue_state, synth_commands_queue_element, fas_commands_queue_size, NULL);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     lfds711_queue_bss_init_valid_on_current_logical_core
main.c:2096:5: warning: implicit declaration of function ‘lfds720_freelist_n_init_valid_on_current_logical_core’; did you mean ‘lfds711_freelist_init_valid_on_current_logical_core’? [-Wimplicit-function-declaration]
     lfds720_freelist_n_init_valid_on_current_logical_core(&freelist_frames, NULL);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     lfds711_freelist_init_valid_on_current_logical_core
main.c:2168:9: warning: implicit declaration of function ‘lfds720_ringbuffer_n_cleanup’; did you mean ‘lfds711_ringbuffer_cleanup’? [-Wimplicit-function-declaration]
         lfds720_ringbuffer_n_cleanup(&rs, rb_element_cleanup_callback);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         lfds711_ringbuffer_cleanup
main.c:2172:5: warning: implicit declaration of function ‘lfds720_freelist_n_cleanup’; did you mean ‘lfds711_freelist_cleanup’? [-Wimplicit-function-declaration]
     lfds720_freelist_n_cleanup(&freelist_frames, flf_element_cleanup_callback);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
     lfds711_freelist_cleanup
main.c:2179:9: warning: implicit declaration of function ‘lfds720_queue_bss_cleanup’; did you mean ‘lfds711_queue_bss_cleanup’? [-Wimplicit-function-declaration]
         lfds720_queue_bss_cleanup(&synth_commands_queue_state, q_element_cleanup_callback);
         ^~~~~~~~~~~~~~~~~~~~~~~~~
         lfds711_queue_bss_cleanup
In file included from main.c:45:
main.c: At top level:
fas.h:144:28: error: storage size of ‘overwrite_occurred_flag’ isn’t known
     enum lfds720_misc_flag overwrite_occurred_flag;
                            ^~~~~~~~~~~~~~~~~~~~~~~
fas.h:146:39: error: storage size of ‘rs’ isn’t known
     struct lfds720_ringbuffer_n_state rs; // frames related data structure
                                       ^~
fas.h:147:36: error: storage size of ‘synth_commands_queue_state’ isn’t known
     struct lfds720_queue_bss_state synth_commands_queue_state;
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
fas.h:148:37: error: storage size of ‘freelist_frames’ isn’t known
     struct lfds720_freelist_n_state freelist_frames;
                                     ^~~~~~~~~~~~~~~
make: *** [Makefile:29: all] Error 1
grz0zrg commented 5 years ago

Hello,

sorry for the long delay, i actually didn't watch the repository so i didn't get notified.

Here is a compatibility layer which should work :

// compatibility layer for liblfds 711 version
#ifdef LFDS711
    #include "liblfds711.h"

    #define lfds720_freelist_n_element lfds711_freelist_element
    #define lfds720_ringbuffer_n_element lfds711_ringbuffer_element
    #define lfds720_ringbuffer_n_state lfds711_ringbuffer_state
    #define lfds720_freelist_n_state lfds711_freelist_state
    #define LFDS720_PAL_ATOMIC_ISOLATION_LENGTH_IN_BYTES LFDS711_PAL_ATOMIC_ISOLATION_IN_BYTES
    #define lfds720_ringbuffer_n_init_valid_on_current_logical_core lfds711_ringbuffer_init_valid_on_current_logical_core
    #define lfds720_freelist_n_init_valid_on_current_logical_core lfds711_freelist_init_valid_on_current_logical_core
    #define LFDS720_FREELIST_N_SET_VALUE_IN_ELEMENT LFDS711_FREELIST_SET_VALUE_IN_ELEMENT
    #define LFDS720_FREELIST_N_GET_VALUE_FROM_ELEMENT LFDS711_FREELIST_GET_VALUE_FROM_ELEMENT
    #define lfds720_freelist_n_threadsafe_push lfds711_freelist_push
    #define lfds720_freelist_n_threadsafe_pop lfds711_freelist_pop
    #define lfds720_ringbuffer_n_cleanup lfds711_ringbuffer_cleanup
    #define lfds720_freelist_n_cleanup lfds711_freelist_cleanup
    #define lfds720_ringbuffer_n_read lfds711_ringbuffer_read
    #define lfds720_ringbuffer_n_write lfds711_ringbuffer_write
    #define lfds720_misc_flag lfds711_misc_flag
    #define LFDS720_MISC_FLAG_RAISED LFDS711_MISC_FLAG_RAISED
    #define LFDS720_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_PHYSICAL_CORE LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE
    #define lfds720_pal_uint_t lfds711_pal_uint_t
#else
    #include "liblfds720.h"
#endif

I will see to provide a liblfds711 compatible layer if that doesn't work.

simdax commented 5 years ago

hmmm seems not working, due to some discrepancies between 720_n_thing that transpiles to 711_thing. At the end I have :

 $ make
gcc main.c tools.c samples.c grains.c oscillators.c wavetables.c note.c usage.c lib/lodepng.c lib/Yin.c filters.c -I lo -I inc -I inc/portaudio -I inc/soundpipe -g -DDEBUG -std=c11 -pedantic -D_POSIX_SOURCE -DALSA_RT -DLFDS711 -llfds -lportaudio -lsamplerate -lwebsockets -lrt -lm -lasound -ljack -pthread -lsndfile -o fas
main.c: In function ‘paCallback’:
main.c:565:80: warning: passing argument 3 of ‘lfds711_freelist_push’ from incompatible pointer type [-Wincompatible-pointer-types]
                     lfds720_freelist_n_threadsafe_push(&freelist_frames, NULL, &curr_freelist_frames_data->fe);
                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from inc/liblfds711.h:19,
                 from fas.h:26,
                 from main.c:45:
inc/liblfds711/lfds711_freelist.h:60:66: note: expected ‘struct lfds711_prng_st_state *’ but argument is of type ‘struct lfds711_freelist_element *’
                                    struct lfds711_prng_st_state *psts );
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
main.c:728:84: warning: passing argument 3 of ‘lfds711_freelist_push’ from incompatible pointer type [-Wincompatible-pointer-types]
                         lfds720_freelist_n_threadsafe_push(&freelist_frames, NULL, &curr_freelist_frames_data->fe);
                                                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from inc/liblfds711.h:19,
                 from fas.h:26,
                 from main.c:45:
inc/liblfds711/lfds711_freelist.h:60:66: note: expected ‘struct lfds711_prng_st_state *’ but argument is of type ‘struct lfds711_freelist_element *’
                                    struct lfds711_prng_st_state *psts );
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
main.c: In function ‘setHeight’:
main.c:758:70: warning: passing argument 3 of ‘lfds711_freelist_pop’ from incompatible pointer type [-Wincompatible-pointer-types]
     while (lfds720_freelist_n_threadsafe_pop(&freelist_frames, NULL, &fe)) {
                                                                      ^~~
In file included from inc/liblfds711.h:19,
                 from fas.h:26,
                 from main.c:45:
inc/liblfds711/lfds711_freelist.h:64:57: note: expected ‘struct lfds711_prng_st_state *’ but argument is of type ‘struct lfds711_freelist_element **’
                           struct lfds711_prng_st_state *psts );
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
main.c:770:68: warning: passing argument 3 of ‘lfds711_freelist_push’ from incompatible pointer type [-Wincompatible-pointer-types]
         lfds720_freelist_n_threadsafe_push(&freelist_frames, NULL, &ffd[i].fe);
                                                                    ^~~~~~~~~~
In file included from inc/liblfds711.h:19,
                 from fas.h:26,
                 from main.c:45:
inc/liblfds711/lfds711_freelist.h:60:66: note: expected ‘struct lfds711_prng_st_state *’ but argument is of type ‘struct lfds711_freelist_element *’
                                    struct lfds711_prng_st_state *psts );
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
main.c: In function ‘clearQueues’:
main.c:840:68: warning: passing argument 3 of ‘lfds711_freelist_push’ from incompatible pointer type [-Wincompatible-pointer-types]
         lfds720_freelist_n_threadsafe_push(&freelist_frames, NULL, &freelist_frames_data->fe);
                                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from inc/liblfds711.h:19,
                 from fas.h:26,
                 from main.c:45:
inc/liblfds711/lfds711_freelist.h:60:66: note: expected ‘struct lfds711_prng_st_state *’ but argument is of type ‘struct lfds711_freelist_element *’

The most simple way would be : how to get the libflds720 or why not shipping it in the repo ?

grz0zrg commented 5 years ago

Some function signature changed a bit, the last two arguments of the function must be swapped.

libflds720 is not yet released, the version i have is an incomplete draft which was packaged by the library author upon request because ARM64 support was needed.

An alternative for now would be to clone the repository just before the merge of the ARM64 branch, head is just 2 commits away and it is mostly conveniences stuff although the latest commit fix an important bug : https://github.com/grz0zrg/fas/tree/77ef94f21eaacdf8863600a1ace8b12e8743ce5f

grz0zrg commented 4 years ago

Compat. layer for liblfds720 -> liblfds711 was added. FAS now use liblfds711 by default (until liblfds720 is released)