Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2010-11-30 03:05:22 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2010-11-30 03:05:22 (GMT)
commit86249d18885b0efe2746c3e3faa14e38dabd6ab9 (patch)
treed5ee056d336ec54815f1b370dadf017f717bdfed
parent98c7b6a89dd3b7ae5b6814c61f4a805c10534007 (diff)
Do not seeak for marks in original text, just store them at the begining of original text
-rw-r--r--src/espeak.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/espeak.c b/src/espeak.c
index 6152ccc..5cceffa 100644
--- a/src/espeak.c
+++ b/src/espeak.c
@@ -62,6 +62,7 @@ struct _Econtext {
gchar *text;
gsize text_offset;
gsize text_len;
+ gchar *next_mark;
Espin queue[SPIN_QUEUE_SIZE];
Espin *in;
@@ -110,14 +111,6 @@ static void emit_mark (Econtext * self, guint offset, const gchar * mark) {
"mark", G_TYPE_STRING, mark, NULL));
}
-static inline gsize
-strbstr (Econtext * self, gsize pos, const gchar * needle, gsize needle_len) {
- for (pos -= needle_len; pos >= needle_len; --pos)
- if (strncmp (self->text + pos, needle, needle_len) == 0)
- return pos;
- return 0;
-}
-
static void init ();
static void process_push (Econtext *, gboolean);
static void process_pop (Econtext *);
@@ -344,6 +337,8 @@ void espeak_reset (Econtext * self) {
g_free (self->text);
self->text = NULL;
}
+
+ self->next_mark = NULL;
}
// espeak ----------------------------------------------------------------------
@@ -371,16 +366,15 @@ static gint synth_cb (short *data, int numsamples, espeak_EVENT * events) {
--i->text_position;
if (i->type == espeakEVENT_MARK) {
- // point mark name to text substring instead of using
- // espeak's allocated(temporally) string
- int l_quote, r_quote;
- if ((r_quote = strbstr (self, i->text_position, "/>", 2)) != 0)
- if ((r_quote = strbstr (self, r_quote, "\"", 1)) != 0)
- if ((l_quote = strbstr (self, r_quote, "\"", 1)) != 0) {
- i->id.name = self->text + l_quote + 1;
- self->text[r_quote] = 0;
- }
-
+ // point mark name to our text substring instead of
+ // one which was temporally allocated by espeak
+ if (self->next_mark == NULL)
+ self->next_mark = self->text;
+ int mark_len = strlen (i->id.name);
+ strncpy (self->next_mark, i->id.name, mark_len);
+ i->id.name = self->next_mark;
+ self->next_mark[mark_len] = '\0';
+ self->next_mark += mark_len + 1;
}
GST_DEBUG ("text_position=%d length=%d",