summaryrefslogtreecommitdiff
path: root/src/lib/ecore_audio
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-03-27 13:34:01 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-04-02 15:56:14 +0300
commit7876846f016b3e1d3a4104723361763f2697eb3b (patch)
tree2ac3ed0c51d499521b1ae6c63214a1b89f64fae8 /src/lib/ecore_audio
parent88860a209e1bb7dd292f58ab653e496a8b44e3b6 (diff)
Eolian: Integration of Ecore Audio Out Pulse
Diffstat (limited to 'src/lib/ecore_audio')
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_pulse.c100
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_pulse.h6
-rw-r--r--src/lib/ecore_audio/ecore_audio_out_pulse.eo15
3 files changed, 41 insertions, 80 deletions
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
index f94f4999ba..8e7fc6d900 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
@@ -20,19 +20,9 @@
20 20
21extern pa_mainloop_api functable; 21extern pa_mainloop_api functable;
22 22
23EAPI Eo_Op ECORE_AUDIO_OBJ_OUT_PULSE_BASE_ID = EO_NOOP;
24
25#define MY_CLASS ECORE_AUDIO_OBJ_OUT_PULSE_CLASS 23#define MY_CLASS ECORE_AUDIO_OBJ_OUT_PULSE_CLASS
26#define MY_CLASS_NAME "Ecore_Audio_Out_Pulse" 24#define MY_CLASS_NAME "Ecore_Audio_Out_Pulse"
27 25
28EAPI const Eo_Event_Description _ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY =
29 EO_EVENT_DESCRIPTION("context,ready", "Called when the output is ready for playback.");
30#define ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY (&(_ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY))
31EAPI const Eo_Event_Description _ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL =
32 EO_EVENT_DESCRIPTION("context,fail", "Called when context fails.");
33#define ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL (&(_ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL))
34
35
36struct _Ecore_Audio_Pulse_Class { 26struct _Ecore_Audio_Pulse_Class {
37 pa_mainloop_api *api; 27 pa_mainloop_api *api;
38 pa_context *context; 28 pa_context *context;
@@ -45,14 +35,15 @@ static struct _Ecore_Audio_Pulse_Class class_vars = {
45 .api = &functable, 35 .api = &functable,
46}; 36};
47 37
48struct _Ecore_Audio_Pulse 38struct _Ecore_Audio_Out_Pulse_Data
49{ 39{
50 char *foo; 40 char *foo;
51}; 41};
52 42
53typedef struct _Ecore_Audio_Pulse Ecore_Audio_Pulse; 43typedef struct _Ecore_Audio_Out_Pulse_Data Ecore_Audio_Out_Pulse_Data;
54 44
55static void _volume_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 45EOLIAN static void
46_ecore_audio_out_pulse_ecore_audio_volume_set(Eo *eo_obj, Ecore_Audio_Out_Pulse_Data *_pd EINA_UNUSED, double volume)
56{ 47{
57 Eo *in; 48 Eo *in;
58 pa_stream *stream; 49 pa_stream *stream;
@@ -61,8 +52,6 @@ static void _volume_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
61 pa_cvolume pa_volume; 52 pa_cvolume pa_volume;
62 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); 53 Ecore_Audio_Output *out_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
63 54
64 double volume = va_arg(*list, double);
65
66 if (volume < 0) 55 if (volume < 0)
67 volume = 0; 56 volume = 0;
68 57
@@ -158,28 +147,26 @@ static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in)
158static Eina_Bool _delayed_attach_cb(void *data, Eo *eo_obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 147static Eina_Bool _delayed_attach_cb(void *data, Eo *eo_obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
159{ 148{
160 Eo *in = data; 149 Eo *in = data;
161 eo_do(eo_obj, eo_event_callback_del(ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY, _delayed_attach_cb, in)); 150 eo_do(eo_obj, eo_event_callback_del(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_READY, _delayed_attach_cb, in));
162 151
163 _input_attach_internal(eo_obj, in); 152 _input_attach_internal(eo_obj, in);
164 153
165 return EINA_TRUE; 154 return EINA_TRUE;
166} 155}
167 156
168static void _input_attach(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 157EOLIAN static Eina_Bool
158_ecore_audio_out_pulse_ecore_audio_out_input_attach(Eo *eo_obj, Ecore_Audio_Out_Pulse_Data *_pd EINA_UNUSED, Eo *in)
169{ 159{
170 Eina_Bool retval = EINA_TRUE; 160 Eina_Bool retval = EINA_TRUE;
171 161
172 Eo *in = va_arg(*list, Eo *);
173 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
174
175 if (class_vars.state != PA_CONTEXT_READY) { 162 if (class_vars.state != PA_CONTEXT_READY) {
176 DBG("Delaying input_attach because PA context is not ready."); 163 DBG("Delaying input_attach because PA context is not ready.");
177 eo_do(eo_obj, eo_event_callback_add(ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY, _delayed_attach_cb, in)); 164 eo_do(eo_obj, eo_event_callback_add(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_READY, _delayed_attach_cb, in));
178 } else { 165 } else {
179 retval = _input_attach_internal(eo_obj, in); 166 retval = _input_attach_internal(eo_obj, in);
180 } 167 }
181 if (ret) 168
182 *ret = retval; 169 return retval;
183} 170}
184 171
185static void _drain_cb(pa_stream *stream, int success EINA_UNUSED, void *data EINA_UNUSED) 172static void _drain_cb(pa_stream *stream, int success EINA_UNUSED, void *data EINA_UNUSED)
@@ -188,28 +175,22 @@ static void _drain_cb(pa_stream *stream, int success EINA_UNUSED, void *data EIN
188 pa_stream_unref(stream); 175 pa_stream_unref(stream);
189} 176}
190 177
191static void _input_detach(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 178EOLIAN static Eina_Bool
179_ecore_audio_out_pulse_ecore_audio_out_input_detach(Eo *eo_obj, Ecore_Audio_Out_Pulse_Data *_pd EINA_UNUSED, Eo *in)
192{ 180{
193 pa_stream *stream; 181 pa_stream *stream;
194 Eina_Bool ret2; 182 Eina_Bool ret2;
195 183
196 Eo *in = va_arg(*list, Eo *);
197 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
198
199 if (ret)
200 *ret = EINA_FALSE;
201
202 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, &ret2)); 184 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, &ret2));
203 if (!ret2) 185 if (!ret2)
204 return; 186 return EINA_FALSE;
205 187
206 eo_do(in, eo_base_data_get("pulse_data", (void **)&stream)); 188 eo_do(in, eo_base_data_get("pulse_data", (void **)&stream));
207 189
208 pa_stream_set_write_callback(stream, NULL, NULL); 190 pa_stream_set_write_callback(stream, NULL, NULL);
209 pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL)); 191 pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL));
210 192
211 if (ret) 193 return EINA_TRUE;
212 *ret = EINA_TRUE;
213} 194}
214 195
215static void _state_cb(pa_context *context, void *data EINA_UNUSED) 196static void _state_cb(pa_context *context, void *data EINA_UNUSED)
@@ -229,12 +210,12 @@ static void _state_cb(pa_context *context, void *data EINA_UNUSED)
229 if (state == PA_CONTEXT_READY) { 210 if (state == PA_CONTEXT_READY) {
230 DBG("PA context ready."); 211 DBG("PA context ready.");
231 EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) { 212 EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) {
232 eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY, NULL, NULL)); 213 eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_READY, NULL, NULL));
233 } 214 }
234 } else if ((state == PA_CONTEXT_FAILED) || (state == PA_CONTEXT_TERMINATED)) { 215 } else if ((state == PA_CONTEXT_FAILED) || (state == PA_CONTEXT_TERMINATED)) {
235 DBG("PA context fail."); 216 DBG("PA context fail.");
236 EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) { 217 EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) {
237 eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL, NULL, NULL)); 218 eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_FAIL, NULL, NULL));
238 } 219 }
239 } else { 220 } else {
240 DBG("Connection state %i", state); 221 DBG("Connection state %i", state);
@@ -260,7 +241,7 @@ static void _state_job(void *data EINA_UNUSED)
260 } 241 }
261 // the callback here can delete things in the list.. 242 // the callback here can delete things in the list..
262 EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) { 243 EINA_LIST_FOREACH(class_vars.outputs, out, eo_obj) {
263 eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL, NULL, NULL)); 244 eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_OUT_PULSE_EVENT_CONTEXT_FAIL, NULL, NULL));
264 } 245 }
265 // now unref everything safely 246 // now unref everything safely
266 EINA_LIST_FOREACH_SAFE(class_vars.outputs, out, tmp, eo_obj) { 247 EINA_LIST_FOREACH_SAFE(class_vars.outputs, out, tmp, eo_obj) {
@@ -270,7 +251,8 @@ static void _state_job(void *data EINA_UNUSED)
270 class_vars.state_job = NULL; 251 class_vars.state_job = NULL;
271} 252}
272 253
273static void _constructor(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 254EOLIAN static void
255_ecore_audio_out_pulse_eo_base_constructor(Eo *eo_obj, Ecore_Audio_Out_Pulse_Data *_pd EINA_UNUSED)
274{ 256{
275 int argc; 257 int argc;
276 char **argv; 258 char **argv;
@@ -297,49 +279,11 @@ static void _constructor(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list EINA_U
297 class_vars.state_job = ecore_job_add(_state_job, NULL); 279 class_vars.state_job = ecore_job_add(_state_job, NULL);
298} 280}
299 281
300static void _destructor(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 282EOLIAN static void
283_ecore_audio_out_pulse_eo_base_destructor(Eo *eo_obj, Ecore_Audio_Out_Pulse_Data *_pd EINA_UNUSED)
301{ 284{
302 class_vars.outputs = eina_list_remove(class_vars.outputs, eo_obj); 285 class_vars.outputs = eina_list_remove(class_vars.outputs, eo_obj);
303 eo_do_super(eo_obj, MY_CLASS, eo_destructor()); 286 eo_do_super(eo_obj, MY_CLASS, eo_destructor());
304} 287}
305 288
306static void _class_constructor(Eo_Class *klass) 289#include "ecore_audio_out_pulse.eo.c"
307{
308 const Eo_Op_Func_Description func_desc[] = {
309 /* Virtual functions of parent class implemented in this class */
310 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
311 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
312
313 EO_OP_FUNC(ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_VOLUME_SET), _volume_set),
314
315 EO_OP_FUNC(ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_ATTACH), _input_attach),
316 EO_OP_FUNC(ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_DETACH), _input_detach),
317 EO_OP_FUNC_SENTINEL
318 };
319
320 eo_class_funcs_set(klass, func_desc);
321}
322
323static const Eo_Op_Description op_desc[] = {
324 EO_OP_DESCRIPTION_SENTINEL
325};
326
327static const Eo_Event_Description *event_desc[] = {
328 ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY,
329 ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL,
330 NULL
331};
332
333
334static const Eo_Class_Description class_desc = {
335 EO_VERSION,
336 MY_CLASS_NAME,
337 EO_CLASS_TYPE_REGULAR,
338 EO_CLASS_DESCRIPTION_OPS(&ECORE_AUDIO_OBJ_OUT_PULSE_BASE_ID, op_desc, ECORE_AUDIO_OBJ_OUT_PULSE_SUB_ID_LAST),
339 event_desc,
340 sizeof(Ecore_Audio_Pulse),
341 _class_constructor,
342 NULL
343};
344
345EO_DEFINE_CLASS(ecore_audio_obj_out_pulse_class_get, &class_desc, ECORE_AUDIO_OBJ_OUT_CLASS, NULL);
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.h b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.h
index 667ae5630e..a8e11ad246 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.h
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.h
@@ -33,7 +33,8 @@ extern "C"
33 * @ingroup Ecore_Audio_Group 33 * @ingroup Ecore_Audio_Group
34 * @{ 34 * @{
35 */ 35 */
36 36#include "ecore_audio_out_pulse.eo.h"
37#if 0
37#define ECORE_AUDIO_OBJ_OUT_PULSE_CLASS ecore_audio_obj_out_pulse_class_get() /**< Ecore_Audio pulseaudio output */ 38#define ECORE_AUDIO_OBJ_OUT_PULSE_CLASS ecore_audio_obj_out_pulse_class_get() /**< Ecore_Audio pulseaudio output */
38 39
39/** 40/**
@@ -73,7 +74,8 @@ extern EAPI const Eo_Event_Description _ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL;
73 * Emitted when the outout context has failed. At this point the output is unusable and will never work, so it is advisable to delete it. 74 * Emitted when the outout context has failed. At this point the output is unusable and will never work, so it is advisable to delete it.
74 */ 75 */
75#define ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL (&(_ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL)) 76#define ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL (&(_ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_FAIL))
76 77
78#endif
77/** 79/**
78 * @} 80 * @}
79 */ 81 */
diff --git a/src/lib/ecore_audio/ecore_audio_out_pulse.eo b/src/lib/ecore_audio/ecore_audio_out_pulse.eo
new file mode 100644
index 0000000000..8c4b886c2c
--- /dev/null
+++ b/src/lib/ecore_audio/ecore_audio_out_pulse.eo
@@ -0,0 +1,15 @@
1class Ecore_Audio_Out_Pulse (Ecore_Audio_Out)
2{
3 eo_prefix: ecore_audio_obj_out_pulse;
4 implements {
5 Eo_Base::constructor;
6 Eo_Base::destructor;
7 Ecore_Audio::volume::set;
8 Ecore_Audio_Out::input_attach;
9 Ecore_Audio_Out::input_detach;
10 }
11 events {
12 context,ready; /*@ Called when the output is ready for playback. */
13 context,fail; /*@ Called when context fails. */
14 }
15} \ No newline at end of file