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-08-18 15:59:09 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2010-08-18 15:59:09 (GMT)
commit6bd028b86e5c24e342345bae8f7131465d00a619 (patch)
tree189948b272dc72f5a040a7d4258e5100ae8dcb3a
parenta974780e5deca0254e8a63b2fb54cad0a14b059a (diff)
Indent source files
-rw-r--r--AUTHORS5
-rw-r--r--HACKING15
-rw-r--r--README5
-rw-r--r--src/espeak.c595
-rw-r--r--src/espeak.h28
-rw-r--r--src/gstespeak.c426
-rw-r--r--src/gstespeak.h11
7 files changed, 494 insertions, 591 deletions
diff --git a/AUTHORS b/AUTHORS
index abb401b..2246308 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,8 @@
Contributors
~~~~~~~~~~~~
Aleksey Lim <alsroot@member.fsf.org>
+Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+
+Maintainers
+~~~~~~~~~~~
+Aleksey Lim <alsroot@member.fsf.org>
diff --git a/HACKING b/HACKING
new file mode 100644
index 0000000..a9b5e5b
--- /dev/null
+++ b/HACKING
@@ -0,0 +1,15 @@
+Before committing
+~~~~~~~~~~~~~~~~~
+All source files need to be passed through indent command.
+Follow http://wiki.sugarlabs.org/go/Activity_Team/Sugar_Lint instructions
+and especially "Lint files before committing" section.
+Otherwise just call indent command with settings [1].
+
+
+Send patches
+~~~~~~~~~~~~
+Create your patches using "git format" command and send them to all maintainers
+from AUTHORS file. The easiest way it just using "git send-email" command.
+
+
+[1] http://git.sugarlabs.org/projects/sugar-lint/repos/mainline/blobs/master/sugar/lint/indent.pro
diff --git a/README b/README
index 4e993ea..73804a3 100644
--- a/README
+++ b/README
@@ -8,6 +8,11 @@ Home Page
http://wiki.sugarlabs.org/go/Activity_Team/gst-plugins-espeak
+Contribution
+~~~~~~~~~~~~
+See HACKING file.
+
+
Get it
~~~~~~
http://git.sugarlabs.org/projects/gst-plugins-espeak
diff --git a/src/espeak.c b/src/espeak.c
index 138d595..58ffc28 100644
--- a/src/espeak.c
+++ b/src/espeak.c
@@ -28,21 +28,18 @@
#include "espeak.h"
-typedef enum
-{
- IN = 1,
- OUT = 2,
- PLAY = 4
+typedef enum {
+ IN = 1,
+ OUT = 2,
+ PLAY = 4
} SpinState;
-typedef enum
-{
+typedef enum {
INPROCESS = 1,
- CLOSE = 2
+ CLOSE = 2
} ContextState;
-typedef struct
-{
+typedef struct {
Econtext *context;
volatile SpinState state;
@@ -59,8 +56,7 @@ typedef struct
const gchar *mark_name;
} Espin;
-struct _Econtext
-{
+struct _Econtext {
volatile ContextState state;
gchar *text;
@@ -83,55 +79,50 @@ struct _Econtext
GstBus *bus;
};
-static inline void
-spinning(Espin *base, Espin **i)
-{
+static inline void spinning (Espin * base, Espin ** i) {
if (++(*i) == base + SPIN_QUEUE_SIZE)
*i = base;
}
-static void
-emit_word(Econtext *self, guint offset, guint len)
-{
- GstStructure *data = gst_structure_new("espeak-word",
+static void emit_word (Econtext * self, guint offset, guint len) {
+ GstStructure *data = gst_structure_new ("espeak-word",
"offset", G_TYPE_UINT, offset,
"len", G_TYPE_UINT, len,
NULL);
if (!self->bus)
- self->bus = gst_element_get_bus(self->emitter);
- GstMessage *msg = gst_message_new_element(GST_OBJECT(self->emitter), data);
- gst_bus_post(self->bus, msg);
+ self->bus = gst_element_get_bus (self->emitter);
+ GstMessage *msg =
+ gst_message_new_element (GST_OBJECT (self->emitter), data);
+ gst_bus_post (self->bus, msg);
}
-static void
-emit_mark(Econtext *self, guint offset, const gchar *mark)
-{
- GstStructure *data = gst_structure_new("espeak-mark",
+static void emit_mark (Econtext * self, guint offset, const gchar * mark) {
+ GstStructure *data = gst_structure_new ("espeak-mark",
"offset", G_TYPE_UINT, offset,
"mark", G_TYPE_STRING, mark,
NULL);
if (!self->bus)
- self->bus = gst_element_get_bus(self->emitter);
- GstMessage *msg = gst_message_new_element(GST_OBJECT(self->emitter), data);
- gst_bus_post(self->bus, msg);
+ self->bus = gst_element_get_bus (self->emitter);
+ GstMessage *msg =
+ gst_message_new_element (GST_OBJECT (self->emitter), data);
+ gst_bus_post (self->bus, msg);
}
static inline gsize
-strbstr(Econtext *self, gsize pos, const gchar *needle, gsize needle_len)
-{
+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)
+ 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*);
+static void init ();
+static void process_push (Econtext *, gboolean);
+static void process_pop (Econtext *);
static GThread *process_tid = NULL;
static GMutex *process_lock = NULL;
-static GCond *process_cond = NULL;
+static GCond *process_cond = NULL;
static GSList *process_queue = NULL;
static gint espeak_sample_rate = 0;
@@ -139,28 +130,25 @@ static GValueArray *espeak_voices = NULL;
// -----------------------------------------------------------------------------
-Econtext*
-espeak_new(GstElement *emitter)
-{
- init();
+Econtext *espeak_new (GstElement * emitter) {
+ init ();
- Econtext *self = g_new0(Econtext, 1);
+ Econtext *self = g_new0 (Econtext, 1);
gint i;
- for (i = SPIN_QUEUE_SIZE; i--;)
- {
+ for (i = SPIN_QUEUE_SIZE; i--;) {
Espin *spin = &self->queue[i];
spin->context = self;
spin->state = IN;
- spin->sound = g_byte_array_new();
- spin->events = g_array_new(FALSE, FALSE, sizeof(espeak_EVENT));
+ spin->sound = g_byte_array_new ();
+ spin->events = g_array_new (FALSE, FALSE, sizeof (espeak_EVENT));
}
self->in = self->queue;
self->out = self->queue;
- self->process_chunk = g_slist_alloc();
+ self->process_chunk = g_slist_alloc ();
self->process_chunk->data = self;
self->pitch = 50;
@@ -170,97 +158,83 @@ espeak_new(GstElement *emitter)
self->track = ESPEAK_TRACK_NONE;
self->emitter = emitter;
- gst_object_ref(self->emitter);
+ gst_object_ref (self->emitter);
self->bus = NULL;
- GST_DEBUG("[%p]", self);
+ GST_DEBUG ("[%p]", self);
return self;
}
-void
-espeak_unref(Econtext *self)
-{
- GST_DEBUG("[%p]", self);
+void espeak_unref (Econtext * self) {
+ GST_DEBUG ("[%p]", self);
- espeak_reset(self);
+ espeak_reset (self);
gint i;
- for (i = SPIN_QUEUE_SIZE; i--;)
- {
- g_byte_array_free(self->queue[i].sound, TRUE);
- g_array_free(self->queue[i].events, TRUE);
+ for (i = SPIN_QUEUE_SIZE; i--;) {
+ g_byte_array_free (self->queue[i].sound, TRUE);
+ g_array_free (self->queue[i].events, TRUE);
}
- g_slist_free(self->process_chunk);
+ g_slist_free (self->process_chunk);
- gst_object_unref(self->bus);
- gst_object_unref(self->emitter);
+ gst_object_unref (self->bus);
+ gst_object_unref (self->emitter);
- memset(self, 0, sizeof(Econtext));
- g_free(self);
+ memset (self, 0, sizeof (Econtext));
+ g_free (self);
}
// in/out ----------------------------------------------------------------------
-void
-espeak_in(Econtext *self, const gchar *text)
-{
- GST_DEBUG("[%p] text=%s", self, text);
+void espeak_in (Econtext * self, const gchar * text) {
+ GST_DEBUG ("[%p] text=%s", self, text);
if (text == NULL || *text == 0)
return;
- self->text = g_strdup(text);
+ self->text = g_strdup (text);
self->text_offset = 0;
- self->text_len = strlen(text);
+ self->text_len = strlen (text);
- process_push(self, TRUE);
+ process_push (self, TRUE);
}
-GstBuffer*
-play(Econtext *self, Espin *spin, gsize size_to_play)
-{
- inline gsize whole(Espin *spin, gsize size_to_play)
- {
- for (;; ++spin->events_pos)
- {
- espeak_EVENT *i = &g_array_index(spin->events, espeak_EVENT,
+GstBuffer *play (Econtext * self, Espin * spin, gsize size_to_play) {
+ inline gsize whole (Espin * spin, gsize size_to_play) {
+ for (;; ++spin->events_pos) {
+ espeak_EVENT *i = &g_array_index (spin->events, espeak_EVENT,
spin->events_pos);
- gsize len = i->sample*2 - spin->sound_offset;
+ gsize len = i->sample * 2 - spin->sound_offset;
if (i->type == espeakEVENT_LIST_TERMINATED || len >= size_to_play)
return len;
}
}
- inline gsize word(Econtext *self, Espin *spin, gsize size_to_play)
- {
+ inline gsize word (Econtext * self, Espin * spin, gsize size_to_play) {
gsize spin_size = spin->sound->len;
gsize event;
gsize sample_offset = 0;
- for (event = spin->events_pos; TRUE; ++event)
- {
- espeak_EVENT *i = &g_array_index(spin->events, espeak_EVENT, event);
+ for (event = spin->events_pos; TRUE; ++event) {
+ espeak_EVENT *i =
+ &g_array_index (spin->events, espeak_EVENT, event);
- GST_DEBUG("event=%zd i->type=%d i->text_position=%d",
- event, i->type, i->text_position);
+ GST_DEBUG ("event=%zd i->type=%d i->text_position=%d",
+ event, i->type, i->text_position);
- if (i->type == espeakEVENT_LIST_TERMINATED)
- {
+ if (i->type == espeakEVENT_LIST_TERMINATED) {
sample_offset = spin_size;
break;
- }
- else if (i->type == espeakEVENT_WORD)
- {
- if (i->text_position != spin->last_word)
- {
- emit_word(self, i->text_position, i->length);
+ } else if (i->type == espeakEVENT_WORD) {
+ if (i->text_position != spin->last_word) {
+ emit_word (self, i->text_position, i->length);
spin->last_word = i->text_position;
}
- sample_offset = i[1].sample*2;
+ sample_offset = i[1].sample * 2;
break;
}
}
@@ -268,11 +242,9 @@ play(Econtext *self, Espin *spin, gsize size_to_play)
return sample_offset - spin->sound_offset;
}
- inline gsize mark(Econtext *self, Espin *spin, gsize size_to_play)
- {
- if (spin->mark_name)
- {
- emit_mark(self, spin->mark_offset, spin->mark_name);
+ inline gsize mark (Econtext * self, Espin * spin, gsize size_to_play) {
+ if (spin->mark_name) {
+ emit_mark (self, spin->mark_offset, spin->mark_name);
spin->mark_offset = 0;
spin->mark_name = NULL;
}
@@ -283,30 +255,26 @@ play(Econtext *self, Espin *spin, gsize size_to_play)
guint mark_offset = 0;
const gchar *mark_name = NULL;
- for (event = spin->events_pos; TRUE; ++event)
- {
- espeak_EVENT *i = &g_array_index(spin->events, espeak_EVENT, event);
+ for (event = spin->events_pos; TRUE; ++event) {
+ espeak_EVENT *i =
+ &g_array_index (spin->events, espeak_EVENT, event);
- GST_DEBUG("event=%zd i->type=%d i->text_position=%d",
- event, i->type, i->text_position);
+ GST_DEBUG ("event=%zd i->type=%d i->text_position=%d",
+ event, i->type, i->text_position);
- if (i->type == espeakEVENT_LIST_TERMINATED)
- {
+ if (i->type == espeakEVENT_LIST_TERMINATED) {
sample_offset = spin_size;
break;
- }
- else if (i->type == espeakEVENT_MARK)
- {
- if (i->sample == 0)
- {
+ } else if (i->type == espeakEVENT_MARK) {
+ if (i->sample == 0) {
if (spin->sound_offset == 0)
- emit_mark(self, i->text_position, i->id.name);
+ emit_mark (self, i->text_position, i->id.name);
continue;
}
mark_offset = i->text_position;
mark_name = i->id.name;
- sample_offset = i->sample*2;
+ sample_offset = i->sample * 2;
break;
}
}
@@ -317,170 +285,155 @@ play(Econtext *self, Espin *spin, gsize size_to_play)
return sample_offset - spin->sound_offset;
}
- g_atomic_int_set(&spin->state, PLAY);
-
- switch (g_atomic_int_get(&self->track))
- {
- case ESPEAK_TRACK_WORD:
- size_to_play = word(self, spin, size_to_play);
- break;
- case ESPEAK_TRACK_MARK:
- size_to_play = mark(self, spin, size_to_play);
- break;
- default:
- size_to_play = whole(spin, size_to_play);
+ g_atomic_int_set (&spin->state, PLAY);
+
+ switch (g_atomic_int_get (&self->track)) {
+ case ESPEAK_TRACK_WORD:
+ size_to_play = word (self, spin, size_to_play);
+ break;
+ case ESPEAK_TRACK_MARK:
+ size_to_play = mark (self, spin, size_to_play);
+ break;
+ default:
+ size_to_play = whole (spin, size_to_play);
}
- espeak_EVENT *event = &g_array_index(spin->events, espeak_EVENT,
+ espeak_EVENT *event = &g_array_index (spin->events, espeak_EVENT,
spin->events_pos);
- GstBuffer *out = gst_buffer_new();
- GST_BUFFER_DATA(out) = spin->sound->data + spin->sound_offset;
- GST_BUFFER_SIZE(out) = size_to_play;
- GST_BUFFER_TIMESTAMP(out) = spin->audio_position;
- spin->audio_position = gst_util_uint64_scale_int(
- event->audio_position, GST_SECOND, 1000);
- GST_BUFFER_DURATION(out) = spin->audio_position - GST_BUFFER_TIMESTAMP(out);
+ GstBuffer *out = gst_buffer_new ();
+ GST_BUFFER_DATA (out) = spin->sound->data + spin->sound_offset;
+ GST_BUFFER_SIZE (out) = size_to_play;
+ GST_BUFFER_TIMESTAMP (out) = spin->audio_position;
+ spin->audio_position =
+ gst_util_uint64_scale_int (event->audio_position, GST_SECOND, 1000);
+ GST_BUFFER_DURATION (out) =
+ spin->audio_position - GST_BUFFER_TIMESTAMP (out);
spin->sound_offset += size_to_play;
spin->events_pos += 1;
- GST_DEBUG("out=%p size_to_play=%zd tell=%zd ts=%"G_GUINT64_FORMAT" dur=%"G_GUINT64_FORMAT,
- GST_BUFFER_DATA(out), size_to_play, spin->sound_offset,
- GST_BUFFER_TIMESTAMP(out), GST_BUFFER_DURATION(out));
+ GST_DEBUG ("out=%p size_to_play=%zd tell=%zd ts=%" G_GUINT64_FORMAT " dur=%"
+ G_GUINT64_FORMAT, GST_BUFFER_DATA (out), size_to_play,
+ spin->sound_offset, GST_BUFFER_TIMESTAMP (out),
+ GST_BUFFER_DURATION (out));
return out;
}
-GstBuffer*
-espeak_out(Econtext *self, gsize size_to_play)
-{
- GST_DEBUG("[%p] size_to_play=%d", self, size_to_play);
-
- for (;;)
- {
- g_mutex_lock(process_lock);
- for (;;)
- {
- if (g_atomic_int_get(&self->out->state) & (PLAY|OUT))
- break;
- if (self->state != INPROCESS)
- {
- if (self->state == CLOSE)
- GST_DEBUG("[%p] sesseion is closed", self);
- else
- GST_DEBUG("[%p] nothing to play", self);
- g_mutex_unlock(process_lock);
- return NULL;
- }
- GST_DEBUG("[%p] wait for processed data", self);
- g_cond_wait(process_cond, process_lock);
+GstBuffer *espeak_out (Econtext * self, gsize size_to_play) {
+ GST_DEBUG ("[%p] size_to_play=%d", self, size_to_play);
+
+ for (;;) {
+ g_mutex_lock (process_lock);
+ for (;;) {
+ if (g_atomic_int_get (&self->out->state) & (PLAY | OUT))
+ break;
+ if (self->state != INPROCESS) {
+ if (self->state == CLOSE)
+ GST_DEBUG ("[%p] sesseion is closed", self);
+ else
+ GST_DEBUG ("[%p] nothing to play", self);
+ g_mutex_unlock (process_lock);
+ return NULL;
}
- g_mutex_unlock(process_lock);
+ GST_DEBUG ("[%p] wait for processed data", self);
+ g_cond_wait (process_cond, process_lock);
+ }
+ g_mutex_unlock (process_lock);
Espin *spin = self->out;
gsize spin_size = spin->sound->len;
- GST_DEBUG("[%p] spin=%p spin->sound_offset=%zd spin_size=%zd " \
+ GST_DEBUG ("[%p] spin=%p spin->sound_offset=%zd spin_size=%zd "
"spin->state=%d",
self, spin, spin->sound_offset, spin_size,
- g_atomic_int_get(&spin->state));
-
- if (g_atomic_int_get(&spin->state) == PLAY &&
- spin->sound_offset >= spin_size)
- {
- g_atomic_int_set(&spin->state, IN);
- process_push(self, FALSE);
- spinning(self->queue, &self->out);
+ g_atomic_int_get (&spin->state));
+
+ if (g_atomic_int_get (&spin->state) == PLAY &&
+ spin->sound_offset >= spin_size) {
+ g_atomic_int_set (&spin->state, IN);
+ process_push (self, FALSE);
+ spinning (self->queue, &self->out);
continue;
}
- return play(self, spin, size_to_play);
+ return play (self, spin, size_to_play);
}
- GST_DEBUG("[%p]", self);
+ GST_DEBUG ("[%p]", self);
return NULL;
}
-void
-espeak_reset(Econtext *self)
-{
- process_pop(self);
+void espeak_reset (Econtext * self) {
+ process_pop (self);
GstBuffer *buf;
- while ((buf = espeak_out(self, SYNC_BUFFER_SIZE)) != NULL)
- gst_buffer_unref(buf);
+ while ((buf = espeak_out (self, SYNC_BUFFER_SIZE)) != NULL)
+ gst_buffer_unref (buf);
int i;
for (i = SPIN_QUEUE_SIZE; i--;)
- g_atomic_int_set(&self->queue[i].state, IN);
+ g_atomic_int_set (&self->queue[i].state, IN);
- if (self->text)
- {
- g_free(self->text);
+ if (self->text) {
+ g_free (self->text);
self->text = NULL;
}
}
// espeak ----------------------------------------------------------------------
-static gint
-synth_cb(short *data, int numsamples, espeak_EVENT *events)
-{
+static gint synth_cb (short *data, int numsamples, espeak_EVENT * events) {
if (data == NULL)
return 0;
Espin *spin = events->user_data;
Econtext *self = spin->context;
- if (numsamples > 0)
- {
- g_byte_array_append(spin->sound, (const guint8*)data, numsamples*2);
+ if (numsamples > 0) {
+ g_byte_array_append (spin->sound, (const guint8 *) data,
+ numsamples * 2);
espeak_EVENT *i;
- for (i = events; i->type != espeakEVENT_LIST_TERMINATED; ++i)
- {
- GST_DEBUG("type=%d text_position=%d length=%d "
- "audio_position=%d sample=%d",
+ for (i = events; i->type != espeakEVENT_LIST_TERMINATED; ++i) {
+ GST_DEBUG ("type=%d text_position=%d length=%d "
+ "audio_position=%d sample=%d",
i->type, i->text_position, i->length,
- i->audio_position, i->sample*2);
+ i->audio_position, i->sample * 2);
// convert to 0-based position
--i->text_position;
- if (i->type == espeakEVENT_MARK)
- {
+ 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)
- {
+ 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;
}
}
- GST_DEBUG("text_position=%d length=%d",
+ GST_DEBUG ("text_position=%d length=%d",
i->text_position, i->length);
- g_array_append_val(spin->events, *i);
+ g_array_append_val (spin->events, *i);
}
}
- GST_DEBUG("numsamples=%d", numsamples*2);
+ GST_DEBUG ("numsamples=%d", numsamples * 2);
return 0;
}
-static void
-synth(Econtext *self, Espin *spin)
-{
- g_byte_array_set_size(spin->sound, 0);
- g_array_set_size(spin->events, 0);
+static void synth (Econtext * self, Espin * spin) {
+ g_byte_array_set_size (spin->sound, 0);
+ g_array_set_size (spin->events, 0);
spin->sound_offset = 0;
spin->audio_position = 0;
spin->events_pos = 0;
@@ -488,239 +441,205 @@ synth(Econtext *self, Espin *spin)
spin->mark_name = NULL;
spin->last_word = -1;
- espeak_SetParameter(espeakPITCH, g_atomic_int_get(&self->pitch), 0);
- espeak_SetParameter(espeakRATE, g_atomic_int_get(&self->rate), 0);
- espeak_SetVoiceByName((gchar*)g_atomic_pointer_get(&self->voice));
- espeak_SetParameter(espeakWORDGAP, g_atomic_int_get(&self->gap), 0);
+ espeak_SetParameter (espeakPITCH, g_atomic_int_get (&self->pitch), 0);
+ espeak_SetParameter (espeakRATE, g_atomic_int_get (&self->rate), 0);
+ espeak_SetVoiceByName ((gchar *) g_atomic_pointer_get (&self->voice));
+ espeak_SetParameter (espeakWORDGAP, g_atomic_int_get (&self->gap), 0);
- gint track = g_atomic_int_get(&self->track);
+ gint track = g_atomic_int_get (&self->track);
gint flags = espeakCHARS_UTF8;
if (track == ESPEAK_TRACK_MARK)
flags |= espeakSSML;
- GST_DEBUG("[%p] text_offset=%zd", self, self->text_offset);
+ GST_DEBUG ("[%p] text_offset=%zd", self, self->text_offset);
- espeak_Synth(self->text, self->text_len + 1, 0, POS_CHARACTER, 0, flags,
+ espeak_Synth (self->text, self->text_len + 1, 0, POS_CHARACTER, 0, flags,
NULL, spin);
- if (spin->events->len)
- {
- int text_offset = g_array_index(spin->events, espeak_EVENT,
- spin->events->len-1).text_position + 1;
- self->text_offset = g_utf8_offset_to_pointer(self->text, text_offset)
+ if (spin->events->len) {
+ int text_offset = g_array_index (spin->events, espeak_EVENT,
+ spin->events->len - 1).text_position + 1;
+ self->text_offset = g_utf8_offset_to_pointer (self->text, text_offset)
- self->text;
}
espeak_EVENT last_event = { espeakEVENT_LIST_TERMINATED };
last_event.sample = spin->sound->len / 2;
- g_array_append_val(spin->events, last_event);
+ g_array_append_val (spin->events, last_event);
}
-gint
-espeak_get_sample_rate()
-{
+gint espeak_get_sample_rate () {
return espeak_sample_rate;
}
-GValueArray*
-espeak_get_voices()
-{
- init();
- return g_value_array_copy(espeak_voices);
+GValueArray *espeak_get_voices () {
+ init ();
+ return g_value_array_copy (espeak_voices);
}
-void
-espeak_set_pitch(Econtext *self, gint value)
-{
+void espeak_set_pitch (Econtext * self, gint value) {
if (value == 0)
value = 50;
else
- value = MIN(99, (value + 100) / 2);
+ value = MIN (99, (value + 100) / 2);
- g_atomic_int_set(&self->pitch, value);
+ g_atomic_int_set (&self->pitch, value);
}
-void
-espeak_set_rate(Econtext *self, gint value)
-{
+void espeak_set_rate (Econtext * self, gint value) {
if (value == 0)
value = 170;
+ else if (value < 0)
+ value = MAX (80, value + 170);
else
- if (value < 0)
- value = MAX(80, value + 170);
- else
- value = 170 + value * 2;
+ value = 170 + value * 2;
- g_atomic_int_set(&self->rate, value);
+ g_atomic_int_set (&self->rate, value);
}
-void
-espeak_set_voice(Econtext *self, const gchar *value)
-{
- g_atomic_pointer_set(&self->voice, value);
+void espeak_set_voice (Econtext * self, const gchar * value) {
+ g_atomic_pointer_set (&self->voice, value);
}
-void
-espeak_set_gap(Econtext *self, guint value)
-{
- g_atomic_int_set(&self->gap, value);
+void espeak_set_gap (Econtext * self, guint value) {
+ g_atomic_int_set (&self->gap, value);
}
-void
-espeak_set_track(Econtext *self, guint value)
-{
- g_atomic_int_set(&self->track, value);
+void espeak_set_track (Econtext * self, guint value) {
+ g_atomic_int_set (&self->track, value);
}
// process ----------------------------------------------------------------------
-static gpointer
-process(gpointer data)
-{
- g_mutex_lock(process_lock);
+static gpointer process (gpointer data) {
+ g_mutex_lock (process_lock);
- for (;;)
- {
+ for (;;) {
while (process_queue == NULL)
- g_cond_wait(process_cond, process_lock);
+ g_cond_wait (process_cond, process_lock);
- while (process_queue)
- {
- Econtext *context = (Econtext*)process_queue->data;
+ while (process_queue) {
+ Econtext *context = (Econtext *) process_queue->data;
Espin *spin = context->in;
- process_queue = g_slist_remove_link(process_queue, process_queue);
+ process_queue = g_slist_remove_link (process_queue, process_queue);
- if (context->state == CLOSE)
- {
- GST_DEBUG("[%p] session is closed", context);
+ if (context->state == CLOSE) {
+ GST_DEBUG ("[%p] session is closed", context);
continue;
}
- GST_DEBUG("[%p] context->text_offset=%d context->text_len=%d",
+ GST_DEBUG ("[%p] context->text_offset=%d context->text_len=%d",
context, context->text_offset, context->text_len);
- if (context->text_offset >= context->text_len)
- {
- GST_DEBUG("[%p] end of text to process", context);
+ if (context->text_offset >= context->text_len) {
+ GST_DEBUG ("[%p] end of text to process", context);
context->state &= ~INPROCESS;
- }
- else
- {
- synth(context, spin);
- g_atomic_int_set(&spin->state, OUT);
- spinning(context->queue, &context->in);
-
- if (g_atomic_int_get(&context->in->state) == IN)
- {
- GST_DEBUG("[%p] continue to process data", context);
- process_queue = g_slist_concat(process_queue,
+ } else {
+ synth (context, spin);
+ g_atomic_int_set (&spin->state, OUT);
+ spinning (context->queue, &context->in);
+
+ if (g_atomic_int_get (&context->in->state) == IN) {
+ GST_DEBUG ("[%p] continue to process data", context);
+ process_queue = g_slist_concat (process_queue,
context->process_chunk);
- }
- else
- {
- GST_DEBUG("[%p] pause to process data", context);
+ } else {
+ GST_DEBUG ("[%p] pause to process data", context);
context->state &= ~INPROCESS;
}
}
}
- g_cond_broadcast(process_cond);
+ g_cond_broadcast (process_cond);
}
- g_mutex_unlock(process_lock);
+ g_mutex_unlock (process_lock);
return NULL;
}
-static void
-process_push(Econtext *context, gboolean force_in)
-{
- GST_DEBUG("[%p] lock", context);
- g_mutex_lock(process_lock);
+static void process_push (Econtext * context, gboolean force_in) {
+ GST_DEBUG ("[%p] lock", context);
+ g_mutex_lock (process_lock);
if (context->state == CLOSE && !force_in)
- GST_DEBUG("[%p] state=%d", context, context->state);
- else if (context->state != INPROCESS)
- {
+ GST_DEBUG ("[%p] state=%d", context, context->state);
+ else if (context->state != INPROCESS) {
context->state = INPROCESS;
- process_queue = g_slist_concat(process_queue, context->process_chunk);
- g_cond_broadcast(process_cond);
+ process_queue = g_slist_concat (process_queue, context->process_chunk);
+ g_cond_broadcast (process_cond);
}
- g_mutex_unlock(process_lock);
- GST_DEBUG("[%p] unlock", context);
+ g_mutex_unlock (process_lock);
+ GST_DEBUG ("[%p] unlock", context);
}
-static void
-process_pop(Econtext *context)
-{
- GST_DEBUG("[%p] lock", context);
- g_mutex_lock(process_lock);
+static void process_pop (Econtext * context) {
+ GST_DEBUG ("[%p] lock", context);
+ g_mutex_lock (process_lock);
- process_queue = g_slist_remove_link(process_queue, context->process_chunk);
+ process_queue = g_slist_remove_link (process_queue, context->process_chunk);
context->state = CLOSE;
- g_cond_broadcast(process_cond);
+ g_cond_broadcast (process_cond);
- g_mutex_unlock(process_lock);
- GST_DEBUG("[%p] unlock", context);
+ g_mutex_unlock (process_lock);
+ GST_DEBUG ("[%p] unlock", context);
}
// -----------------------------------------------------------------------------
-static void
-init()
-{
+static void init () {
static volatile gsize initialized = 0;
- if (initialized == 0)
- {
+ if (initialized == 0) {
++initialized;
- process_lock = g_mutex_new();
- process_cond = g_cond_new();
- process_tid = g_thread_create(process, NULL, FALSE, NULL);
+ process_lock = g_mutex_new ();
+ process_cond = g_cond_new ();
+ process_tid = g_thread_create (process, NULL, FALSE, NULL);
- espeak_sample_rate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,
+ espeak_sample_rate = espeak_Initialize (AUDIO_OUTPUT_SYNCHRONOUS,
SYNC_BUFFER_SIZE, NULL, 0);
- espeak_SetSynthCallback(synth_cb);
+ espeak_SetSynthCallback (synth_cb);
gsize count = 0;
const espeak_VOICE **i;
- const espeak_VOICE **voices = espeak_ListVoices(NULL);
+ const espeak_VOICE **voices = espeak_ListVoices (NULL);
for (i = voices; *i; ++i)
++count;
- espeak_voices = g_value_array_new(count);
+ espeak_voices = g_value_array_new (count);
- for (i = voices; *i; ++i)
- {
- GValueArray *voice = g_value_array_new(2);
+ for (i = voices; *i; ++i) {
+ GValueArray *voice = g_value_array_new (2);
GValue name = { 0 };
- g_value_init(&name, G_TYPE_STRING);
- g_value_set_static_string(&name, (*i)->name);
- g_value_array_append(voice, &name);
+ g_value_init (&name, G_TYPE_STRING);
+ g_value_set_static_string (&name, (*i)->name);
+ g_value_array_append (voice, &name);
- char *dialect_str = strchr((*i)->languages + 1, '-');
- if (dialect_str) *dialect_str++ = 0;
+ char *dialect_str = strchr ((*i)->languages + 1, '-');
+ if (dialect_str)
+ *dialect_str++ = 0;
GValue lang = { 0 };
- g_value_init(&lang, G_TYPE_STRING);
- g_value_set_static_string(&lang, (*i)->languages + 1);
- g_value_array_append(voice, &lang);
+ g_value_init (&lang, G_TYPE_STRING);
+ g_value_set_static_string (&lang, (*i)->languages + 1);
+ g_value_array_append (voice, &lang);
GValue dialect = { 0 };
- g_value_init(&dialect, G_TYPE_STRING);
- g_value_set_static_string(&dialect, dialect_str ? dialect_str : "none");
- g_value_array_append(voice, &dialect);
+ g_value_init (&dialect, G_TYPE_STRING);
+ g_value_set_static_string (&dialect,
+ dialect_str ? dialect_str : "none");
+ g_value_array_append (voice, &dialect);
GValue voice_value = { 0 };
- g_value_init(&voice_value, G_TYPE_VALUE_ARRAY);
- g_value_set_boxed_take_ownership(&voice_value, voice);
- g_value_array_append(espeak_voices, &voice_value);
- g_value_unset(&voice_value);
+ g_value_init (&voice_value, G_TYPE_VALUE_ARRAY);
+ g_value_set_boxed_take_ownership (&voice_value, voice);
+ g_value_array_append (espeak_voices, &voice_value);
+ g_value_unset (&voice_value);
}
}
}
diff --git a/src/espeak.h b/src/espeak.h
index a9082dd..329466e 100644
--- a/src/espeak.h
+++ b/src/espeak.h
@@ -27,19 +27,19 @@
struct _Econtext;
typedef struct _Econtext Econtext;
-Econtext* espeak_new(GstElement*);
-void espeak_unref(Econtext*);
-
-gint espeak_get_sample_rate();
-GValueArray* espeak_get_voices();
-void espeak_set_pitch(Econtext*, gint);
-void espeak_set_rate(Econtext*, gint);
-void espeak_set_voice(Econtext*, const gchar*);
-void espeak_set_gap(Econtext*, guint);
-void espeak_set_track(Econtext*, guint);
-
-void espeak_in(Econtext*, const gchar *str);
-GstBuffer* espeak_out(Econtext*, gsize size_to_play);
-void espeak_reset(Econtext*);
+Econtext *espeak_new (GstElement *);
+void espeak_unref (Econtext *);
+
+gint espeak_get_sample_rate ();
+GValueArray *espeak_get_voices ();
+void espeak_set_pitch (Econtext *, gint);
+void espeak_set_rate (Econtext *, gint);
+void espeak_set_voice (Econtext *, const gchar *);
+void espeak_set_gap (Econtext *, guint);
+void espeak_set_track (Econtext *, guint);
+
+void espeak_in (Econtext *, const gchar * str);
+GstBuffer *espeak_out (Econtext *, gsize size_to_play);
+void espeak_reset (Econtext *);
#endif
diff --git a/src/gstespeak.c b/src/gstespeak.c
index ed0f6c7..f7a05fa 100644
--- a/src/gstespeak.c
+++ b/src/gstespeak.c
@@ -29,7 +29,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gst/gst.h>
@@ -41,8 +41,7 @@
GST_DEBUG_CATEGORY_STATIC (gst_espeak_debug);
#define GST_CAT_DEFAULT gst_espeak_debug
-enum
-{
+enum {
PROP_0,
PROP_TEXT,
PROP_PITCH,
@@ -54,34 +53,30 @@ enum
PROP_CAPS
};
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
- );
-
-static GstFlowReturn gst_espeak_create(GstBaseSrc*,
- guint64, guint, GstBuffer**);
-static gboolean gst_espeak_start(GstBaseSrc*);
-static gboolean gst_espeak_stop(GstBaseSrc*);
-static gboolean gst_espeak_is_seekable (GstBaseSrc*);
-static void gst_espeak_init_uri(GType);
-static void gst_espeak_finalize(GObject*);
-static void gst_espeak_set_property(GObject*, guint, const GValue*,
- GParamSpec*);
-static void gst_espeak_get_property(GObject*, guint, GValue*, GParamSpec*);
-static GstCaps *gst_espeak_getcaps(GstBaseSrc*);
-
-GST_BOILERPLATE_FULL(GstEspeak, gst_espeak, GstBaseSrc, GST_TYPE_BASE_SRC,
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+static GstFlowReturn gst_espeak_create (GstBaseSrc *,
+ guint64, guint, GstBuffer **);
+static gboolean gst_espeak_start (GstBaseSrc *);
+static gboolean gst_espeak_stop (GstBaseSrc *);
+static gboolean gst_espeak_is_seekable (GstBaseSrc *);
+static void gst_espeak_init_uri (GType);
+static void gst_espeak_finalize (GObject *);
+static void gst_espeak_set_property (GObject *, guint, const GValue *,
+ GParamSpec *);
+static void gst_espeak_get_property (GObject *, guint, GValue *, GParamSpec *);
+static GstCaps *gst_espeak_getcaps (GstBaseSrc *);
+
+GST_BOILERPLATE_FULL (GstEspeak, gst_espeak, GstBaseSrc, GST_TYPE_BASE_SRC,
gst_espeak_init_uri);
/******************************************************************************/
-static void
-gst_espeak_base_init(gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS(gclass);
+static void gst_espeak_base_init (gpointer gclass) {
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
static GstElementDetails details = {
"Espeak",
@@ -90,16 +85,14 @@ gst_espeak_base_init(gpointer gclass)
"Aleksey S. Lim <alsroot@member.fsf.org>"
};
- gst_element_class_set_details(element_class, &details);
+ gst_element_class_set_details (element_class, &details);
- gst_element_class_add_pad_template(element_class,
- gst_static_pad_template_get(&src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_factory));
}
/* initialize the espeak's class */
-static void
-gst_espeak_class_init(GstEspeakClass * klass)
-{
+static void gst_espeak_class_init (GstEspeakClass * klass) {
GObjectClass *gobject_class = (GObjectClass *) klass;
GstBaseSrcClass *basesrc_class = (GstBaseSrcClass *) klass;
@@ -113,38 +106,38 @@ gst_espeak_class_init(GstEspeakClass * klass)
gobject_class->set_property = gst_espeak_set_property;
gobject_class->get_property = gst_espeak_get_property;
- g_object_class_install_property(gobject_class, PROP_TEXT,
- g_param_spec_string("text", "Text",
- "Text to pronounce", NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property(gobject_class, PROP_PITCH,
- g_param_spec_int("pitch", "Pitch adjustment",
- "Pitch adjustment", -100, 100, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property(gobject_class, PROP_RATE,
- g_param_spec_int("rate", "Speed in words per minute",
- "Speed in words per minute", -100, 100, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property(gobject_class, PROP_VOICE,
- g_param_spec_string("voice", "Current voice",
- "Current voice", ESPEAK_DEFAULT_VOICE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property(gobject_class, PROP_GAP,
- g_param_spec_uint("gap", "Gap",
- "Word gap", 0, G_MAXINT, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property(gobject_class, PROP_TRACK,
- g_param_spec_uint("track", "Track",
- "Track espeak events", 0, G_MAXINT, ESPEAK_TRACK_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property(gobject_class, PROP_VOICES,
- g_param_spec_boxed("voices", "List of voices",
- "List of voices", G_TYPE_VALUE_ARRAY,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property(gobject_class, PROP_CAPS,
- g_param_spec_boxed("caps", "Caps",
- "Caps describing the format of the data", GST_TYPE_CAPS,
- G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, PROP_TEXT,
+ g_param_spec_string ("text", "Text",
+ "Text to pronounce", NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_PITCH,
+ g_param_spec_int ("pitch", "Pitch adjustment",
+ "Pitch adjustment", -100, 100, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_RATE,
+ g_param_spec_int ("rate", "Speed in words per minute",
+ "Speed in words per minute", -100, 100, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_VOICE,
+ g_param_spec_string ("voice", "Current voice",
+ "Current voice", ESPEAK_DEFAULT_VOICE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_GAP,
+ g_param_spec_uint ("gap", "Gap",
+ "Word gap", 0, G_MAXINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_TRACK,
+ g_param_spec_uint ("track", "Track",
+ "Track espeak events", 0, G_MAXINT, ESPEAK_TRACK_NONE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_VOICES,
+ g_param_spec_boxed ("voices", "List of voices",
+ "List of voices", G_TYPE_VALUE_ARRAY,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_CAPS,
+ g_param_spec_boxed ("caps", "Caps",
+ "Caps describing the format of the data", GST_TYPE_CAPS,
+ G_PARAM_READABLE));
}
/* initialize the new element
@@ -152,228 +145,204 @@ gst_espeak_class_init(GstEspeakClass * klass)
* set pad calback functions
* initialize instance structure
*/
-static void
-gst_espeak_init (GstEspeak *self, GstEspeakClass *gclass)
-{
+static void gst_espeak_init (GstEspeak * self, GstEspeakClass * gclass) {
self->text = NULL;
self->pitch = 0;
self->rate = 0;
- self->voice = g_strdup(ESPEAK_DEFAULT_VOICE);
- self->voices = espeak_get_voices();
- self->speak = espeak_new(GST_ELEMENT(self));
+ self->voice = g_strdup (ESPEAK_DEFAULT_VOICE);
+ self->voices = espeak_get_voices ();
+ self->speak = espeak_new (GST_ELEMENT (self));
- self->caps = gst_caps_new_simple("audio/x-raw-int",
- "rate", G_TYPE_INT, espeak_get_sample_rate(),
+ self->caps = gst_caps_new_simple ("audio/x-raw-int",
+ "rate", G_TYPE_INT, espeak_get_sample_rate (),
"channels", G_TYPE_INT, 1,
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed", G_TYPE_BOOLEAN, TRUE,
- NULL);
+ "depth", G_TYPE_INT, 16, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
- gst_base_src_set_format(GST_BASE_SRC(self), GST_FORMAT_DEFAULT);
+ gst_base_src_set_format (GST_BASE_SRC (self), GST_FORMAT_DEFAULT);
}
-static void
-gst_espeak_finalize(GObject * self_)
-{
- GstEspeak *self = GST_ESPEAK(self_);
-
- g_free(self->text); self->text = NULL;
- gst_caps_unref(self->caps); self->caps = NULL;
- espeak_unref(self->speak); self->speak = NULL;
- g_free(self->voice); self->voice = NULL;
- g_value_array_free(self->voices); self->voices = NULL;
+static void gst_espeak_finalize (GObject * self_) {
+ GstEspeak *self = GST_ESPEAK (self_);
- G_OBJECT_CLASS(parent_class)->dispose(self_);
+ g_free (self->text);
+ self->text = NULL;
+ gst_caps_unref (self->caps);
+ self->caps = NULL;
+ espeak_unref (self->speak);
+ self->speak = NULL;
+ g_free (self->voice);
+ self->voice = NULL;
+ g_value_array_free (self->voices);
+ self->voices = NULL;
+
+ G_OBJECT_CLASS (parent_class)->dispose (self_);
}
/******************************************************************************/
-static void
-gst_espeak_set_text(GstEspeak *self, const gchar *text)
-{
- g_free(self->text);
- self->text = g_strdup(text);
+static void gst_espeak_set_text (GstEspeak * self, const gchar * text) {
+ g_free (self->text);
+ self->text = g_strdup (text);
}
static void
-gst_espeak_set_property(GObject *object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstEspeak *self = GST_ESPEAK(object);
+gst_espeak_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec) {
+ GstEspeak *self = GST_ESPEAK (object);
switch (prop_id) {
- case PROP_TEXT:
- gst_espeak_set_text(self, g_value_get_string(value));
- break;
- case PROP_PITCH:
- self->pitch = g_value_get_int(value);
- espeak_set_pitch(self->speak, self->pitch);
- break;
- case PROP_RATE:
- self->rate = g_value_get_int(value);
- espeak_set_rate(self->speak, self->rate);
- break;
- case PROP_VOICE:
- self->voice = g_strdup(g_value_get_string(value));
- espeak_set_voice(self->speak, self->voice);
- break;
- case PROP_GAP:
- self->gap = g_value_get_uint(value);
- espeak_set_gap(self->speak, self->gap);
- break;
- case PROP_TRACK:
- self->track = g_value_get_uint(value);
- espeak_set_track(self->speak, self->track);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_TEXT:
+ gst_espeak_set_text (self, g_value_get_string (value));
+ break;
+ case PROP_PITCH:
+ self->pitch = g_value_get_int (value);
+ espeak_set_pitch (self->speak, self->pitch);
+ break;
+ case PROP_RATE:
+ self->rate = g_value_get_int (value);
+ espeak_set_rate (self->speak, self->rate);
+ break;
+ case PROP_VOICE:
+ self->voice = g_strdup (g_value_get_string (value));
+ espeak_set_voice (self->speak, self->voice);
+ break;
+ case PROP_GAP:
+ self->gap = g_value_get_uint (value);
+ espeak_set_gap (self->speak, self->gap);
+ break;
+ case PROP_TRACK:
+ self->track = g_value_get_uint (value);
+ espeak_set_track (self->speak, self->track);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-gst_espeak_get_property(GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstEspeak *self = GST_ESPEAK(object);
+gst_espeak_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec) {
+ GstEspeak *self = GST_ESPEAK (object);
switch (prop_id) {
- case PROP_TEXT:
- g_value_set_string(value, self->text);
- break;
- case PROP_PITCH:
- g_value_set_uint(value, self->pitch);
- break;
- case PROP_RATE:
- g_value_set_uint(value, self->rate);
- break;
- case PROP_VOICE:
- g_value_set_string(value, self->voice);
- break;
- case PROP_GAP:
- g_value_set_uint(value, self->gap);
- break;
- case PROP_TRACK:
- g_value_set_uint(value, self->track);
- break;
- case PROP_VOICES:
- g_value_set_boxed(value, self->voices);
- break;
- case PROP_CAPS:
- gst_value_set_caps(value, self->caps);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_TEXT:
+ g_value_set_string (value, self->text);
+ break;
+ case PROP_PITCH:
+ g_value_set_uint (value, self->pitch);
+ break;
+ case PROP_RATE:
+ g_value_set_uint (value, self->rate);
+ break;
+ case PROP_VOICE:
+ g_value_set_string (value, self->voice);
+ break;
+ case PROP_GAP:
+ g_value_set_uint (value, self->gap);
+ break;
+ case PROP_TRACK:
+ g_value_set_uint (value, self->track);
+ break;
+ case PROP_VOICES:
+ g_value_set_boxed (value, self->voices);
+ break;
+ case PROP_CAPS:
+ gst_value_set_caps (value, self->caps);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
/******************************************************************************/
static GstFlowReturn
-gst_espeak_create(GstBaseSrc * self_, guint64 offset, guint size,
- GstBuffer **buf)
-{
- GstEspeak *self = GST_ESPEAK(self_);
+gst_espeak_create (GstBaseSrc * self_, guint64 offset, guint size,
+ GstBuffer ** buf) {
+ GstEspeak *self = GST_ESPEAK (self_);
- *buf = espeak_out(self->speak, size);
+ *buf = espeak_out (self->speak, size);
- if (*buf)
- {
- gst_buffer_set_caps(*buf, self->caps);
+ if (*buf) {
+ gst_buffer_set_caps (*buf, self->caps);
return GST_FLOW_OK;
- }
- else
+ } else
return GST_FLOW_UNEXPECTED;
}
-static gboolean
-gst_espeak_start(GstBaseSrc * self_)
-{
- GST_DEBUG("gst_espeak_start");
- GstEspeak *self = GST_ESPEAK(self_);
- espeak_in(self->speak, self->text);
+static gboolean gst_espeak_start (GstBaseSrc * self_) {
+ GST_DEBUG ("gst_espeak_start");
+ GstEspeak *self = GST_ESPEAK (self_);
+ espeak_in (self->speak, self->text);
return TRUE;
}
-static gboolean
-gst_espeak_stop(GstBaseSrc * self_)
-{
- GST_DEBUG("gst_espeak_stop");
- GstEspeak *self = GST_ESPEAK(self_);
- espeak_reset(self->speak);
+static gboolean gst_espeak_stop (GstBaseSrc * self_) {
+ GST_DEBUG ("gst_espeak_stop");
+ GstEspeak *self = GST_ESPEAK (self_);
+ espeak_reset (self->speak);
return TRUE;
}
-static gboolean
-gst_espeak_is_seekable(GstBaseSrc * src)
-{
+static gboolean gst_espeak_is_seekable (GstBaseSrc * src) {
return FALSE;
}
-static GstCaps *
-gst_espeak_getcaps(GstBaseSrc *self_)
-{
- GstEspeak *self = GST_ESPEAK(self_);
- return gst_caps_ref(self->caps);
+static GstCaps *gst_espeak_getcaps (GstBaseSrc * self_) {
+ GstEspeak *self = GST_ESPEAK (self_);
+ return gst_caps_ref (self->caps);
}
/******************************************************************************/
-static GstURIType
-gst_espeak_uri_get_type(void)
-{
+static GstURIType gst_espeak_uri_get_type (void) {
return GST_URI_SRC;
}
-static gchar**
-gst_espeak_uri_get_protocols(void)
-{
+static gchar **gst_espeak_uri_get_protocols (void) {
static gchar *protocols[] = { "espeak", NULL };
return protocols;
}
static gboolean
-gst_espeak_uri_set_uri(GstURIHandler *handler, const gchar *uri)
-{
+gst_espeak_uri_set_uri (GstURIHandler * handler, const gchar * uri) {
gchar *protocol, *text;
gboolean ret;
- protocol = gst_uri_get_protocol(uri);
- ret = strcmp(protocol, "espeak") == 0;
- g_free(protocol);
- if (!ret) return FALSE;
+ protocol = gst_uri_get_protocol (uri);
+ ret = strcmp (protocol, "espeak") == 0;
+ g_free (protocol);
+ if (!ret)
+ return FALSE;
- text = gst_uri_get_location(uri);
+ text = gst_uri_get_location (uri);
if (!text)
return FALSE;
- gst_espeak_set_text(GST_ESPEAK(handler), text);
+ gst_espeak_set_text (GST_ESPEAK (handler), text);
g_free (text);
return TRUE;
}
-static void
-gst_espeak_uri_handler_init(gpointer g_iface, gpointer iface_data)
-{
- GstURIHandlerInterface *iface = (GstURIHandlerInterface*) g_iface;
+static void gst_espeak_uri_handler_init (gpointer g_iface, gpointer iface_data) {
+ GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
iface->get_type = gst_espeak_uri_get_type;
iface->get_protocols = gst_espeak_uri_get_protocols;
iface->set_uri = gst_espeak_uri_set_uri;
}
-static void
-gst_espeak_init_uri(GType filesrc_type)
-{
+static void gst_espeak_init_uri (GType filesrc_type) {
static const GInterfaceInfo urihandler_info = {
- gst_espeak_uri_handler_init,
- NULL,
- NULL
+ gst_espeak_uri_handler_init,
+ NULL,
+ NULL
};
g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER,
&urihandler_info);
@@ -385,28 +354,23 @@ gst_espeak_init_uri(GType filesrc_type)
* initialize the plug-in itself
* register the element factories and other features
*/
-static gboolean
-espeak_init(GstPlugin *espeak)
-{
- /* debug category for fltering log messages
- *
- * exchange the string 'Template espeak' with your description
- */
- GST_DEBUG_CATEGORY_INIT (gst_espeak_debug, "espeak",
- 0, "Template espeak");
-
- return gst_element_register (espeak, "espeak", GST_RANK_NONE,
- GST_TYPE_ESPEAK);
+static gboolean espeak_init (GstPlugin * espeak) {
+ /* debug category for fltering log messages
+ *
+ * exchange the string 'Template espeak' with your description
+ */
+ GST_DEBUG_CATEGORY_INIT (gst_espeak_debug, "espeak", 0, "Template espeak");
+
+ return gst_element_register (espeak, "espeak", GST_RANK_NONE,
+ GST_TYPE_ESPEAK);
}
-GST_PLUGIN_DEFINE(
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "espeak",
- "Uses eSpeak library as a sound source for GStreamer",
- espeak_init,
- PACKAGE_VERSION,
- "LGPL",
- PACKAGE_NAME,
- "http://sugarlabs.org/go/DevelopmentTeam/gst-plugins-espeak"
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "espeak",
+ "Uses eSpeak library as a sound source for GStreamer",
+ espeak_init,
+ PACKAGE_VERSION,
+ "LGPL",
+ PACKAGE_NAME,
+ "http://sugarlabs.org/go/DevelopmentTeam/gst-plugins-espeak")
diff --git a/src/gstespeak.h b/src/gstespeak.h
index 60b6806..e4f5ca3 100644
--- a/src/gstespeak.h
+++ b/src/gstespeak.h
@@ -22,7 +22,6 @@
#include <gst/audio/gstaudiosrc.h>
G_BEGIN_DECLS
-
/* #defines don't like whitespacey bits */
#define GST_TYPE_ESPEAK \
(gst_espeak_get_type())
@@ -34,13 +33,11 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ESPEAK))
#define GST_IS_ESPEAK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ESPEAK))
-
-typedef struct _GstEspeak GstEspeak;
+typedef struct _GstEspeak GstEspeak;
typedef struct _GstEspeakClass GstEspeakClass;
struct _Econtext;
-struct _GstEspeak
-{
+struct _GstEspeak {
GstAudioSrc parent;
struct _Econtext *speak;
gchar *text;
@@ -54,13 +51,11 @@ struct _GstEspeak
gboolean poll;
};
-struct _GstEspeakClass
-{
+struct _GstEspeakClass {
GstAudioSrcClass parent_class;
};
GType gst_espeak_get_type (void);
G_END_DECLS
-
#endif /* __GST_ESPEAK_H__ */