diff options
-rw-r--r-- | src/Makefile_Ecore_Audio.am | 10 | ||||
-rw-r--r-- | src/lib/ecore_audio/ecore_audio_in_tone.eo | 12 | ||||
-rw-r--r-- | src/lib/ecore_audio/ecore_audio_obj_in_tone.c | 108 | ||||
-rw-r--r-- | 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 2696d9b691..1f2d3f28b2 100644 --- a/src/Makefile_Ecore_Audio.am +++ b/src/Makefile_Ecore_Audio.am | |||
@@ -14,7 +14,9 @@ BUILT_SOURCES += \ | |||
14 | lib/ecore_audio/ecore_audio_out_sndfile.eo.c \ | 14 | lib/ecore_audio/ecore_audio_out_sndfile.eo.c \ |
15 | lib/ecore_audio/ecore_audio_out_sndfile.eo.h \ | 15 | lib/ecore_audio/ecore_audio_out_sndfile.eo.h \ |
16 | lib/ecore_audio/ecore_audio_out_pulse.eo.c \ | 16 | lib/ecore_audio/ecore_audio_out_pulse.eo.c \ |
17 | lib/ecore_audio/ecore_audio_out_pulse.eo.h | 17 | lib/ecore_audio/ecore_audio_out_pulse.eo.h \ |
18 | lib/ecore_audio/ecore_audio_in_tone.eo.c \ | ||
19 | lib/ecore_audio/ecore_audio_in_tone.eo.h | ||
18 | 20 | ||
19 | ecore_audioeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@ | 21 | ecore_audioeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@ |
20 | ecore_audioeolianfiles_DATA = \ | 22 | ecore_audioeolianfiles_DATA = \ |
@@ -23,7 +25,8 @@ ecore_audioeolianfiles_DATA = \ | |||
23 | lib/ecore_audio/ecore_audio_out.eo \ | 25 | lib/ecore_audio/ecore_audio_out.eo \ |
24 | lib/ecore_audio/ecore_audio_in_sndfile.eo \ | 26 | lib/ecore_audio/ecore_audio_in_sndfile.eo \ |
25 | lib/ecore_audio/ecore_audio_out_sndfile.eo \ | 27 | lib/ecore_audio/ecore_audio_out_sndfile.eo \ |
26 | lib/ecore_audio/ecore_audio_out_pulse.eo | 28 | lib/ecore_audio/ecore_audio_out_pulse.eo \ |
29 | lib/ecore_audio/ecore_audio_in_tone.eo | ||
27 | 30 | ||
28 | EXTRA_DIST += \ | 31 | EXTRA_DIST += \ |
29 | ${ecore_audioeolianfiles_DATA} | 32 | ${ecore_audioeolianfiles_DATA} |
@@ -45,7 +48,8 @@ nodist_installed_ecoreaudiomainheaders_DATA = \ | |||
45 | lib/ecore_audio/ecore_audio_out.eo.h \ | 48 | lib/ecore_audio/ecore_audio_out.eo.h \ |
46 | lib/ecore_audio/ecore_audio_in_sndfile.eo.h \ | 49 | lib/ecore_audio/ecore_audio_in_sndfile.eo.h \ |
47 | lib/ecore_audio/ecore_audio_out_sndfile.eo.h \ | 50 | lib/ecore_audio/ecore_audio_out_sndfile.eo.h \ |
48 | lib/ecore_audio/ecore_audio_out_pulse.eo.h | 51 | lib/ecore_audio/ecore_audio_out_pulse.eo.h \ |
52 | lib/ecore_audio/ecore_audio_in_tone.eo.h | ||
49 | 53 | ||
50 | lib_ecore_audio_libecore_audio_la_SOURCES = \ | 54 | lib_ecore_audio_libecore_audio_la_SOURCES = \ |
51 | lib/ecore_audio/ecore_audio.c \ | 55 | 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 0000000000..6b3e489368 --- /dev/null +++ b/src/lib/ecore_audio/ecore_audio_in_tone.eo | |||
@@ -0,0 +1,12 @@ | |||
1 | class Ecore_Audio_In_Tone (Ecore_Audio_In) | ||
2 | { | ||
3 | eo_prefix: ecore_audio_obj_in_tone; | ||
4 | implements { | ||
5 | Eo_Base::constructor; | ||
6 | Eo_Base::data_set; | ||
7 | Eo_Base::data_get; | ||
8 | Ecore_Audio_In::length::set; | ||
9 | Ecore_Audio_In::seek; | ||
10 | Ecore_Audio_In::read_internal; | ||
11 | } | ||
12 | } \ 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 3d971343ae..8ba55ada7f 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 @@ | |||
14 | #include "ecore_audio_private.h" | 14 | #include "ecore_audio_private.h" |
15 | #include <math.h> | 15 | #include <math.h> |
16 | 16 | ||
17 | EAPI Eo_Op ECORE_AUDIO_OBJ_IN_TONE_BASE_ID = EO_NOOP; | ||
18 | |||
19 | #define MY_CLASS ECORE_AUDIO_OBJ_IN_TONE_CLASS | 17 | #define MY_CLASS ECORE_AUDIO_OBJ_IN_TONE_CLASS |
20 | #define MY_CLASS_NAME "Ecore_Audio_In_Tone" | 18 | #define MY_CLASS_NAME "Ecore_Audio_In_Tone" |
21 | 19 | ||
22 | struct _Ecore_Audio_Tone | 20 | struct _Ecore_Audio_In_Tone_Data |
23 | { | 21 | { |
24 | int freq; | 22 | int freq; |
25 | int phase; | 23 | int phase; |
26 | }; | 24 | }; |
27 | 25 | ||
28 | typedef struct _Ecore_Audio_Tone Ecore_Audio_Tone; | 26 | typedef struct _Ecore_Audio_In_Tone_Data Ecore_Audio_In_Tone_Data; |
29 | 27 | ||
30 | static void _tone_read(Eo *eo_obj, void *_pd, va_list *list) | 28 | EOLIAN static ssize_t |
29 | _ecore_audio_in_tone_ecore_audio_in_read_internal(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, void *data, size_t len) | ||
31 | { | 30 | { |
32 | int i, remain; | 31 | size_t i, remain; |
33 | Ecore_Audio_Tone *obj = _pd; | ||
34 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); | 32 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); |
35 | 33 | ||
36 | |||
37 | void *data = va_arg(*list, void *); | ||
38 | int len = va_arg(*list, int); | ||
39 | int *ret = va_arg(*list, int *); | ||
40 | |||
41 | float *val = data; | 34 | float *val = data; |
42 | 35 | ||
43 | remain = in_obj->length * in_obj->samplerate * 4 - obj->phase * 4; | 36 | 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) | |||
50 | 43 | ||
51 | obj->phase += i; | 44 | obj->phase += i; |
52 | 45 | ||
53 | if (ret) | 46 | return remain; |
54 | *ret = remain; | ||
55 | } | 47 | } |
56 | 48 | ||
57 | static void _seek(Eo *eo_obj, void *_pd, va_list *list) | 49 | EOLIAN static double |
50 | _ecore_audio_in_tone_ecore_audio_in_seek(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, double offs, int mode) | ||
58 | { | 51 | { |
59 | int tmp; | 52 | int tmp; |
60 | Ecore_Audio_Tone *obj = _pd; | ||
61 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); | 53 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); |
62 | 54 | ||
63 | double offs = va_arg(*list, double); | ||
64 | int mode = va_arg(*list, int); | ||
65 | double *ret = va_arg(*list, double *); | ||
66 | |||
67 | switch (mode) { | 55 | switch (mode) { |
68 | case SEEK_SET: | 56 | case SEEK_SET: |
69 | tmp = offs * in_obj->samplerate; | 57 | tmp = offs * in_obj->samplerate; |
@@ -82,32 +70,21 @@ static void _seek(Eo *eo_obj, void *_pd, va_list *list) | |||
82 | 70 | ||
83 | obj->phase = tmp; | 71 | obj->phase = tmp; |
84 | 72 | ||
85 | if (ret) | 73 | return (double)obj->phase / in_obj->samplerate; |
86 | *ret = (double)obj->phase / in_obj->samplerate; | ||
87 | |||
88 | return; | ||
89 | err: | 74 | err: |
90 | if (ret) | 75 | return -1.0; |
91 | *ret = -1.0; | ||
92 | } | 76 | } |
93 | 77 | ||
94 | static void _length_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) | 78 | EOLIAN static void |
79 | _ecore_audio_in_tone_ecore_audio_in_length_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *_pd EINA_UNUSED, double length) | ||
95 | { | 80 | { |
96 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); | 81 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); |
97 | |||
98 | double length= va_arg(*list, double); | ||
99 | |||
100 | in_obj->length = length; | 82 | in_obj->length = length; |
101 | } | 83 | } |
102 | 84 | ||
103 | static void _data_set(Eo *eo_obj, void *_pd, va_list *list) | 85 | EOLIAN static void |
86 | _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) | ||
104 | { | 87 | { |
105 | Ecore_Audio_Tone *obj = _pd; | ||
106 | |||
107 | const char *key = va_arg(*list, const char *); | ||
108 | const void *val = va_arg(*list, const void *); | ||
109 | eo_base_data_free_func func = va_arg(*list, eo_base_data_free_func); | ||
110 | |||
111 | if (!key) return; | 88 | if (!key) return; |
112 | 89 | ||
113 | if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { | 90 | if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { |
@@ -118,25 +95,21 @@ static void _data_set(Eo *eo_obj, void *_pd, va_list *list) | |||
118 | 95 | ||
119 | } | 96 | } |
120 | 97 | ||
121 | static void _data_get(Eo *eo_obj, void *_pd, va_list *list) | 98 | EOLIAN static void* |
99 | _ecore_audio_in_tone_eo_base_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key) | ||
122 | { | 100 | { |
123 | Ecore_Audio_Tone *obj = _pd; | ||
124 | |||
125 | const char *key = va_arg(*list, const char*); | ||
126 | void **ret = va_arg(*list, void **); | ||
127 | |||
128 | if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { | 101 | if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) { |
129 | if (ret) | 102 | return (void *)obj->freq; |
130 | *(int *)ret = obj->freq; | ||
131 | } else { | 103 | } else { |
132 | eo_do_super(eo_obj, MY_CLASS, eo_base_data_get(key, ret)); | 104 | void *ret = NULL; |
105 | eo_do_super(eo_obj, MY_CLASS, eo_base_data_get(key, &ret)); | ||
106 | return ret; | ||
133 | } | 107 | } |
134 | |||
135 | } | 108 | } |
136 | 109 | ||
137 | static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED) | 110 | EOLIAN static void |
111 | _ecore_audio_in_tone_eo_base_constructor(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj) | ||
138 | { | 112 | { |
139 | Ecore_Audio_Tone *obj = _pd; | ||
140 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); | 113 | Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); |
141 | 114 | ||
142 | eo_do_super(eo_obj, MY_CLASS, eo_constructor()); | 115 | 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) | |||
149 | obj->freq = 1000; | 122 | obj->freq = 1000; |
150 | } | 123 | } |
151 | 124 | ||
152 | static void _class_constructor(Eo_Class *klass) | 125 | #include "ecore_audio_in_tone.eo.c" |
153 | { | ||
154 | const Eo_Op_Func_Description func_desc[] = { | ||
155 | /* Virtual functions of parent class implemented in this class */ | ||
156 | EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), | ||
157 | //EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), | ||
158 | |||
159 | EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), _data_get), | ||
160 | EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), _data_set), | ||
161 | |||
162 | EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_LENGTH_SET), _length_set), | ||
163 | EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_SEEK), _seek), | ||
164 | EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_READ_INTERNAL), _tone_read), | ||
165 | |||
166 | EO_OP_FUNC_SENTINEL | ||
167 | }; | ||
168 | |||
169 | eo_class_funcs_set(klass, func_desc); | ||
170 | } | ||
171 | |||
172 | static const Eo_Op_Description op_desc[] = { | ||
173 | EO_OP_DESCRIPTION_SENTINEL | ||
174 | }; | ||
175 | |||
176 | static const Eo_Class_Description class_desc = { | ||
177 | EO_VERSION, | ||
178 | MY_CLASS_NAME, | ||
179 | EO_CLASS_TYPE_REGULAR, | ||
180 | EO_CLASS_DESCRIPTION_OPS(&ECORE_AUDIO_OBJ_IN_TONE_BASE_ID, op_desc, ECORE_AUDIO_OBJ_IN_TONE_SUB_ID_LAST), | ||
181 | NULL, | ||
182 | sizeof(Ecore_Audio_Tone), | ||
183 | _class_constructor, | ||
184 | NULL | ||
185 | }; | ||
186 | |||
187 | EO_DEFINE_CLASS(ecore_audio_obj_in_tone_class_get, &class_desc, ECORE_AUDIO_OBJ_IN_CLASS, NULL); | ||
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 13bd01645c..6bfd505a28 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" | |||
41 | */ | 41 | */ |
42 | #define ECORE_AUDIO_ATTR_TONE_FREQ "ecore_audio_freq" | 42 | #define ECORE_AUDIO_ATTR_TONE_FREQ "ecore_audio_freq" |
43 | 43 | ||
44 | #include "ecore_audio_in_tone.eo.h" | ||
45 | #if 0 | ||
44 | #define ECORE_AUDIO_OBJ_IN_TONE_CLASS ecore_audio_obj_in_tone_class_get() /**< Ecore_Audio tone input */ | 46 | #define ECORE_AUDIO_OBJ_IN_TONE_CLASS ecore_audio_obj_in_tone_class_get() /**< Ecore_Audio tone input */ |
45 | 47 | ||
46 | /** | 48 | /** |
@@ -58,7 +60,7 @@ enum Ecore_Audio_Obj_In_Tone_Sub_Ids | |||
58 | }; | 60 | }; |
59 | 61 | ||
60 | #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) | 62 | #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) |
61 | 63 | #endif | |
62 | /** | 64 | /** |
63 | * @} | 65 | * @} |
64 | */ | 66 | */ |