summaryrefslogtreecommitdiff
path: root/src/lib/ecore_audio
diff options
context:
space:
mode:
authorDaniel Willmann <d.willmann@samsung.com>2013-04-23 17:10:16 +0100
committerDaniel Willmann <d.willmann@samsung.com>2013-04-23 17:13:39 +0100
commit97d4b50c91adcb8b779f5449b27e2265f2f243f0 (patch)
tree4528951705a4f945f451401a04db900be02e58c2 /src/lib/ecore_audio
parent4e3804041f8e865e007b2a6a0d45a05f39500c3b (diff)
ecore_audio: Add more return values for methods, catch up with API
input_attach, input_detach, format_set, and source_set now return an Eina_Bool Tests, examples and edje_multisense adapted Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
Diffstat (limited to 'src/lib/ecore_audio')
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj.h4
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_in.c2
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c13
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out.c15
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out.h2
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_pulse.c14
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c30
7 files changed, 69 insertions, 11 deletions
diff --git a/src/lib/ecore_audio/ecore_audio_obj.h b/src/lib/ecore_audio/ecore_audio_obj.h
index 87c08b8f25..625aad5ed6 100644
--- a/src/lib/ecore_audio/ecore_audio_obj.h
+++ b/src/lib/ecore_audio/ecore_audio_obj.h
@@ -85,11 +85,11 @@ enum Ecore_Audio_Obj_Sub_Ids
85 85
86#define ecore_audio_obj_volume_get(ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_VOLUME_GET), EO_TYPECHECK(double *, ret) 86#define ecore_audio_obj_volume_get(ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_VOLUME_GET), EO_TYPECHECK(double *, ret)
87 87
88#define ecore_audio_obj_source_set(source) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_SET), EO_TYPECHECK(const char *, source) 88#define ecore_audio_obj_source_set(source, ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_SET), EO_TYPECHECK(const char *, source), EO_TYPECHECK(Eina_Bool *, ret)
89 89
90#define ecore_audio_obj_source_get(source) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_GET), EO_TYPECHECK(const char **, source) 90#define ecore_audio_obj_source_get(source) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_GET), EO_TYPECHECK(const char **, source)
91 91
92#define ecore_audio_obj_format_set(format) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_SET), EO_TYPECHECK(Ecore_Audio_Format, format) 92#define ecore_audio_obj_format_set(format, ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_SET), EO_TYPECHECK(Ecore_Audio_Format, format), EO_TYPECHECK(Eina_Bool *, ret)
93 93
94#define ecore_audio_obj_format_get(ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_GET), EO_TYPECHECK(Ecore_Audio_Format *, ret) 94#define ecore_audio_obj_format_get(ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_GET), EO_TYPECHECK(Ecore_Audio_Format *, ret)
95 95
diff --git a/src/lib/ecore_audio/ecore_audio_obj_in.c b/src/lib/ecore_audio/ecore_audio_obj_in.c
index 1264939f8a..9f80806c37 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in.c
@@ -243,7 +243,7 @@ static void _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
243 Ecore_Audio_Input *obj = _pd; 243 Ecore_Audio_Input *obj = _pd;
244 244
245 if(obj->output) 245 if(obj->output)
246 eo_do(obj->output, ecore_audio_obj_out_input_detach(eo_obj)); 246 eo_do(obj->output, ecore_audio_obj_out_input_detach(eo_obj, NULL));
247 247
248 eo_do_super(eo_obj, MY_CLASS, eo_destructor()); 248 eo_do_super(eo_obj, MY_CLASS, eo_destructor());
249} 249}
diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
index 6dcc9fb591..eee40c41d2 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
@@ -137,6 +137,10 @@ static void _source_set(Eo *eo_obj, void *_pd, va_list *list)
137 Ecore_Audio_Input *in_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS); 137 Ecore_Audio_Input *in_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
138 138
139 const char *source = va_arg(*list, const char *); 139 const char *source = va_arg(*list, const char *);
140 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
141
142 if (ret)
143 *ret = EINA_FALSE;
140 144
141 if (obj->handle) { 145 if (obj->handle) {
142 sf_close(obj->handle); 146 sf_close(obj->handle);
@@ -156,6 +160,9 @@ static void _source_set(Eo *eo_obj, void *_pd, va_list *list)
156 return; 160 return;
157 } 161 }
158 162
163 if (ret)
164 *ret = EINA_TRUE;
165
159 in_obj->seekable = EINA_TRUE; 166 in_obj->seekable = EINA_TRUE;
160 in_obj->length = (double)obj->sfinfo.frames / obj->sfinfo.samplerate; 167 in_obj->length = (double)obj->sfinfo.frames / obj->sfinfo.samplerate;
161 168
@@ -188,6 +195,7 @@ static void _format_set(Eo *eo_obj, void *_pd, va_list *list)
188 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 195 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
189 196
190 Ecore_Audio_Format format= va_arg(*list, Ecore_Audio_Format); 197 Ecore_Audio_Format format= va_arg(*list, Ecore_Audio_Format);
198 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
191 199
192 if (ea_obj->source) { 200 if (ea_obj->source) {
193 ERR("Input is already open - cannot change format"); 201 ERR("Input is already open - cannot change format");
@@ -208,9 +216,14 @@ static void _format_set(Eo *eo_obj, void *_pd, va_list *list)
208 break; 216 break;
209 default: 217 default:
210 ERR("Format not supported!"); 218 ERR("Format not supported!");
219 if (ret)
220 *ret = EINA_FALSE;
211 return; 221 return;
212 } 222 }
213 ea_obj->format = format; 223 ea_obj->format = format;
224
225 if (ret)
226 *ret = EINA_TRUE;
214} 227}
215 228
216static void _format_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 229static void _format_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out.c b/src/lib/ecore_audio/ecore_audio_obj_out.c
index 253cf62ad6..c463240845 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out.c
@@ -35,7 +35,7 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
35 if (in->output == eo_obj) 35 if (in->output == eo_obj)
36 return; 36 return;
37 37
38 if (in->output) eo_do(in->output, ecore_audio_obj_out_input_detach(input)); 38 if (in->output) eo_do(in->output, ecore_audio_obj_out_input_detach(input, NULL));
39 in->output = eo_obj; 39 in->output = eo_obj;
40 40
41 /* TODO: Check type is input 41 /* TODO: Check type is input
@@ -48,15 +48,22 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
48 *ret = EINA_TRUE; 48 *ret = EINA_TRUE;
49} 49}
50 50
51static void _input_detach(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list) 51static void _input_detach(Eo *eo_obj, void *_pd, va_list *list)
52{ 52{
53 Ecore_Audio_Output *obj = _pd; 53 Ecore_Audio_Output *obj = _pd;
54 Ecore_Audio_Input *in; 54 Ecore_Audio_Input *in;
55 55
56 Eo *input = va_arg(*list, Eo *); 56 Eo *input = va_arg(*list, Eo *);
57 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
57 58
58 in = eo_data_get(input, ECORE_AUDIO_OBJ_IN_CLASS); 59 in = eo_data_get(input, ECORE_AUDIO_OBJ_IN_CLASS);
59 60
61 if (ret)
62 *ret = EINA_FALSE;
63
64 if (in->output != eo_obj)
65 return;
66
60 in->output = NULL; 67 in->output = NULL;
61 68
62 /* TODO: Check type is input 69 /* TODO: Check type is input
@@ -65,6 +72,8 @@ static void _input_detach(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
65 72
66 obj->inputs = eina_list_remove(obj->inputs, input); 73 obj->inputs = eina_list_remove(obj->inputs, input);
67 74
75 if (ret)
76 *ret = EINA_TRUE;
68} 77}
69 78
70static void _inputs_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list) 79static void _inputs_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
@@ -91,7 +100,7 @@ static void _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
91 Eo *in; 100 Eo *in;
92 101
93 EINA_LIST_FOREACH_SAFE(obj->inputs, cur, tmp, in) { 102 EINA_LIST_FOREACH_SAFE(obj->inputs, cur, tmp, in) {
94 eo_do(eo_obj, ecore_audio_obj_out_input_detach(in)); 103 eo_do(eo_obj, ecore_audio_obj_out_input_detach(in, NULL));
95 } 104 }
96 105
97 eo_do_super(eo_obj, MY_CLASS, eo_destructor()); 106 eo_do_super(eo_obj, MY_CLASS, eo_destructor());
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out.h b/src/lib/ecore_audio/ecore_audio_obj_out.h
index ec5e9bf773..e42581ffd5 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out.h
+++ b/src/lib/ecore_audio/ecore_audio_obj_out.h
@@ -51,7 +51,7 @@ enum Ecore_Audio_Obj_Out_Sub_Ids
51 51
52#define ecore_audio_obj_out_input_attach(input, ret) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_ATTACH), EO_TYPECHECK(Eo *, input), EO_TYPECHECK(Eina_Bool *, ret) 52#define ecore_audio_obj_out_input_attach(input, ret) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_ATTACH), EO_TYPECHECK(Eo *, input), EO_TYPECHECK(Eina_Bool *, ret)
53 53
54#define ecore_audio_obj_out_input_detach(input) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_DETACH), EO_TYPECHECK(Eo *, input) 54#define ecore_audio_obj_out_input_detach(input, ret) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_DETACH), EO_TYPECHECK(Eo *, input), EO_TYPECHECK(Eina_Bool *, ret)
55 55
56#define ecore_audio_obj_out_inputs_get(input) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUTS_GET), EO_TYPECHECK(Eina_List **, input) 56#define ecore_audio_obj_out_inputs_get(input) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUTS_GET), EO_TYPECHECK(Eina_List **, input)
57 57
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 0232a10e41..4c43d399cf 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c
@@ -131,7 +131,7 @@ static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in)
131 stream = pa_stream_new(class_vars.context, name, &ss, NULL); 131 stream = pa_stream_new(class_vars.context, name, &ss, NULL);
132 if (!stream) { 132 if (!stream) {
133 ERR("Could not create stream"); 133 ERR("Could not create stream");
134 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in)); 134 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL));
135 return EINA_FALSE; 135 return EINA_FALSE;
136 } 136 }
137 137
@@ -185,15 +185,25 @@ static void _drain_cb(pa_stream *stream, int success EINA_UNUSED, void *data EIN
185static void _input_detach(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 185static void _input_detach(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
186{ 186{
187 pa_stream *stream; 187 pa_stream *stream;
188 Eina_Bool ret2;
188 189
189 Eo *in = va_arg(*list, Eo *); 190 Eo *in = va_arg(*list, Eo *);
191 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
192
193 if (ret)
194 *ret = EINA_FALSE;
195
196 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, &ret2));
197 if (!ret2)
198 return;
190 199
191 eo_do(in, eo_base_data_get("pulse_data", (void **)&stream)); 200 eo_do(in, eo_base_data_get("pulse_data", (void **)&stream));
192 201
193 pa_stream_set_write_callback(stream, NULL, NULL); 202 pa_stream_set_write_callback(stream, NULL, NULL);
194 pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL)); 203 pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL));
195 204
196 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in)); 205 if (ret)
206 *ret = EINA_TRUE;
197} 207}
198 208
199static void _state_cb(pa_context *context, void *data EINA_UNUSED) 209static void _state_cb(pa_context *context, void *data EINA_UNUSED)
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 99e89d1838..68c2a3d84f 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
@@ -64,11 +64,17 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
64 Ecore_Audio_Sndfile *obj = _pd; 64 Ecore_Audio_Sndfile *obj = _pd;
65 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 65 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
66 Ecore_Audio_Output *out_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS); 66 Ecore_Audio_Output *out_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
67 Eina_Bool ret2;
67 68
68 Eo *in = va_arg(*list, Eo *); 69 Eo *in = va_arg(*list, Eo *);
69 Eina_Bool *ret = va_arg(*list, Eina_Bool *); 70 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
70 71
71 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, ret)); 72 if (ret)
73 *ret = EINA_FALSE;
74
75 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret2));
76 if (!ret2)
77 return;
72 78
73 eo_do(in, ecore_audio_obj_in_samplerate_get(&obj->sfinfo.samplerate)); 79 eo_do(in, ecore_audio_obj_in_samplerate_get(&obj->sfinfo.samplerate));
74 eo_do(in, ecore_audio_obj_in_channels_get(&obj->sfinfo.channels)); 80 eo_do(in, ecore_audio_obj_in_channels_get(&obj->sfinfo.channels));
@@ -78,9 +84,13 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
78 if (!obj->handle) { 84 if (!obj->handle) {
79 eina_stringshare_del(ea_obj->source); 85 eina_stringshare_del(ea_obj->source);
80 ea_obj->source = NULL; 86 ea_obj->source = NULL;
87 eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL));
81 return; 88 return;
82 } 89 }
83 90
91 if (ret)
92 *ret = EINA_TRUE;
93
84 if (ea_obj->paused) 94 if (ea_obj->paused)
85 return; 95 return;
86 96
@@ -96,6 +106,10 @@ static void _source_set(Eo *eo_obj, void *_pd, va_list *list)
96 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 106 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
97 107
98 const char *source = va_arg(*list, const char *); 108 const char *source = va_arg(*list, const char *);
109 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
110
111 if (ret)
112 *ret = EINA_FALSE;
99 113
100 if (obj->handle) { 114 if (obj->handle) {
101 sf_close(obj->handle); 115 sf_close(obj->handle);
@@ -107,6 +121,11 @@ static void _source_set(Eo *eo_obj, void *_pd, va_list *list)
107 if (!ea_obj->source) 121 if (!ea_obj->source)
108 return; 122 return;
109 123
124 //FIXME: Open the file here
125
126 if (ret)
127 *ret = EINA_TRUE;
128
110} 129}
111 130
112static void _source_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 131static void _source_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
@@ -125,9 +144,12 @@ static void _format_set(Eo *eo_obj, void *_pd, va_list *list)
125 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS); 144 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
126 145
127 Ecore_Audio_Format format= va_arg(*list, Ecore_Audio_Format); 146 Ecore_Audio_Format format= va_arg(*list, Ecore_Audio_Format);
147 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
128 148
129 if (ea_obj->source) { 149 if (ea_obj->source) {
130 ERR("Input is already open - cannot change format"); 150 ERR("Input is already open - cannot change format");
151 if (ret)
152 *ret = EINA_FALSE;
131 return; 153 return;
132 } 154 }
133 155
@@ -145,9 +167,13 @@ static void _format_set(Eo *eo_obj, void *_pd, va_list *list)
145 break; 167 break;
146 default: 168 default:
147 ERR("Format not supported!"); 169 ERR("Format not supported!");
170 if (ret)
171 *ret = EINA_FALSE;
148 return; 172 return;
149 } 173 }
150 ea_obj->format = format; 174 ea_obj->format = format;
175 if (ret)
176 *ret = EINA_TRUE;
151} 177}
152 178
153static void _format_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list) 179static void _format_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
@@ -164,7 +190,7 @@ static void _constructor(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list EINA_U
164{ 190{
165 eo_do_super(eo_obj, MY_CLASS, eo_constructor()); 191 eo_do_super(eo_obj, MY_CLASS, eo_constructor());
166 192
167 eo_do(eo_obj, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG)); 193 eo_do(eo_obj, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG, NULL));
168} 194}
169 195
170static void _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED) 196static void _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)