diff options
Diffstat (limited to 'navit/speech.c')
-rw-r--r-- | navit/speech.c | 148 |
1 files changed, 71 insertions, 77 deletions
diff --git a/navit/speech.c b/navit/speech.c index d1ebcc276..75cf10f92 100644 --- a/navit/speech.c +++ b/navit/speech.c @@ -26,63 +26,60 @@ #include "xmlconfig.h" struct speech { - NAVIT_OBJECT; - struct speech_priv *priv; - struct speech_methods meth; + NAVIT_OBJECT; + struct speech_priv *priv; + struct speech_methods meth; }; struct speech * -speech_new(struct attr *parent, struct attr **attrs) -{ - struct speech *this_; - struct speech_priv *(*speech_new)(struct speech_methods *meth, struct attr **attrs, struct attr *parent); - struct attr *attr; - - attr=attr_search(attrs, NULL, attr_type); - if (! attr) { - dbg(lvl_error,"type missing"); - return NULL; - } - dbg(lvl_debug,"type='%s'", attr->u.str); - speech_new=plugin_get_category_speech(attr->u.str); - dbg(lvl_debug,"new=%p", speech_new); - if (! speech_new) { - dbg(lvl_error,"wrong type '%s'", attr->u.str); - return NULL; - } - this_=(struct speech *)navit_object_new(attrs, &speech_func, sizeof(struct speech)); - this_->priv=speech_new(&this_->meth, this_->attrs, parent); - dbg(lvl_debug, "say=%p", this_->meth.say); - dbg(lvl_debug,"priv=%p", this_->priv); - if (! this_->priv) { - speech_destroy(this_); - return NULL; - } - dbg(lvl_debug,"return %p", this_); - - return this_; +speech_new(struct attr *parent, struct attr **attrs) { + struct speech *this_; + struct speech_priv *(*speech_new)(struct speech_methods *meth, struct attr **attrs, struct attr *parent); + struct attr *attr; + + attr=attr_search(attrs, NULL, attr_type); + if (! attr) { + dbg(lvl_error,"type missing"); + return NULL; + } + dbg(lvl_debug,"type='%s'", attr->u.str); + speech_new=plugin_get_category_speech(attr->u.str); + dbg(lvl_debug,"new=%p", speech_new); + if (! speech_new) { + dbg(lvl_error,"wrong type '%s'", attr->u.str); + return NULL; + } + this_=(struct speech *)navit_object_new(attrs, &speech_func, sizeof(struct speech)); + this_->priv=speech_new(&this_->meth, this_->attrs, parent); + dbg(lvl_debug, "say=%p", this_->meth.say); + dbg(lvl_debug,"priv=%p", this_->priv); + if (! this_->priv) { + speech_destroy(this_); + return NULL; + } + dbg(lvl_debug,"return %p", this_); + + return this_; } void -speech_destroy(struct speech *this_) -{ - if (this_->priv) - this_->meth.destroy(this_->priv); - navit_object_destroy((struct navit_object *)this_); +speech_destroy(struct speech *this_) { + if (this_->priv) + this_->meth.destroy(this_->priv); + navit_object_destroy((struct navit_object *)this_); } int -speech_say(struct speech *this_, const char *text) -{ - dbg(lvl_debug, "this_=%p text='%s' calling %p", this_, text, this_->meth.say); - return (this_->meth.say)(this_->priv, text); +speech_say(struct speech *this_, const char *text) { + dbg(lvl_debug, "this_=%p text='%s' calling %p", this_, text, this_->meth.say); + return (this_->meth.say)(this_->priv, text); } struct attr active=ATTR_INT(active, 1); -struct attr *speech_default_attrs[]={ - &active, - NULL, +struct attr *speech_default_attrs[]= { + &active, + NULL, }; /** @@ -96,9 +93,8 @@ struct attr *speech_default_attrs[]={ */ int -speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) -{ - return attr_generic_get_attr(this_->attrs, speech_default_attrs, type, attr, iter); +speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) { + return attr_generic_get_attr(this_->attrs, speech_default_attrs, type, attr, iter); } /** @@ -113,18 +109,17 @@ speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, st * @return Time in tenth of seconds or -1 on error */ int -speech_estimate_duration(struct speech *this_, char *str) -{ - int count; - struct attr cps_attr; - - if (!speech_get_attr(this_,attr_cps,&cps_attr,NULL)) { - return -1; - } - - count = strlen(str); - - return (count * 10) / cps_attr.u.num; +speech_estimate_duration(struct speech *this_, char *str) { + int count; + struct attr cps_attr; + + if (!speech_get_attr(this_,attr_cps,&cps_attr,NULL)) { + return -1; + } + + count = strlen(str); + + return (count * 10) / cps_attr.u.num; } /** @@ -140,26 +135,25 @@ speech_estimate_duration(struct speech *this_, char *str) */ int -speech_set_attr(struct speech *this_, struct attr *attr) -{ - this_->attrs=attr_generic_set_attr(this_->attrs, attr); - //callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); - return 1; +speech_set_attr(struct speech *this_, struct attr *attr) { + this_->attrs=attr_generic_set_attr(this_->attrs, attr); + //callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); + return 1; } struct object_func speech_func = { - attr_speech, - (object_func_new)speech_new, - (object_func_get_attr)speech_get_attr, - (object_func_iter_new)navit_object_attr_iter_new, - (object_func_iter_destroy)navit_object_attr_iter_destroy, - (object_func_set_attr)speech_set_attr, - (object_func_add_attr)navit_object_add_attr, - (object_func_remove_attr)navit_object_remove_attr, - (object_func_init)NULL, - (object_func_destroy)speech_destroy, - (object_func_dup)NULL, - (object_func_ref)navit_object_ref, - (object_func_unref)navit_object_unref, + attr_speech, + (object_func_new)speech_new, + (object_func_get_attr)speech_get_attr, + (object_func_iter_new)navit_object_attr_iter_new, + (object_func_iter_destroy)navit_object_attr_iter_destroy, + (object_func_set_attr)speech_set_attr, + (object_func_add_attr)navit_object_add_attr, + (object_func_remove_attr)navit_object_remove_attr, + (object_func_init)NULL, + (object_func_destroy)speech_destroy, + (object_func_dup)NULL, + (object_func_ref)navit_object_ref, + (object_func_unref)navit_object_unref, }; |