daemon: separate API-visible parts of the client and voice interfaces.
authorKrisztian Litkey <kli@iki.fi>
Fri, 20 Dec 2013 12:56:03 +0000 (14:56 +0200)
committerKrisztian Litkey <kli@iki.fi>
Fri, 10 Jan 2014 15:07:56 +0000 (17:07 +0200)
Don't use SRS_CLIENT_TYPE_DBUS, use SRS_CLIENT_TYPE_EXTERNAL instead.

src/daemon/client-api-types.h [new file with mode: 0644]
src/daemon/client.h
src/daemon/voice-api-types.h [new file with mode: 0644]
src/daemon/voice.h
src/plugins/dbus-client-interface/dbus-client.c

diff --git a/src/daemon/client-api-types.h b/src/daemon/client-api-types.h
new file mode 100644 (file)
index 0000000..88c0250
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2012 - 2013, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *   * Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *   * Neither the name of Intel Corporation nor the names of its contributors
+ *     may be used to endorse or promote products derived from this software
+ *     without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __SRS_CLIENT_API_TYPES_H__
+#define __SRS_CLIENT_API_TYPES_H__
+
+/*
+ * voice focus types
+ */
+
+typedef enum {
+    SRS_VOICE_FOCUS_NONE = 0,            /* focus released */
+    SRS_VOICE_FOCUS_SHARED,              /* normal shared voice focus */
+    SRS_VOICE_FOCUS_EXCLUSIVE,           /* exclusive voice focus */
+} srs_voice_focus_t;
+
+
+/*
+ * special command tokens
+ */
+
+#define SRS_TOKEN_SWITCHDICT "__switch_dict__"
+#define SRS_TOKEN_PUSHDICT   "__push_dict__"
+#define SRS_TOKEN_POPDICT    "__pop_dict__"
+#define SRS_TOKEN_WILDCARD   "*"
+
+
+/* dictionary pseudo-commands */
+#define SRS_DICTCMD_SWITCH    "__switch_dict__"
+#define SRS_DICTCMD_PUSH      "__push_dict__"
+#define SRS_DICTCMD_POP       "__pop_dict__"
+
+#define SRS_DICT_SWITCH(dict) SRS_DICTCMD_SWITCH"("dict")"
+#define SRS_DICT_PUSH(dict)   SRS_DICTCMD_PUSH"("dict")"
+#define SRS_DICT_POP()        SRS_DICTCMD_POP
+
+
+/*
+ * special tokens
+ */
+
+#define SRS_TOKEN_SWITCHDICT "__switch_dict__"
+#define SRS_TOKEN_PUSHDICT   "__push_dict__"
+#define SRS_TOKEN_POPDICT    "__pop_dict__"
+
+#define SRS_TOKEN_WILDCARD "*"           /* match till end of utterance */
+
+#endif /* __SRS_CLIENT_API_TYPES_H__ */
index 499ba5f..2b79bd3 100644 (file)
 
 typedef struct srs_client_s srs_client_t;
 
-#include "src/daemon/context.h"
-#include "src/daemon/resctl.h"
-#include "src/daemon/audiobuf.h"
+#include "srs/daemon/context.h"
+#include "srs/daemon/resctl.h"
+#include "srs/daemon/audiobuf.h"
 #include "srs/daemon/voice.h"
+#include "srs/daemon/client-api-types.h"
 
 
 /*
@@ -44,23 +45,12 @@ typedef struct srs_client_s srs_client_t;
 
 typedef enum {
     SRS_CLIENT_TYPE_NONE = 0,
-    SRS_CLIENT_TYPE_DBUS,                /* external D-BUS client */
     SRS_CLIENT_TYPE_BUILTIN,             /* builtin client */
+    SRS_CLIENT_TYPE_EXTERNAL,            /* other client */
 } srs_client_type_t;
 
 
 /*
- * voice focus types
- */
-
-typedef enum {
-    SRS_VOICE_FOCUS_NONE = 0,            /* focus released */
-    SRS_VOICE_FOCUS_SHARED,              /* normal shared voice focus */
-    SRS_VOICE_FOCUS_EXCLUSIVE,           /* exclusive voice focus */
-} srs_voice_focus_t;
-
-
-/*
  * client commands
  */
 
@@ -73,40 +63,9 @@ typedef struct {
 
 
 /*
- * special command tokens
- */
-
-#define SRS_TOKEN_SWITCHDICT "__switch_dict__"
-#define SRS_TOKEN_PUSHDICT   "__push_dict__"
-#define SRS_TOKEN_POPDICT    "__pop_dict__"
-#define SRS_TOKEN_WILDCARD   "*"
-
-
-/* dictionary pseudo-commands */
-#define SRS_DICTCMD_SWITCH    "__switch_dict__"
-#define SRS_DICTCMD_PUSH      "__push_dict__"
-#define SRS_DICTCMD_POP       "__pop_dict__"
-
-#define SRS_DICT_SWITCH(dict) SRS_DICTCMD_SWITCH"("dict")"
-#define SRS_DICT_PUSH(dict)   SRS_DICTCMD_PUSH"("dict")"
-#define SRS_DICT_POP()        SRS_DICTCMD_POP
-
-
-/*
- * special tokens
- */
-
-#define SRS_TOKEN_SWITCHDICT "__switch_dict__"
-#define SRS_TOKEN_PUSHDICT   "__push_dict__"
-#define SRS_TOKEN_POPDICT    "__pop_dict__"
-
-#define SRS_TOKEN_WILDCARD "*"           /* match till end of utterance */
-
-/*
  * dictionary operations
  */
 
-/* dictionary operations */
 typedef enum {
     SRS_DICT_OP_UNKNOWN = 0,
     SRS_DICT_OP_SWITCH,
@@ -189,6 +148,6 @@ int client_query_voices(srs_client_t *c, const char *language,
                         srs_voice_actor_t **actorsp);
 
 /** Free voice actor query reult. */
-    void client_free_queried_voices(srs_voice_actor_t *actors);
+void client_free_queried_voices(srs_voice_actor_t *actors);
 
 #endif /* __SRS_DAEMON_CLIENT_H__ */
diff --git a/src/daemon/voice-api-types.h b/src/daemon/voice-api-types.h
new file mode 100644 (file)
index 0000000..567bbbf
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2012 - 2013, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *   * Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *   * Neither the name of Intel Corporation nor the names of its contributors
+ *     may be used to endorse or promote products derived from this software
+ *     without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __SRS_VOICE_API_TYPES_H__
+#define __SRS_VOICE_API_TYPES_H__
+
+/** Failure/invalid voice identifier. */
+#define SRS_VOICE_INVALID ((uint32_t)-1)
+
+/** Voice rendering notification callback events. */
+typedef enum {
+    SRS_VOICE_EVENT_STARTED,             /* TTS started */
+    SRS_VOICE_EVENT_PROGRESS,            /* TTS progressing */
+    SRS_VOICE_EVENT_COMPLETED,           /* TTS finished successfully */
+    SRS_VOICE_EVENT_TIMEOUT,             /* TTS timed out */
+    SRS_VOICE_EVENT_ABORTED,             /* TTS finished abnormally */
+    SRS_VOICE_EVENT_MAX
+} srs_voice_event_type_t;
+
+/** Voice rendering notification event masks. */
+#define SRS_VOICE_MASK_NONE        0
+#define SRS_VOICE_MASK_STARTED    (1 << SRS_VOICE_EVENT_STARTED)
+#define SRS_VOICE_MASK_PROGRESS   (1 << SRS_VOICE_EVENT_PROGRESS)
+#define SRS_VOICE_MASK_COMPLETED  (1 << SRS_VOICE_EVENT_COMPLETED)
+#define SRS_VOICE_MASK_TIMEOUT    (1 << SRS_VOICE_EVENT_TIMEOUT)
+#define SRS_VOICE_MASK_ABORTED    (1 << SRS_VOICE_EVENT_ABORTED)
+
+#define SRS_VOICE_MASK_ALL       ((1 << SRS_VOICE_EVENT_MAX) - 1)
+#define SRS_VOICE_MASK_DONE       (SRS_VOICE_MASK_COMPLETED | \
+                                   SRS_VOICE_MASK_TIMEOUT   | \
+                                   SRS_VOICE_MASK_ABORTED)
+
+typedef struct {
+    srs_voice_event_type_t type;         /* event type */
+    uint32_t               id;           /* voice stream id */
+    union {                              /* event-specific data */
+        struct {
+            double   pcnt;               /* progress in percentages */
+            uint32_t msec;               /* progress in millisconds */
+        } progress;
+    } data;
+} srs_voice_event_t;
+
+/** Voice actor genders. */
+typedef enum {
+    SRS_VOICE_GENDER_ANY,                /* any voice actor */
+    SRS_VOICE_GENDER_MALE,               /* a male voice actor */
+    SRS_VOICE_GENDER_FEMALE,             /* a female voice actor */
+} srs_voice_gender_t;
+
+#define SRS_VOICE_FEMALE "female"        /* any female actor */
+#define SRS_VOICE_MALE   "male"          /* any male actor */
+
+/** Voice timeout/queuing constants. */
+#define SRS_VOICE_IMMEDIATE     0        /* render immediately or fail */
+#define SRS_VOICE_QUEUE        -1        /* allow queuing indefinitely */
+#define SRS_VOICE_TIMEOUT(sec) (sec)     /* fail if can't start in time */
+
+
+/*
+ * voice actors
+ */
+typedef struct {
+    uint32_t            id;              /* backend actor id */
+    char               *lang;            /* spoken language */
+    char               *dialect;         /* language dialect, if any */
+    uint16_t            gender;          /* gender */
+    uint16_t            age;             /* actor age */
+    char               *name;            /* backend actor name */
+    char               *description;     /* human-readable description */
+} srs_voice_actor_t;
+
+
+#endif /* __SRS_VOICE_API_TYPES_H__ */
index 9860868..35f3add 100644 (file)
 #ifndef __SRS_DAEMON_VOICE_H__
 #define __SRS_DAEMON_VOICE_H__
 
-#include "src/daemon/context.h"
+#include "srs/daemon/context.h"
+#include "srs/daemon/voice-api-types.h"
 
 /*
  * speech synthesizer backend interface
  */
 
-/** Failure/invalid voice identifier. */
-#define SRS_VOICE_INVALID ((uint32_t)-1)
-
-/** Voice rendering notification callback events. */
-typedef enum {
-    SRS_VOICE_EVENT_STARTED,             /* TTS started */
-    SRS_VOICE_EVENT_PROGRESS,            /* TTS progressing */
-    SRS_VOICE_EVENT_COMPLETED,           /* TTS finished successfully */
-    SRS_VOICE_EVENT_TIMEOUT,             /* TTS timed out */
-    SRS_VOICE_EVENT_ABORTED,             /* TTS finished abnormally */
-    SRS_VOICE_EVENT_MAX
-} srs_voice_event_type_t;
-
-/** Voice rendering notification event masks. */
-#define SRS_VOICE_MASK_NONE        0
-#define SRS_VOICE_MASK_STARTED    (1 << SRS_VOICE_EVENT_STARTED)
-#define SRS_VOICE_MASK_PROGRESS   (1 << SRS_VOICE_EVENT_PROGRESS)
-#define SRS_VOICE_MASK_COMPLETED  (1 << SRS_VOICE_EVENT_COMPLETED)
-#define SRS_VOICE_MASK_TIMEOUT    (1 << SRS_VOICE_EVENT_TIMEOUT)
-#define SRS_VOICE_MASK_ABORTED    (1 << SRS_VOICE_EVENT_ABORTED)
-
-#define SRS_VOICE_MASK_ALL       ((1 << SRS_VOICE_EVENT_MAX) - 1)
-#define SRS_VOICE_MASK_DONE       (SRS_VOICE_MASK_COMPLETED | \
-                                   SRS_VOICE_MASK_TIMEOUT   | \
-                                   SRS_VOICE_MASK_ABORTED)
-
-typedef struct {
-    srs_voice_event_type_t type;         /* event type */
-    uint32_t               id;           /* voice stream id */
-    union {                              /* event-specific data */
-        struct {
-            double   pcnt;               /* progress in percentages */
-            uint32_t msec;               /* progress in millisconds */
-        } progress;
-    } data;
-} srs_voice_event_t;
-
 /** Voice rendering notification callback type. */
 typedef void (*srs_voice_notify_t)(srs_voice_event_t *event, void *notify_data);
 
-/** Voice actor genders. */
-typedef enum {
-    SRS_VOICE_GENDER_ANY,                /* any voice actor */
-    SRS_VOICE_GENDER_MALE,               /* a male voice actor */
-    SRS_VOICE_GENDER_FEMALE,             /* a female voice actor */
-} srs_voice_gender_t;
-
-#define SRS_VOICE_FEMALE "female"        /* any female actor */
-#define SRS_VOICE_MALE   "male"          /* any male actor */
-
-/** Voice timeout/queuing constants. */
-#define SRS_VOICE_IMMEDIATE     0        /* render immediately or fail */
-#define SRS_VOICE_QUEUE        -1        /* allow queuing indefinitely */
-#define SRS_VOICE_TIMEOUT(sec) (sec)     /* fail if can't start in time */
-
-
-/*
- * voice actors
- */
-typedef struct {
-    uint32_t            id;              /* backend actor id */
-    char               *lang;            /* spoken language */
-    char               *dialect;         /* language dialect, if any */
-    srs_voice_gender_t  gender;          /* gender */
-    int                 age;             /* actor age */
-    char               *name;            /* backend actor name */
-    char               *description;     /* human-readable description */
-} srs_voice_actor_t;
-
-
 /*
  * API to voice backend
  */
index 8ae5835..601e43b 100644 (file)
@@ -32,7 +32,6 @@
 
 #include <murphy/common/log.h>
 #include <murphy/common/debug.h>
-#include <murphy/common/debug.h>
 #include <murphy/common/dbus-libdbus.h>
 
 #include "src/daemon/plugin.h"
@@ -389,7 +388,7 @@ static int register_req(mrp_dbus_t *dbus, mrp_dbus_msg_t *req, void *user_data)
 
     mrp_debug("got register request from %s", id);
 
-    c = client_create(srs, SRS_CLIENT_TYPE_DBUS, name, appcls, cmds, ncmd,
+    c = client_create(srs, SRS_CLIENT_TYPE_EXTERNAL, name, appcls, cmds, ncmd,
                       id, &ops, bus);
 
     if (c != NULL) {