Expose LADSPA functions via public API

Always compile in fluid_ladspa.h and c to that the LADSPA API functions
are always exposed, but use dummy functions that return failure (NULL,
FLUID_FAILED or FALSE) if LADSPA isn't available.
This commit is contained in:
Marcus Weseloh 2017-11-18 20:46:25 +01:00
parent 1863c618e8
commit e511992680
6 changed files with 152 additions and 12 deletions

View file

@ -104,6 +104,7 @@ extern "C" {
#include "fluidsynth/gen.h" #include "fluidsynth/gen.h"
#include "fluidsynth/voice.h" #include "fluidsynth/voice.h"
#include "fluidsynth/version.h" #include "fluidsynth/version.h"
#include "fluidsynth/ladspa.h"
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -27,6 +27,7 @@ if ( NOT MACOSX_FRAMEWORK )
audio.h audio.h
event.h event.h
gen.h gen.h
ladspa.h
log.h log.h
midi.h midi.h
misc.h misc.h

View file

@ -0,0 +1,58 @@
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/
#ifndef _FLUIDSYNTH_LADSPA_H
#define _FLUIDSYNTH_LADSPA_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _fluid_ladspa_fx_t fluid_ladspa_fx_t;
FLUIDSYNTH_API fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_ladspa_is_active(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_activate(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_deactivate(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_reset(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_check(fluid_ladspa_fx_t *fx, char *err, int err_size);
FLUIDSYNTH_API int fluid_ladspa_host_port_exists(fluid_ladspa_fx_t *fx, const char *name);
FLUIDSYNTH_API int fluid_ladspa_add_buffer(fluid_ladspa_fx_t *fx, const char *name);
FLUIDSYNTH_API int fluid_ladspa_buffer_exists(fluid_ladspa_fx_t *fx, const char *name);
FLUIDSYNTH_API int fluid_ladspa_add_effect(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *lib_name, const char *plugin_name);
FLUIDSYNTH_API int fluid_ladspa_effect_can_mix(fluid_ladspa_fx_t *fx, const char *name);
FLUIDSYNTH_API int fluid_ladspa_effect_set_mix(fluid_ladspa_fx_t *fx, const char *name, int mix, float gain);
FLUIDSYNTH_API int fluid_ladspa_effect_port_exists(fluid_ladspa_fx_t *fx, const char *effect_name, const char *port_name);
FLUIDSYNTH_API int fluid_ladspa_effect_set_control(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *port_name, float val);
FLUIDSYNTH_API int fluid_ladspa_effect_link(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *port_name, const char *name);
#ifdef __cplusplus
}
#endif
#endif /* _FLUIDSYNTH_LADSPA_H */

View file

@ -98,10 +98,6 @@ if ( LIBSNDFILE_SUPPORT )
include_directories ( ${LIBSNDFILE_INCLUDEDIR} ${LIBSNDFILE_INCLUDE_DIRS} ) include_directories ( ${LIBSNDFILE_INCLUDEDIR} ${LIBSNDFILE_INCLUDE_DIRS} )
endif ( LIBSNDFILE_SUPPORT ) endif ( LIBSNDFILE_SUPPORT )
if ( LADSPA_SUPPORT )
set ( fluid_ladspa_SOURCES bindings/fluid_ladspa.c bindings/fluid_ladspa.h )
endif ( LADSPA_SUPPORT )
if ( MIDISHARE_SUPPORT ) if ( MIDISHARE_SUPPORT )
set ( fluid_midishare_SOURCES drivers/fluid_midishare.c ) set ( fluid_midishare_SOURCES drivers/fluid_midishare.c )
include_directories ( ${MidiShare_INCLUDE_DIRS} ) include_directories ( ${MidiShare_INCLUDE_DIRS} )
@ -179,12 +175,15 @@ set ( libfluidsynth_SOURCES
bindings/fluid_cmd.c bindings/fluid_cmd.c
bindings/fluid_cmd.h bindings/fluid_cmd.h
bindings/fluid_filerenderer.c bindings/fluid_filerenderer.c
bindings/fluid_ladspa.c
bindings/fluid_ladspa.h
) )
set ( public_HEADERS set ( public_HEADERS
${CMAKE_SOURCE_DIR}/include/fluidsynth/audio.h ${CMAKE_SOURCE_DIR}/include/fluidsynth/audio.h
${CMAKE_SOURCE_DIR}/include/fluidsynth/event.h ${CMAKE_SOURCE_DIR}/include/fluidsynth/event.h
${CMAKE_SOURCE_DIR}/include/fluidsynth/gen.h ${CMAKE_SOURCE_DIR}/include/fluidsynth/gen.h
${CMAKE_SOURCE_DIR}/include/fluidsynth/ladspa.h
${CMAKE_SOURCE_DIR}/include/fluidsynth/log.h ${CMAKE_SOURCE_DIR}/include/fluidsynth/log.h
${CMAKE_SOURCE_DIR}/include/fluidsynth/midi.h ${CMAKE_SOURCE_DIR}/include/fluidsynth/midi.h
${CMAKE_SOURCE_DIR}/include/fluidsynth/misc.h ${CMAKE_SOURCE_DIR}/include/fluidsynth/misc.h
@ -236,7 +235,6 @@ add_library ( libfluidsynth
${fluid_dbus_SOURCES} ${fluid_dbus_SOURCES}
${fluid_jack_SOURCES} ${fluid_jack_SOURCES}
${fluid_lash_SOURCES} ${fluid_lash_SOURCES}
${fluid_ladspa_SOURCES}
${fluid_midishare_SOURCES} ${fluid_midishare_SOURCES}
${fluid_oss_SOURCES} ${fluid_oss_SOURCES}
${fluid_portaudio_SOURCES} ${fluid_portaudio_SOURCES}

View file

@ -25,10 +25,13 @@
* Author: Marcus Weseloh * Author: Marcus Weseloh
*/ */
#include "fluid_ladspa.h"
#include "fluid_synth.h" #include "fluid_synth.h"
#ifdef LADSPA
#include "fluidsynth_priv.h" #include "fluidsynth_priv.h"
#include "fluid_ladspa.h"
#include "fluid_sys.h" #include "fluid_sys.h"
#include <math.h> #include <math.h>
#include <ladspa.h> #include <ladspa.h>
@ -1665,3 +1668,88 @@ static FLUID_INLINE void copy_effect_to_host_buffers(fluid_ladspa_fx_t *fx, int
} }
} }
#endif /* WITH_FLOAT */ #endif /* WITH_FLOAT */
#else /* ifdef LADSPA */
/* Dummy functions to use if LADSPA is not compiled in, to keep the
* FluidSynth library ABI stable */
fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth)
{
return NULL;
}
int fluid_ladspa_is_active(fluid_ladspa_fx_t *fx)
{
return FALSE;
}
int fluid_ladspa_activate(fluid_ladspa_fx_t *fx)
{
return FLUID_FAILED;
}
int fluid_ladspa_deactivate(fluid_ladspa_fx_t *fx)
{
return FLUID_FAILED;
}
int fluid_ladspa_reset(fluid_ladspa_fx_t *fx)
{
return FLUID_FAILED;
}
int fluid_ladspa_check(fluid_ladspa_fx_t *fx, char *err, int err_size)
{
return FLUID_FAILED;
}
int fluid_ladspa_host_port_exists(fluid_ladspa_fx_t *fx, const char *name)
{
return FALSE;
}
int fluid_ladspa_add_buffer(fluid_ladspa_fx_t *fx, const char *name)
{
return FLUID_FAILED;
}
int fluid_ladspa_buffer_exists(fluid_ladspa_fx_t *fx, const char *name)
{
return FALSE;
}
int fluid_ladspa_add_effect(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *lib_name, const char *plugin_name)
{
return FLUID_FAILED;
}
int fluid_ladspa_effect_can_mix(fluid_ladspa_fx_t *fx, const char *name)
{
return FALSE;
}
int fluid_ladspa_effect_set_mix(fluid_ladspa_fx_t *fx, const char *name, int mix, float gain)
{
return FLUID_FAILED;
}
int fluid_ladspa_effect_port_exists(fluid_ladspa_fx_t *fx, const char *effect_name, const char *port_name)
{
return FALSE;
}
int fluid_ladspa_effect_set_control(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *port_name, float val)
{
return FLUID_FAILED;
}
int fluid_ladspa_effect_link(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *port_name, const char *name)
{
return FLUID_FAILED;
}
#endif /* ifdef LADSPA */

View file

@ -27,10 +27,6 @@
#include "fluid_sys.h" #include "fluid_sys.h"
#include "fluidsynth_priv.h" #include "fluidsynth_priv.h"
#ifdef LADSPA
typedef struct _fluid_ladspa_fx_t fluid_ladspa_fx_t;
fluid_ladspa_fx_t *new_fluid_ladspa_fx(fluid_real_t sample_rate, int buffer_size); fluid_ladspa_fx_t *new_fluid_ladspa_fx(fluid_real_t sample_rate, int buffer_size);
void delete_fluid_ladspa_fx(fluid_ladspa_fx_t *fx); void delete_fluid_ladspa_fx(fluid_ladspa_fx_t *fx);
fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth); fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth);
@ -62,6 +58,4 @@ int fluid_ladspa_effect_set_control(fluid_ladspa_fx_t *fx, const char *effect_na
int fluid_ladspa_effect_link(fluid_ladspa_fx_t *fx, const char *effect_name, int fluid_ladspa_effect_link(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *port_name, const char *name); const char *port_name, const char *name);
#endif /* LADSPA */
#endif /* _FLUID_LADSPA_H */ #endif /* _FLUID_LADSPA_H */