jackdanielz pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=07da26add95398a7c8b060c0bdf2aba0d65c03a0
commit 07da26add95398a7c8b060c0bdf2aba0d65c03a0 Author: Yossi Kantor <yossi.kan...@samsung.com> Date: Thu Mar 27 14:05:41 2014 +0200 Eolian: Integration of Ecore Audio In Tone --- src/Makefile_Ecore_Audio.am | 10 ++- src/lib/ecore_audio/ecore_audio_in_tone.eo | 12 +++ src/lib/ecore_audio/ecore_audio_obj_in_tone.c | 108 ++++++-------------------- src/lib/ecore_audio/ecore_audio_obj_in_tone.h | 4 +- 4 files changed, 45 insertions(+), 89 deletions(-) diff --git a/src/Makefile_Ecore_Audio.am b/src/Makefile_Ecore_Audio.am index 2696d9b..1f2d3f2 100644 --- a/src/Makefile_Ecore_Audio.am +++ b/src/Makefile_Ecore_Audio.am @@ -14,7 +14,9 @@ BUILT_SOURCES += \ lib/ecore_audio/ecore_audio_out_sndfile.eo.c \ lib/ecore_audio/ecore_audio_out_sndfile.eo.h \ lib/ecore_audio/ecore_audio_out_pulse.eo.c \ - lib/ecore_audio/ecore_audio_out_pulse.eo.h + lib/ecore_audio/ecore_audio_out_pulse.eo.h \ + lib/ecore_audio/ecore_audio_in_tone.eo.c \ + lib/ecore_audio/ecore_audio_in_tone.eo.h ecore_audioeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@ ecore_audioeolianfiles_DATA = \ @@ -23,7 +25,8 @@ ecore_audioeolianfiles_DATA = \ lib/ecore_audio/ecore_audio_out.eo \ lib/ecore_audio/ecore_audio_in_sndfile.eo \ lib/ecore_audio/ecore_audio_out_sndfile.eo \ - lib/ecore_audio/ecore_audio_out_pulse.eo + lib/ecore_audio/ecore_audio_out_pulse.eo \ + lib/ecore_audio/ecore_audio_in_tone.eo EXTRA_DIST += \ ${ecore_audioeolianfiles_DATA} @@ -45,7 +48,8 @@ nodist_installed_ecoreaudiomainheaders_DATA = \ lib/ecore_audio/ecore_audio_out.eo.h \ lib/ecore_audio/ecore_audio_in_sndfile.eo.h \ lib/ecore_audio/ecore_audio_out_sndfile.eo.h \ - lib/ecore_audio/ecore_audio_out_pulse.eo.h + lib/ecore_audio/ecore_audio_out_pulse.eo.h \ + lib/ecore_audio/ecore_audio_in_tone.eo.h lib_ecore_audio_libecore_audio_la_SOURCES = \ lib/ecore_audio/ecore_audio.c \ diff --git a/src/lib/ecore_audio/ecore_audio_in_tone.eo b/src/lib/ecore_audio/ecore_audio_in_tone.eo new file mode 100644 index 0000000..6b3e489 --- /dev/null +++ b/src/lib/ecore_audio/ecore_audio_in_tone.eo @@ -0,0 +1,12 @@ +class Ecore_Audio_In_Tone (Ecore_Audio_In) +{ + eo_prefix: ecore_audio_obj_in_tone; + implements { + Eo_Base::constructor; + Eo_Base::data_set; + Eo_Base::data_get; + Ecore_Audio_In::length::set; + Ecore_Audio_In::seek; + Ecore_Audio_In::read_internal; + } +} \ No newline at end of file diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c index 3d97134..8ba55ad 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c @@ -14,30 +14,23 @@ #include "ecore_audio_private.h" #include <math.h> -EAPI Eo_Op ECORE_AUDIO_OBJ_IN_TONE_BASE_ID = EO_NOOP; - #define MY_CLASS ECORE_AUDIO_OBJ_IN_TONE_CLASS #define MY_CLASS_NAME "Ecore_Audio_In_Tone" -struct _Ecore_Audio_Tone +struct _Ecore_Audio_In_Tone_Data { int freq; int phase; }; -typedef struct _Ecore_Audio_Tone Ecore_Audio_Tone; +typedef struct _Ecore_Audio_In_Tone_Data Ecore_Audio_In_Tone_Data; -static void _tone_read(Eo *eo_obj, void *_pd, va_list *list) +EOLIAN static ssize_t +_ecore_audio_in_tone_ecore_audio_in_read_internal(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, void *data, size_t len) { - int i, remain; - Ecore_Audio_Tone *obj = _pd; + size_t i, remain; Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); - - void *data = va_arg(*list, void *); - int len = va_arg(*list, int); - int *ret = va_arg(*list, int *); - float *val = data; remain = in_obj->length * in_obj->samplerate * 4 - obj->phase * 4; @@ -50,20 +43,15 @@ static void _tone_read(Eo *eo_obj, void *_pd, va_list *list) obj->phase += i; - if (ret) - *ret = remain; + return remain; } -static void _seek(Eo *eo_obj, void *_pd, va_list *list) +EOLIAN static double +_ecore_audio_in_tone_ecore_audio_in_seek(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, double offs, int mode) { int tmp; - Ecore_Audio_Tone *obj = _pd; Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); - double offs = va_arg(*list, double); - int mode = va_arg(*list, int); - double *ret = va_arg(*list, double *); - switch (mode) { case SEEK_SET: tmp = offs * in_obj->samplerate; @@ -82,32 +70,21 @@ static void _seek(Eo *eo_obj, void *_pd, va_list *list) obj->phase = tmp; - if (ret) - *ret = (double)obj->phase / in_obj->samplerate; - - return; + return (double)obj->phase / in_obj->samplerate; err: - if (ret) - *ret = -1.0; + return -1.0; } -static void _length_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) +EOLIAN static void +_ecore_audio_in_tone_ecore_audio_in_length_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *_pd EINA_UNUSED, double length) { Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); - - double length= va_arg(*list, double); - in_obj->length = length; } -static void _data_set(Eo *eo_obj, void *_pd, va_list *list) +EOLIAN static void +_ecore_audio_in_tone_eo_base_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val, eo_base_data_free_func func) { - Ecore_Audio_Tone *obj = _pd; - - const char *key = va_arg(*list, const char *); - const void *val = va_arg(*list, const void *); - eo_base_data_free_func func = va_arg(*list, eo_base_data_free_func); - if (!key) return; if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { @@ -118,25 +95,21 @@ static void _data_set(Eo *eo_obj, void *_pd, va_list *list) } -static void _data_get(Eo *eo_obj, void *_pd, va_list *list) +EOLIAN static void* +_ecore_audio_in_tone_eo_base_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) { - Ecore_Audio_Tone *obj = _pd; - - const char *key = va_arg(*list, const char*); - void **ret = va_arg(*list, void **); - if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { - if (ret) - *(int *)ret = obj->freq; + return (void *)obj->freq; } else { - eo_do_super(eo_obj, MY_CLASS, eo_base_data_get(key, ret)); + void *ret = NULL; + eo_do_super(eo_obj, MY_CLASS, eo_base_data_get(key, &ret)); + return ret; } - } -static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED) +EOLIAN static void +_ecore_audio_in_tone_eo_base_constructor(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj) { - Ecore_Audio_Tone *obj = _pd; Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); eo_do_super(eo_obj, MY_CLASS, eo_constructor()); @@ -149,39 +122,4 @@ static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED) obj->freq = 1000; } -static void _class_constructor(Eo_Class *klass) -{ - const Eo_Op_Func_Description func_desc[] = { - /* Virtual functions of parent class implemented in this class */ - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), - //EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), - - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), _data_get), - EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), _data_set), - - EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_LENGTH_SET), _length_set), - EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_SEEK), _seek), - EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_READ_INTERNAL), _tone_read), - - EO_OP_FUNC_SENTINEL - }; - - eo_class_funcs_set(klass, func_desc); -} - -static const Eo_Op_Description op_desc[] = { - EO_OP_DESCRIPTION_SENTINEL -}; - -static const Eo_Class_Description class_desc = { - EO_VERSION, - MY_CLASS_NAME, - EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(&ECORE_AUDIO_OBJ_IN_TONE_BASE_ID, op_desc, ECORE_AUDIO_OBJ_IN_TONE_SUB_ID_LAST), - NULL, - sizeof(Ecore_Audio_Tone), - _class_constructor, - NULL -}; - -EO_DEFINE_CLASS(ecore_audio_obj_in_tone_class_get, &class_desc, ECORE_AUDIO_OBJ_IN_CLASS, NULL); +#include "ecore_audio_in_tone.eo.c" diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.h b/src/lib/ecore_audio/ecore_audio_obj_in_tone.h index 13bd016..6bfd505 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.h +++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.h @@ -41,6 +41,8 @@ extern "C" */ #define ECORE_AUDIO_ATTR_TONE_FREQ "ecore_audio_freq" +#include "ecore_audio_in_tone.eo.h" +#if 0 #define ECORE_AUDIO_OBJ_IN_TONE_CLASS ecore_audio_obj_in_tone_class_get() /**< Ecore_Audio tone input */ /** @@ -58,7 +60,7 @@ enum Ecore_Audio_Obj_In_Tone_Sub_Ids }; #define ECORE_AUDIO_OBJ_IN_TONE_ID(sub_id) (ECORE_AUDIO_OBJ_IN_TONE_BASE_ID + EO_TYPECHECK(enum Ecore_Audio_Obj_In_Tone_Sub_Ids, sub_id) - +#endif /** * @} */ --