summaryrefslogtreecommitdiff
path: root/src/examples/ecore/ecore_audio_playback.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/ecore/ecore_audio_playback.c')
-rw-r--r--src/examples/ecore/ecore_audio_playback.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/examples/ecore/ecore_audio_playback.c b/src/examples/ecore/ecore_audio_playback.c
index 95ab90a..f1624e0 100644
--- a/src/examples/ecore/ecore_audio_playback.c
+++ b/src/examples/ecore/ecore_audio_playback.c
@@ -30,19 +30,19 @@ handle_cmd(char *cmd, size_t bread)
30 if (!out) 30 if (!out)
31 return; 31 return;
32 32
33 eo_do(out, ecore_audio_obj_out_inputs_get(&out_inputs)); 33 ecore_audio_obj_out_inputs_get(out, &out_inputs);
34 EINA_LIST_FOREACH(out_inputs, input, in) 34 EINA_LIST_FOREACH(out_inputs, input, in)
35 { 35 {
36 eo_do(in, ecore_audio_obj_in_seek(0, SEEK_CUR, &pos)); 36 ecore_audio_obj_in_seek(in, 0, SEEK_CUR, &pos);
37 if (!strncmp(cmd, "<", bread)) 37 if (!strncmp(cmd, "<", bread))
38 eo_do(in, ecore_audio_obj_in_seek(-10, SEEK_CUR, &pos)); 38 ecore_audio_obj_in_seek(in, -10, SEEK_CUR, &pos);
39 else if (!strncmp(cmd, ">", bread)) 39 else if (!strncmp(cmd, ">", bread))
40 eo_do(in, ecore_audio_obj_in_seek(10, SEEK_CUR, &pos)); 40 ecore_audio_obj_in_seek(in, 10, SEEK_CUR, &pos);
41 41
42 min = pos / 60; 42 min = pos / 60;
43 43
44 eo_do(in, ecore_audio_obj_name_get(&name)); 44 ecore_audio_obj_name_get(in, &name);
45 eo_do(in, ecore_audio_obj_in_length_get(&length)); 45 ecore_audio_obj_in_length_get(in, &length);
46 printf("Position: %2im %5.02fs (%0.2f%%) - %s\n", min, pos - min * 60, pos/length*100, name); 46 printf("Position: %2im %5.02fs (%0.2f%%) - %s\n", min, pos - min * 60, pos/length*100, name);
47 47
48 } 48 }
@@ -53,7 +53,7 @@ handle_cmd(char *cmd, size_t bread)
53 else if (!strncmp(cmd, "n", bread)) 53 else if (!strncmp(cmd, "n", bread))
54 { 54 {
55 in = eina_list_data_get(out_inputs); 55 in = eina_list_data_get(out_inputs);
56 eo_do(out, ret = ecore_audio_obj_out_input_detach(in)); 56 ret = ecore_audio_obj_out_input_detach(out, in);
57 if (!ret) 57 if (!ret)
58 printf("Could not detach input\n"); 58 printf("Could not detach input\n");
59 59
@@ -63,11 +63,11 @@ handle_cmd(char *cmd, size_t bread)
63 { 63 {
64 in = (Eo *)eina_list_data_get(inputs); 64 in = (Eo *)eina_list_data_get(inputs);
65 65
66 eo_do(in, ecore_audio_obj_name_get(&name), 66 ecore_audio_obj_name_get(in, &name);
67 ecore_audio_obj_in_length_get(&length)); 67 ecore_audio_obj_in_length_get(in, &length);
68 68
69 printf("Start: %s (%0.2fs)\n", name, length); 69 printf("Start: %s (%0.2fs)\n", name, length);
70 eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); 70 ret = ecore_audio_obj_out_input_attach(out, in);
71 if (!ret) 71 if (!ret)
72 printf("Could not attach input %s\n", name); 72 printf("Could not attach input %s\n", name);
73 } 73 }
@@ -84,11 +84,11 @@ handle_cmd(char *cmd, size_t bread)
84 { 84 {
85 in = (Eo *)eina_list_data_get(inputs); 85 in = (Eo *)eina_list_data_get(inputs);
86 86
87 eo_do(in, ecore_audio_obj_name_get(&name), 87 ecore_audio_obj_name_get(in, &name);
88 ecore_audio_obj_in_length_get(&length)); 88 ecore_audio_obj_in_length_get(in, &length);
89 89
90 printf("Start: %s (%0.2fs)\n", name, length); 90 printf("Start: %s (%0.2fs)\n", name, length);
91 eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); 91 ret = ecore_audio_obj_out_input_attach(out, in);
92 if (!ret) 92 if (!ret)
93 printf("Could not attach input %s\n", name); 93 printf("Could not attach input %s\n", name);
94 } 94 }
@@ -98,25 +98,25 @@ handle_cmd(char *cmd, size_t bread)
98 EINA_LIST_FOREACH(out_inputs, input, in) 98 EINA_LIST_FOREACH(out_inputs, input, in)
99 { 99 {
100 Eina_Bool loop; 100 Eina_Bool loop;
101 eo_do(in, ecore_audio_obj_in_looped_get(&loop), 101 ecore_audio_obj_in_looped_get(in, &loop);
102 ecore_audio_obj_name_get(&name)); 102 ecore_audio_obj_name_get(in, &name);
103 103
104 printf("%s song %s\n", !loop?"Looping":"Not looping", name); 104 printf("%s song %s\n", !loop?"Looping":"Not looping", name);
105 eo_do(in, ecore_audio_obj_in_looped_set(!loop)); 105 ecore_audio_obj_in_looped_set(in, !loop);
106 } 106 }
107 } 107 }
108 else if (!strncmp(cmd, "+", bread)) 108 else if (!strncmp(cmd, "+", bread))
109 { 109 {
110 if (volume < 1.5) 110 if (volume < 1.5)
111 volume += 0.01; 111 volume += 0.01;
112 eo_do(out, ecore_audio_obj_volume_set(volume)); 112 ecore_audio_obj_volume_set(out, volume);
113 printf("Volume: %3.0f%%\n", volume * 100); 113 printf("Volume: %3.0f%%\n", volume * 100);
114 } 114 }
115 else if (!strncmp(cmd, "-", bread)) 115 else if (!strncmp(cmd, "-", bread))
116 { 116 {
117 if (volume > 0) 117 if (volume > 0)
118 volume -= 0.01; 118 volume -= 0.01;
119 eo_do(out, ecore_audio_obj_volume_set(volume)); 119 ecore_audio_obj_volume_set(out, volume);
120 printf("Volume: %3.0f%%\n", volume * 100); 120 printf("Volume: %3.0f%%\n", volume * 100);
121 } 121 }
122 else if (!strncmp(cmd, "*", bread)) 122 else if (!strncmp(cmd, "*", bread))
@@ -124,11 +124,11 @@ handle_cmd(char *cmd, size_t bread)
124 double speed; 124 double speed;
125 EINA_LIST_FOREACH(out_inputs, input, in) 125 EINA_LIST_FOREACH(out_inputs, input, in)
126 { 126 {
127 eo_do(in, ecore_audio_obj_in_speed_get(&speed)); 127 ecore_audio_obj_in_speed_get(in, &speed);
128 if (speed < 2.0) 128 if (speed < 2.0)
129 speed += 0.01; 129 speed += 0.01;
130 eo_do(in, ecore_audio_obj_in_speed_set(speed), 130 ecore_audio_obj_in_speed_set(in, speed);
131 ecore_audio_obj_name_get(&name)); 131 ecore_audio_obj_name_get(in, &name);
132 printf("Speed: %3.0f%% (%s)\n", speed * 100, name); 132 printf("Speed: %3.0f%% (%s)\n", speed * 100, name);
133 } 133 }
134 } 134 }
@@ -137,11 +137,11 @@ handle_cmd(char *cmd, size_t bread)
137 double speed; 137 double speed;
138 EINA_LIST_FOREACH(out_inputs, input, in) 138 EINA_LIST_FOREACH(out_inputs, input, in)
139 { 139 {
140 eo_do(in, ecore_audio_obj_in_speed_get(&speed)); 140 ecore_audio_obj_in_speed_get(in, &speed);
141 if (speed > 0.5) 141 if (speed > 0.5)
142 speed -= 0.01; 142 speed -= 0.01;
143 eo_do(in, ecore_audio_obj_in_speed_set(speed), 143 ecore_audio_obj_in_speed_set(in, speed);
144 ecore_audio_obj_name_get(&name)); 144 ecore_audio_obj_name_get(in, &name);
145 printf("Speed: %3.0f%% (%s)\n", speed * 100, name); 145 printf("Speed: %3.0f%% (%s)\n", speed * 100, name);
146 } 146 }
147 } 147 }
@@ -149,11 +149,11 @@ handle_cmd(char *cmd, size_t bread)
149 { 149 {
150 EINA_LIST_FOREACH(out_inputs, input, in) 150 EINA_LIST_FOREACH(out_inputs, input, in)
151 { 151 {
152 eo_do(in, ecore_audio_obj_paused_get(&paused), 152 ecore_audio_obj_paused_get(in, &paused);
153 ecore_audio_obj_name_get(&name), 153 ecore_audio_obj_name_get(in, &name);
154 ecore_audio_obj_in_remaining_get(&length)); 154 ecore_audio_obj_in_remaining_get(in, &length);
155 printf("%s %s\n%0.2f remaining\n", !paused ? "Paused" : "Unpaused", name, length); 155 printf("%s %s\n%0.2f remaining\n", !paused ? "Paused" : "Unpaused", name, length);
156 eo_do(in, ecore_audio_obj_paused_set(!paused)); 156 ecore_audio_obj_paused_set(in, !paused);
157 } 157 }
158 } 158 }
159 else if (!strncmp(cmd, "q", bread)) 159 else if (!strncmp(cmd, "q", bread))
@@ -196,11 +196,11 @@ static Eina_Bool _play_finished(void *data EINA_UNUSED, const Eo_Event *event)
196 const char *name; 196 const char *name;
197 Eina_Bool ret; 197 Eina_Bool ret;
198 198
199 eo_do(event->obj, ecore_audio_obj_name_get(&name)); 199 ecore_audio_obj_name_get(event->obj, &name);
200 printf("Done: %s\n", name); 200 printf("Done: %s\n", name);
201 201
202 inputs = eina_list_remove(inputs, event->obj); 202 inputs = eina_list_remove(inputs, event->obj);
203 eo_do(out, ret = ecore_audio_obj_out_input_detach(event->obj)); 203 ret = ecore_audio_obj_out_input_detach(out, event->obj);
204 eo_del(event->obj); 204 eo_del(event->obj);
205 205
206 if (!ret) 206 if (!ret)
@@ -212,9 +212,9 @@ static Eina_Bool _play_finished(void *data EINA_UNUSED, const Eo_Event *event)
212 const char *name; 212 const char *name;
213 Eo *in = (Eo *)eina_list_data_get(inputs); 213 Eo *in = (Eo *)eina_list_data_get(inputs);
214 214
215 eo_do(in, ecore_audio_obj_name_get(&name)); 215 ecore_audio_obj_name_get(in, &name);
216 printf("Start: %s\n", name); 216 printf("Start: %s\n", name);
217 eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); 217 ret = ecore_audio_obj_out_input_attach(out, in);
218 if (!ret) 218 if (!ret)
219 printf("Could not attach input %s\n", name); 219 printf("Could not attach input %s\n", name);
220 } 220 }
@@ -266,13 +266,13 @@ main(int argc, const char *argv[])
266 { 266 {
267 if (!strncmp(val, "freq=", 5)) { 267 if (!strncmp(val, "freq=", 5)) {
268 freq = atoi(&val[5]); 268 freq = atoi(&val[5]);
269 eo_do(in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq)); 269 eo_key_data_set(in, ECORE_AUDIO_ATTR_TONE_FREQ, &freq);
270 } else if (!strncmp(val, "duration=", 9)) { 270 } else if (!strncmp(val, "duration=", 9)) {
271 eo_do(in, ecore_audio_obj_in_length_set(atof(&val[9]))); 271 ecore_audio_obj_in_length_set(in, atof(&val[9]));
272 } 272 }
273 } 273 }
274 free(tmp); 274 free(tmp);
275 eo_do(in, ecore_audio_obj_name_set(argv[i])); 275 ecore_audio_obj_name_set(in, argv[i]);
276 } 276 }
277 else 277 else
278 { 278 {
@@ -283,15 +283,15 @@ main(int argc, const char *argv[])
283 goto end; 283 goto end;
284 } 284 }
285 tmp = strdup(argv[i]); 285 tmp = strdup(argv[i]);
286 eo_do(in, ecore_audio_obj_name_set(basename(tmp))); 286 ecore_audio_obj_name_set(in, basename(tmp));
287 free(tmp); 287 free(tmp);
288 eo_do(in, ret = ecore_audio_obj_source_set(argv[i])); 288 ret = ecore_audio_obj_source_set(in, argv[i]);
289 if (!ret) { 289 if (!ret) {
290 printf("Could not set %s as input\n", argv[i]); 290 printf("Could not set %s as input\n", argv[i]);
291 continue; 291 continue;
292 } 292 }
293 } 293 }
294 eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL)); 294 eo_event_callback_add(in, ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL);
295 inputs = eina_list_append(inputs, in); 295 inputs = eina_list_append(inputs, in);
296 } 296 }
297 297
@@ -302,13 +302,13 @@ main(int argc, const char *argv[])
302 if (!in) 302 if (!in)
303 return 1; 303 return 1;
304 304
305 eo_do(in, ecore_audio_obj_name_get(&name), 305 ecore_audio_obj_name_get(in, &name);
306 ecore_audio_obj_in_length_get(&length)); 306 ecore_audio_obj_in_length_get(in, &length);
307 307
308 printf("Start: %s (%0.2fs)\n", name, length); 308 printf("Start: %s (%0.2fs)\n", name, length);
309 309
310 out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL); 310 out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
311 eo_do(out, ret = ecore_audio_obj_out_input_attach(in)); 311 ret = ecore_audio_obj_out_input_attach(out, in);
312 if (!ret) 312 if (!ret)
313 printf("Could not attach input %s\n", name); 313 printf("Could not attach input %s\n", name);
314 314