[asterisk-commits] seanbright: branch seanbright/tts r426100 - in /team/seanbright/tts: include/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 22 16:49:21 CDT 2014
Author: seanbright
Date: Wed Oct 22 16:49:19 2014
New Revision: 426100
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=426100
Log:
Registration/Unregistration
Added:
team/seanbright/tts/include/asterisk/tts.h (with props)
team/seanbright/tts/res/res_tts.c (with props)
team/seanbright/tts/res/res_tts.exports.in (with props)
Added: team/seanbright/tts/include/asterisk/tts.h
URL: http://svnview.digium.com/svn/asterisk/team/seanbright/tts/include/asterisk/tts.h?view=auto&rev=426100
==============================================================================
--- team/seanbright/tts/include/asterisk/tts.h (added)
+++ team/seanbright/tts/include/asterisk/tts.h Wed Oct 22 16:49:19 2014
@@ -1,0 +1,45 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2014, malleable, LLC.
+ *
+ * Sean Bright <sean at malleable.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Generic Text-To-Speech API
+ */
+
+#ifndef _ASTERISK_TTS_H
+#define _ASTERISK_TTS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+struct ast_tts_engine {
+ /*! Name of TTS engine */
+ char *name;
+ AST_LIST_ENTRY(ast_tts_engine) list;
+};
+
+/*! \brief Register a TTS engine */
+int ast_tts_register(struct ast_tts_engine *engine);
+/*! \brief Unregister a TTS engine */
+int ast_tts_unregister(const char *engine_name);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_TTS_H */
Propchange: team/seanbright/tts/include/asterisk/tts.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/seanbright/tts/include/asterisk/tts.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/seanbright/tts/include/asterisk/tts.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/seanbright/tts/res/res_tts.c
URL: http://svnview.digium.com/svn/asterisk/team/seanbright/tts/res/res_tts.c?view=auto&rev=426100
==============================================================================
--- team/seanbright/tts/res/res_tts.c (added)
+++ team/seanbright/tts/res/res_tts.c Wed Oct 22 16:49:19 2014
@@ -1,0 +1,138 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2014, malleable, LLC.
+ *
+ * Sean Bright <sean at malleable.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Generic Text-To-Speech API
+ *
+ * \author Sean Bright <sean at malleable.com>
+ */
+
+/*** MODULEINFO
+ <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
+
+#include "asterisk/channel.h"
+#include "asterisk/module.h"
+#include "asterisk/lock.h"
+#include "asterisk/linkedlists.h"
+#include "asterisk/cli.h"
+#include "asterisk/term.h"
+#include "asterisk/tts.h"
+#include "asterisk/format_cache.h"
+
+static AST_RWLIST_HEAD_STATIC(engines, ast_tts_engine);
+static struct ast_tts_engine *default_engine = NULL;
+
+/*! \brief Find a TTS engine of specified name, if NULL then use the default one */
+static struct ast_tts_engine *find_engine(const char *engine_name)
+{
+ struct ast_tts_engine *engine = NULL;
+
+ /* If no name is specified -- use the default engine */
+ if (ast_strlen_zero(engine_name)) {
+ return default_engine;
+ }
+
+ AST_RWLIST_RDLOCK(&engines);
+ AST_RWLIST_TRAVERSE(&engines, engine, list) {
+ if (!strcasecmp(engine->name, engine_name)) {
+ break;
+ }
+ }
+ AST_RWLIST_UNLOCK(&engines);
+
+ return engine;
+}
+
+/*! \brief Register a TTS engine */
+int ast_tts_register(struct ast_tts_engine *engine)
+{
+ int res = 0;
+
+ /* If an engine is already loaded with this name, error out */
+ if (find_engine(engine->name)) {
+ ast_log(LOG_WARNING, "TTS engine '%s' already exists.\n", engine->name);
+ return -1;
+ }
+
+ ast_verb(2, "Registered TTS engine '%s'\n", engine->name);
+
+ /* Add to the engine linked list and make default if needed */
+ AST_RWLIST_WRLOCK(&engines);
+ AST_RWLIST_INSERT_HEAD(&engines, engine, list);
+ if (!default_engine) {
+ default_engine = engine;
+ ast_verb(2, "Made '%s' the default TTS engine\n", engine->name);
+ }
+ AST_RWLIST_UNLOCK(&engines);
+
+ return res;
+}
+
+/*! \brief Unregister a TTS engine */
+int ast_tts_unregister(const char *engine_name)
+{
+ struct ast_tts_engine *engine = NULL;
+ int res = -1;
+
+ if (ast_strlen_zero(engine_name))
+ return -1;
+
+ AST_RWLIST_WRLOCK(&engines);
+ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&engines, engine, list) {
+ if (!strcasecmp(engine->name, engine_name)) {
+ /* We have our engine... removed it */
+ AST_RWLIST_REMOVE_CURRENT(list);
+ /* If this was the default engine, we need to pick a new one */
+ if (engine == default_engine) {
+ default_engine = AST_RWLIST_FIRST(&engines);
+ }
+ ast_verb(2, "Unregistered TTS engine '%s'\n", engine_name);
+ /* All went well */
+ res = 0;
+ break;
+ }
+ }
+ AST_RWLIST_TRAVERSE_SAFE_END;
+ AST_RWLIST_UNLOCK(&engines);
+
+ return res;
+}
+
+static int unload_module(void)
+{
+ /* We can not be unloaded */
+ return -1;
+}
+
+static int load_module(void)
+{
+ return AST_MODULE_LOAD_SUCCESS;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Generic Text-To-Speech API",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .load_pri = AST_MODPRI_APP_DEPEND,
+ );
Propchange: team/seanbright/tts/res/res_tts.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/seanbright/tts/res/res_tts.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/seanbright/tts/res/res_tts.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/seanbright/tts/res/res_tts.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/seanbright/tts/res/res_tts.exports.in?view=auto&rev=426100
==============================================================================
--- team/seanbright/tts/res/res_tts.exports.in (added)
+++ team/seanbright/tts/res/res_tts.exports.in Wed Oct 22 16:49:19 2014
@@ -1,0 +1,6 @@
+{
+ global:
+ LINKER_SYMBOL_PREFIXast_*;
+ local:
+ *;
+};
Propchange: team/seanbright/tts/res/res_tts.exports.in
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/seanbright/tts/res/res_tts.exports.in
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/seanbright/tts/res/res_tts.exports.in
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list