summaryrefslogtreecommitdiff
path: root/src/lib/ecore_audio
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-03-27 14:05:41 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-04-02 15:56:14 +0300
commit07da26add95398a7c8b060c0bdf2aba0d65c03a0 (patch)
tree4bc2712acd733de985d7dfef2d9d899223284ae5 /src/lib/ecore_audio
parent7876846f016b3e1d3a4104723361763f2697eb3b (diff)
Eolian: Integration of Ecore Audio In Tone
Diffstat (limited to 'src/lib/ecore_audio')
-rw-r--r--src/lib/ecore_audio/ecore_audio_in_tone.eo12
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_in_tone.c108
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_in_tone.h4
3 files changed, 38 insertions, 86 deletions
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 @@
1class 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
17EAPI 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
22struct _Ecore_Audio_Tone 20struct _Ecore_Audio_In_Tone_Data
23{ 21{
24 int freq; 22 int freq;
25 int phase; 23 int phase;
26}; 24};
27 25
28typedef struct _Ecore_Audio_Tone Ecore_Audio_Tone; 26typedef struct _Ecore_Audio_In_Tone_Data Ecore_Audio_In_Tone_Data;
29 27
30static void _tone_read(Eo *eo_obj, void *_pd, va_list *list) 28EOLIAN 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
57static void _seek(Eo *eo_obj, void *_pd, va_list *list) 49EOLIAN 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;
89err: 74err:
90 if (ret) 75 return -1.0;
91 *ret = -1.0;
92} 76}
93 77
94static void _length_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 78EOLIAN 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
103static void _data_set(Eo *eo_obj, void *_pd, va_list *list) 85EOLIAN 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
121static void _data_get(Eo *eo_obj, void *_pd, va_list *list) 98EOLIAN 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
137static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED) 110EOLIAN 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
152static 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
172static const Eo_Op_Description op_desc[] = {
173 EO_OP_DESCRIPTION_SENTINEL
174};
175
176static 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
187EO_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 */