123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- // This is generated file. Do not modify directly.
- // Path to the code generator:
- // tools/generate_library_loader/generate_library_loader.py .
- #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).
- #if !defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN) && \
- !defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- #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
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN) && \
- defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- #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
- LibSpeechdLoader::LibSpeechdLoader() : loaded_(false) {}
- 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 =
- reinterpret_cast<decltype(this->spd_open)>(dlsym(library_, "spd_open"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_say)>(dlsym(library_, "spd_say"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_stop)>(dlsym(library_, "spd_stop"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_close)>(dlsym(library_, "spd_close"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_pause)>(dlsym(library_, "spd_pause"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- spd_pause = &::spd_pause;
- #endif
- if (!spd_pause) {
- CleanUp(true);
- return false;
- }
- #if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
- spd_resume = reinterpret_cast<decltype(this->spd_resume)>(
- dlsym(library_, "spd_resume"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_set_notification_on)>(
- dlsym(library_, "spd_set_notification_on"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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)
- spd_set_voice_rate = reinterpret_cast<decltype(this->spd_set_voice_rate)>(
- dlsym(library_, "spd_set_voice_rate"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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)
- spd_set_voice_pitch = reinterpret_cast<decltype(this->spd_set_voice_pitch)>(
- dlsym(library_, "spd_set_voice_pitch"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_list_synthesis_voices)>(
- dlsym(library_, "spd_list_synthesis_voices"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_set_synthesis_voice)>(
- dlsym(library_, "spd_set_synthesis_voice"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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)
- spd_list_modules = reinterpret_cast<decltype(this->spd_list_modules)>(
- dlsym(library_, "spd_list_modules"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- 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 =
- reinterpret_cast<decltype(this->spd_set_output_module)>(
- dlsym(library_, "spd_set_output_module"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- spd_set_output_module = &::spd_set_output_module;
- #endif
- if (!spd_set_output_module) {
- CleanUp(true);
- return false;
- }
- #if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
- spd_set_language = reinterpret_cast<decltype(this->spd_set_language)>(
- dlsym(library_, "spd_set_language"));
- #endif
- #if defined( \
- LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
- spd_set_language = &::spd_set_language;
- #endif
- if (!spd_set_language) {
- CleanUp(true);
- return false;
- }
- 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;
- spd_set_language = NULL;
- }
|