summaryrefslogtreecommitdiff
path: root/src/lib/ecore_audio
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-03-27 11:53:26 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-04-02 15:56:14 +0300
commit88860a209e1bb7dd292f58ab653e496a8b44e3b6 (patch)
treedead2b6ffa38b3bfcbc8bba945b18d830f016dd8 /src/lib/ecore_audio
parent6295d77a3c7d20c94a5d460692be30139784935b (diff)
Eolian: Integration of Ecore Audio Out Sndfile
Diffstat (limited to 'src/lib/ecore_audio')
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c127
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_sndfile.h3
-rw-r--r--src/lib/ecore_audio/ecore_audio_out_sndfile.eo13
3 files changed, 47 insertions, 96 deletions
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
index 282c22a419..d1ca3b5263 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
@@ -14,28 +14,26 @@
14#include "ecore_audio_private.h" 14#include "ecore_audio_private.h"
15#include <sndfile.h> 15#include <sndfile.h>
16 16
17EAPI Eo_Op ECORE_AUDIO_OBJ_OUT_SNDFILE_BASE_ID = EO_NOOP;
18
19#define MY_CLASS ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS 17#define MY_CLASS ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS
20#define MY_CLASS_NAME "Ecore_Audio_Out_Sndfile" 18#define MY_CLASS_NAME "Ecore_Audio_Out_Sndfile"
21 19
22extern SF_VIRTUAL_IO vio_wrapper; 20extern SF_VIRTUAL_IO vio_wrapper;
23 21
24struct _Ecore_Audio_Sndfile 22struct _Ecore_Audio_Out_Sndfile_Data
25{ 23{
26 SNDFILE *handle; 24 SNDFILE *handle;
27 SF_INFO sfinfo; 25 SF_INFO sfinfo;
28 Ecore_Audio_Vio *vio; 26 Ecore_Audio_Vio *vio;
29}; 27};
30 28
31typedef struct _Ecore_Audio_Sndfile Ecore_Audio_Sndfile; 29typedef struct _Ecore_Audio_Out_Sndfile_Data Ecore_Audio_Out_Sndfile_Data;
32 30
33static Eina_Bool _write_cb(void *data) 31static Eina_Bool _write_cb(void *data)
34{ 32{
35 Eo *eo_obj = data; 33 Eo *eo_obj = data;
36 Eo *in; 34 Eo *in;
37 35
38 Ecore_Audio_Sndfile *obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS); 36 Ecore_Audio_Out_Sndfile_Data *obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS);
39 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); 37 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
40 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 38 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
41 39
@@ -61,22 +59,16 @@ static Eina_Bool _write_cb(void *data)
61 return EINA_TRUE; 59 return EINA_TRUE;
62} 60}
63 61
64static void _input_attach(Eo *eo_obj, void *_pd, va_list *list) 62EOLIAN static Eina_Bool
63_ecore_audio_out_sndfile_ecore_audio_out_input_attach(Eo *eo_obj, Ecore_Audio_Out_Sndfile_Data *obj, Eo *in)
65{ 64{
66 Ecore_Audio_Sndfile *obj = _pd;
67 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 65 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
68 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); 66 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
69 Eina_Bool ret2; 67 Eina_Bool ret2;
70 68
71 Eo *in = va_arg(*list, Eo *);
72 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
73
74 if (ret)
75 *ret = EINA_FALSE;
76
77 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret2)); 69 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret2));
78 if (!ret2) 70 if (!ret2)
79 return; 71 return EINA_FALSE;
80 72
81 eo_do(in, ecore_audio_obj_in_samplerate_get(&obj->sfinfo.samplerate)); 73 eo_do(in, ecore_audio_obj_in_samplerate_get(&obj->sfinfo.samplerate));
82 eo_do(in, ecore_audio_obj_in_channels_get(&obj->sfinfo.channels)); 74 eo_do(in, ecore_audio_obj_in_channels_get(&obj->sfinfo.channels));
@@ -87,32 +79,24 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
87 eina_stringshare_del(ea_obj->source); 79 eina_stringshare_del(ea_obj->source);
88 ea_obj->source = NULL; 80 ea_obj->source = NULL;
89 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL)); 81 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL));
90 return; 82 return EINA_FALSE;
91 } 83 }
92 84
93 if (ret)
94 *ret = EINA_TRUE;
95
96 if (ea_obj->paused) 85 if (ea_obj->paused)
97 return; 86 return EINA_TRUE;
98 87
99 if (out_obj->inputs) { 88 if (out_obj->inputs) {
100 out_obj->write_idler = ecore_idler_add(_write_cb, eo_obj); 89 out_obj->write_idler = ecore_idler_add(_write_cb, eo_obj);
101 } 90 }
91
92 return EINA_TRUE;
102} 93}
103 94
104static void _source_set(Eo *eo_obj, void *_pd, va_list *list) 95EOLIAN static Eina_Bool
96_ecore_audio_out_sndfile_ecore_audio_source_set(Eo *eo_obj, Ecore_Audio_Out_Sndfile_Data *obj, const char *source)
105{ 97{
106 Ecore_Audio_Sndfile *obj = _pd;
107
108 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 98 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
109 99
110 const char *source = va_arg(*list, const char *);
111 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
112
113 if (ret)
114 *ret = EINA_FALSE;
115
116 if (obj->handle) { 100 if (obj->handle) {
117 sf_close(obj->handle); 101 sf_close(obj->handle);
118 obj->handle = NULL; 102 obj->handle = NULL;
@@ -121,38 +105,28 @@ static void _source_set(Eo *eo_obj, void *_pd, va_list *list)
121 eina_stringshare_replace(&ea_obj->source, source); 105 eina_stringshare_replace(&ea_obj->source, source);
122 106
123 if (!ea_obj->source) 107 if (!ea_obj->source)
124 return; 108 return EINA_FALSE;
125 109
126 //FIXME: Open the file here 110 //FIXME: Open the file here
127 111
128 if (ret) 112 return EINA_TRUE;
129 *ret = EINA_TRUE;
130
131} 113}
132 114
133static void _source_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 115EOLIAN static const char*
116_ecore_audio_out_sndfile_ecore_audio_source_get(Eo *eo_obj, Ecore_Audio_Out_Sndfile_Data *_pd EINA_UNUSED)
134{ 117{
135 Ecore_Audio_Object *obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 118 Ecore_Audio_Object *obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
136 119 return obj->source;
137 const char **ret = va_arg(*list, const char **);
138
139 if (ret)
140 *ret = obj->source;
141} 120}
142 121
143static void _format_set(Eo *eo_obj, void *_pd, va_list *list) 122EOLIAN static Eina_Bool
123_ecore_audio_out_sndfile_ecore_audio_format_set(Eo *eo_obj, Ecore_Audio_Out_Sndfile_Data *obj, Ecore_Audio_Format format)
144{ 124{
145 Ecore_Audio_Sndfile *obj = _pd;
146 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 125 Ecore_Audio_Object *ea_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
147 126
148 Ecore_Audio_Format format= va_arg(*list, Ecore_Audio_Format);
149 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
150
151 if (ea_obj->source) { 127 if (ea_obj->source) {
152 ERR("Input is already open - cannot change format"); 128 ERR("Input is already open - cannot change format");
153 if (ret) 129 return EINA_FALSE;
154 *ret = EINA_FALSE;
155 return;
156 } 130 }
157 131
158 switch (format) { 132 switch (format) {
@@ -170,26 +144,22 @@ static void _format_set(Eo *eo_obj, void *_pd, va_list *list)
170 break; 144 break;
171 default: 145 default:
172 ERR("Format not supported!"); 146 ERR("Format not supported!");
173 if (ret) 147 return EINA_FALSE;
174 *ret = EINA_FALSE;
175 return;
176 } 148 }
177 ea_obj->format = format; 149 ea_obj->format = format;
178 if (ret) 150
179 *ret = EINA_TRUE; 151 return EINA_TRUE;
180} 152}
181 153
182static void _format_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 154EOLIAN static Ecore_Audio_Format
155_ecore_audio_out_sndfile_ecore_audio_format_get(Eo *eo_obj, Ecore_Audio_Out_Sndfile_Data *_pd EINA_UNUSED)
183{ 156{
184 Ecore_Audio_Object *obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 157 Ecore_Audio_Object *obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
185 158 return obj->format;
186 Ecore_Audio_Format *ret = va_arg(*list, Ecore_Audio_Format *);
187
188 if (ret)
189 *ret = obj->format;
190} 159}
191 160
192static void _constructor(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 161EOLIAN static void
162_ecore_audio_out_sndfile_eo_base_constructor(Eo *eo_obj, Ecore_Audio_Out_Sndfile_Data *_pd EINA_UNUSED)
193{ 163{
194 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); 164 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
195 165
@@ -201,9 +171,9 @@ static void _constructor(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list EINA_U
201 out_obj->need_writer = EINA_FALSE; 171 out_obj->need_writer = EINA_FALSE;
202} 172}
203 173
204static void _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED) 174EOLIAN static void
175_ecore_audio_out_sndfile_eo_base_destructor(Eo *eo_obj, Ecore_Audio_Out_Sndfile_Data *obj)
205{ 176{
206 Ecore_Audio_Sndfile *obj = _pd;
207 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); 177 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
208 178
209 if (obj->handle) 179 if (obj->handle)
@@ -214,39 +184,4 @@ static void _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
214 eo_do_super(eo_obj, MY_CLASS, eo_destructor()); 184 eo_do_super(eo_obj, MY_CLASS, eo_destructor());
215} 185}
216 186
217static void _class_constructor(Eo_Class *klass) 187#include "ecore_audio_out_sndfile.eo.c"
218{
219 const Eo_Op_Func_Description func_desc[] = {
220 /* Virtual functions of parent class implemented in this class */
221 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
222 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
223
224 EO_OP_FUNC(ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_SET), _source_set),
225 EO_OP_FUNC(ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_GET), _source_get),
226 EO_OP_FUNC(ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_SET), _format_set),
227 EO_OP_FUNC(ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_GET), _format_get),
228
229 EO_OP_FUNC(ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_ATTACH), _input_attach),
230 //EO_OP_FUNC(ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_FORMAT_GET), _format_get),
231 EO_OP_FUNC_SENTINEL
232 };
233
234 eo_class_funcs_set(klass, func_desc);
235}
236
237static const Eo_Op_Description op_desc[] = {
238 EO_OP_DESCRIPTION_SENTINEL
239};
240
241static const Eo_Class_Description class_desc = {
242 EO_VERSION,
243 MY_CLASS_NAME,
244 EO_CLASS_TYPE_REGULAR,
245 EO_CLASS_DESCRIPTION_OPS(&ECORE_AUDIO_OBJ_OUT_SNDFILE_BASE_ID, op_desc, ECORE_AUDIO_OBJ_OUT_SNDFILE_SUB_ID_LAST),
246 NULL,
247 sizeof(Ecore_Audio_Sndfile),
248 _class_constructor,
249 NULL
250};
251
252EO_DEFINE_CLASS(ecore_audio_obj_out_sndfile_class_get, &class_desc, ECORE_AUDIO_OBJ_OUT_CLASS, NULL);
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.h b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.h
index 818abbe646..f72d5c86c6 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.h
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.h
@@ -33,6 +33,8 @@ extern "C"
33 * @ingroup Ecore_Audio_Group 33 * @ingroup Ecore_Audio_Group
34 * @{ 34 * @{
35 */ 35 */
36#include "ecore_audio_out_sndfile.eo.h"
37#if 0
36 38
37#define ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS ecore_audio_obj_out_sndfile_class_get() /**< Ecore_Audio sndfile output */ 39#define ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS ecore_audio_obj_out_sndfile_class_get() /**< Ecore_Audio sndfile output */
38 40
@@ -52,6 +54,7 @@ enum _Ecore_Audio_Obj_Out_Sndfile_Sub_Ids
52 54
53#define ECORE_AUDIO_OBJ_OUT_SNDFILE_ID(sub_id) (ECORE_AUDIO_OBJ_OUT_SNDFILE_BASE_ID + EO_TYPECHECK(enum _Ecore_Audio_Obj_Out_Sndfile_Sub_Ids, sub_id)) 55#define ECORE_AUDIO_OBJ_OUT_SNDFILE_ID(sub_id) (ECORE_AUDIO_OBJ_OUT_SNDFILE_BASE_ID + EO_TYPECHECK(enum _Ecore_Audio_Obj_Out_Sndfile_Sub_Ids, sub_id))
54 56
57#endif
55/** 58/**
56 * @} 59 * @}
57 */ 60 */
diff --git a/src/lib/ecore_audio/ecore_audio_out_sndfile.eo b/src/lib/ecore_audio/ecore_audio_out_sndfile.eo
new file mode 100644
index 0000000000..2164949119
--- /dev/null
+++ b/src/lib/ecore_audio/ecore_audio_out_sndfile.eo
@@ -0,0 +1,13 @@
1class Ecore_Audio_Out_Sndfile (Ecore_Audio_Out)
2{
3 eo_prefix: ecore_audio_obj_out_sndfile;
4 implements {
5 Eo_Base::constructor;
6 Eo_Base::destructor;
7 Ecore_Audio::source::get;
8 Ecore_Audio::source::set;
9 Ecore_Audio::format::get;
10 Ecore_Audio::format::set;
11 Ecore_Audio_Out::input_attach;
12 }
13} \ No newline at end of file