2014-10-08 02:14:12 +00:00
// This is generated file. Do not modify directly.
2018-04-18 01:57:05 +00:00
// Path to the code generator:
// tools/generate_library_loader/generate_library_loader.py .
2014-10-08 02:14:12 +00:00
# include "library_loaders/libspeechd.h"
# include <dlfcn.h>
// Put these sanity checks here so that they fire at most once
// (to avoid cluttering the build output).
2018-04-18 01:57:05 +00:00
# if !defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN ) & & \
! defined ( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
# error neither LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN nor LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED defined
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN ) & & \
defined ( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
# error both LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN and LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED defined
# endif
2018-04-18 01:57:05 +00:00
LibSpeechdLoader : : LibSpeechdLoader ( ) : loaded_ ( false ) { }
2014-10-08 02:14:12 +00:00
LibSpeechdLoader : : ~ LibSpeechdLoader ( ) {
CleanUp ( loaded_ ) ;
}
bool LibSpeechdLoader : : Load ( const std : : string & library_name ) {
if ( loaded_ )
return false ;
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
library_ = dlopen ( library_name . c_str ( ) , RTLD_LAZY ) ;
if ( ! library_ )
return false ;
# endif
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_open =
2018-04-18 01:57:05 +00:00
reinterpret_cast < decltype ( this - > spd_open ) > ( dlsym ( library_ , " spd_open " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_open = & : : spd_open ;
# endif
if ( ! spd_open ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_say =
2018-04-18 01:57:05 +00:00
reinterpret_cast < decltype ( this - > spd_say ) > ( dlsym ( library_ , " spd_say " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_say = & : : spd_say ;
# endif
if ( ! spd_say ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_stop =
2018-04-18 01:57:05 +00:00
reinterpret_cast < decltype ( this - > spd_stop ) > ( dlsym ( library_ , " spd_stop " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_stop = & : : spd_stop ;
# endif
if ( ! spd_stop ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_close =
2018-04-18 01:57:05 +00:00
reinterpret_cast < decltype ( this - > spd_close ) > ( dlsym ( library_ , " spd_close " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_close = & : : spd_close ;
# endif
if ( ! spd_close ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_pause =
2018-04-18 01:57:05 +00:00
reinterpret_cast < decltype ( this - > spd_pause ) > ( dlsym ( library_ , " spd_pause " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_pause = & : : spd_pause ;
# endif
if ( ! spd_pause ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
2018-04-18 01:57:05 +00:00
spd_resume = reinterpret_cast < decltype ( this - > spd_resume ) > (
dlsym ( library_ , " spd_resume " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_resume = & : : spd_resume ;
# endif
if ( ! spd_resume ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_notification_on =
2015-07-01 07:56:29 +00:00
reinterpret_cast < decltype ( this - > spd_set_notification_on ) > (
2014-10-08 02:14:12 +00:00
dlsym ( library_ , " spd_set_notification_on " ) ) ;
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_set_notification_on = & : : spd_set_notification_on ;
# endif
if ( ! spd_set_notification_on ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
2018-04-18 01:57:05 +00:00
spd_set_voice_rate = reinterpret_cast < decltype ( this - > spd_set_voice_rate ) > (
dlsym ( library_ , " spd_set_voice_rate " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_set_voice_rate = & : : spd_set_voice_rate ;
# endif
if ( ! spd_set_voice_rate ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
2018-04-18 01:57:05 +00:00
spd_set_voice_pitch = reinterpret_cast < decltype ( this - > spd_set_voice_pitch ) > (
dlsym ( library_ , " spd_set_voice_pitch " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_set_voice_pitch = & : : spd_set_voice_pitch ;
# endif
if ( ! spd_set_voice_pitch ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_list_synthesis_voices =
2015-07-01 07:56:29 +00:00
reinterpret_cast < decltype ( this - > spd_list_synthesis_voices ) > (
2014-10-08 02:14:12 +00:00
dlsym ( library_ , " spd_list_synthesis_voices " ) ) ;
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_list_synthesis_voices = & : : spd_list_synthesis_voices ;
# endif
if ( ! spd_list_synthesis_voices ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_synthesis_voice =
2015-07-01 07:56:29 +00:00
reinterpret_cast < decltype ( this - > spd_set_synthesis_voice ) > (
2014-10-08 02:14:12 +00:00
dlsym ( library_ , " spd_set_synthesis_voice " ) ) ;
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_set_synthesis_voice = & : : spd_set_synthesis_voice ;
# endif
if ( ! spd_set_synthesis_voice ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
2018-04-18 01:57:05 +00:00
spd_list_modules = reinterpret_cast < decltype ( this - > spd_list_modules ) > (
dlsym ( library_ , " spd_list_modules " ) ) ;
2014-10-08 02:14:12 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_list_modules = & : : spd_list_modules ;
# endif
if ( ! spd_list_modules ) {
CleanUp ( true ) ;
return false ;
}
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_output_module =
2015-07-01 07:56:29 +00:00
reinterpret_cast < decltype ( this - > spd_set_output_module ) > (
2014-10-08 02:14:12 +00:00
dlsym ( library_ , " spd_set_output_module " ) ) ;
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2014-10-08 02:14:12 +00:00
spd_set_output_module = & : : spd_set_output_module ;
# endif
if ( ! spd_set_output_module ) {
CleanUp ( true ) ;
return false ;
}
2015-12-08 02:26:32 +00:00
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
2018-04-18 01:57:05 +00:00
spd_set_language = reinterpret_cast < decltype ( this - > spd_set_language ) > (
dlsym ( library_ , " spd_set_language " ) ) ;
2015-12-08 02:26:32 +00:00
# endif
2018-04-18 01:57:05 +00:00
# if defined( \
LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED )
2015-12-08 02:26:32 +00:00
spd_set_language = & : : spd_set_language ;
# endif
if ( ! spd_set_language ) {
CleanUp ( true ) ;
return false ;
}
2014-10-08 02:14:12 +00:00
loaded_ = true ;
return true ;
}
void LibSpeechdLoader : : CleanUp ( bool unload ) {
# if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
if ( unload ) {
dlclose ( library_ ) ;
library_ = NULL ;
}
# endif
loaded_ = false ;
spd_open = NULL ;
spd_say = NULL ;
spd_stop = NULL ;
spd_close = NULL ;
spd_pause = NULL ;
spd_resume = NULL ;
spd_set_notification_on = NULL ;
spd_set_voice_rate = NULL ;
spd_set_voice_pitch = NULL ;
spd_list_synthesis_voices = NULL ;
spd_set_synthesis_voice = NULL ;
spd_list_modules = NULL ;
spd_set_output_module = NULL ;
2015-12-08 02:26:32 +00:00
spd_set_language = NULL ;
2014-10-08 02:14:12 +00:00
}