diff options
author | Cedric BAIL <cedric.bail@free.fr> | 2011-12-28 16:10:10 +0000 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2011-12-28 16:10:10 +0000 |
commit | 521c66c9e5f6371fddc34b868744a9716d49f36c (patch) | |
tree | c05278bc3b4b2c7912e6ea6a1d4f1691ec8e4cec /legacy/ethumb | |
parent | 8296e98d8b9e33445f1370d0a082303ebd6f9adf (diff) |
ethumb: make plugin API fully assynchronous and use it in emotion backend.
NOTE: epdf isn't asynchronous at the moment, so no need to fix its ethumb plugin.
SVN revision: 66607
Diffstat (limited to 'legacy/ethumb')
-rw-r--r-- | legacy/ethumb/src/lib/Ethumb_Plugin.h | 3 | ||||
-rw-r--r-- | legacy/ethumb/src/lib/ethumb.c | 16 | ||||
-rw-r--r-- | legacy/ethumb/src/lib/ethumb_private.h | 4 | ||||
-rw-r--r-- | legacy/ethumb/src/plugins/emotion/emotion.c | 49 | ||||
-rw-r--r-- | legacy/ethumb/src/plugins/epdf/epdf.c | 1 |
5 files changed, 58 insertions, 15 deletions
diff --git a/legacy/ethumb/src/lib/Ethumb_Plugin.h b/legacy/ethumb/src/lib/Ethumb_Plugin.h index 6dda23b390..3eb6f020cd 100644 --- a/legacy/ethumb/src/lib/Ethumb_Plugin.h +++ b/legacy/ethumb/src/lib/Ethumb_Plugin.h | |||
@@ -10,7 +10,8 @@ typedef struct _Ethumb_Plugin Ethumb_Plugin; | |||
10 | struct _Ethumb_Plugin | 10 | struct _Ethumb_Plugin |
11 | { | 11 | { |
12 | const char **extensions; | 12 | const char **extensions; |
13 | void (*generate_thumb)(Ethumb *); | 13 | void *(*thumb_generate)(Ethumb *); |
14 | void (*thumb_cancel)(Ethumb *, void *); | ||
14 | }; | 15 | }; |
15 | 16 | ||
16 | EAPI void ethumb_calculate_aspect_from_ratio(Ethumb *e, float ia, int *w, int *h); | 17 | EAPI void ethumb_calculate_aspect_from_ratio(Ethumb *e, float ia, int *w, int *h); |
diff --git a/legacy/ethumb/src/lib/ethumb.c b/legacy/ethumb/src/lib/ethumb.c index ecabe9cc02..c097fbe382 100644 --- a/legacy/ethumb/src/lib/ethumb.c +++ b/legacy/ethumb/src/lib/ethumb.c | |||
@@ -1185,7 +1185,8 @@ _ethumb_plugin_generate(Ethumb *e) | |||
1185 | else | 1185 | else |
1186 | evas_object_hide(e->img); | 1186 | evas_object_hide(e->img); |
1187 | 1187 | ||
1188 | plugin->generate_thumb(e); | 1188 | e->plugin = plugin; |
1189 | e->pdata = plugin->thumb_generate(e); | ||
1189 | 1190 | ||
1190 | return EINA_TRUE; | 1191 | return EINA_TRUE; |
1191 | } | 1192 | } |
@@ -1519,6 +1520,8 @@ ethumb_finished_callback_call(Ethumb *e, int result) | |||
1519 | if (e->finished_idler) | 1520 | if (e->finished_idler) |
1520 | ecore_idler_del(e->finished_idler); | 1521 | ecore_idler_del(e->finished_idler); |
1521 | e->finished_idler = ecore_idler_add(_ethumb_finished_idler_cb, e); | 1522 | e->finished_idler = ecore_idler_add(_ethumb_finished_idler_cb, e); |
1523 | e->plugin = NULL; | ||
1524 | e->pdata = NULL; | ||
1522 | } | 1525 | } |
1523 | 1526 | ||
1524 | EAPI Eina_Bool | 1527 | EAPI Eina_Bool |
@@ -1537,6 +1540,13 @@ ethumb_generate(Ethumb *e, Ethumb_Generate_Cb finished_cb, const void *data, Ein | |||
1537 | ERR("thumbnail generation already in progress."); | 1540 | ERR("thumbnail generation already in progress."); |
1538 | return EINA_FALSE; | 1541 | return EINA_FALSE; |
1539 | } | 1542 | } |
1543 | if (e->pdata) | ||
1544 | { | ||
1545 | e->plugin->thumb_cancel(e, e->pdata); | ||
1546 | e->pdata = NULL; | ||
1547 | e->plugin = NULL; | ||
1548 | } | ||
1549 | |||
1540 | e->finished_cb = finished_cb; | 1550 | e->finished_cb = finished_cb; |
1541 | e->cb_data = (void *)data; | 1551 | e->cb_data = (void *)data; |
1542 | e->cb_data_free = free_data; | 1552 | e->cb_data_free = free_data; |
@@ -1549,9 +1559,9 @@ ethumb_generate(Ethumb *e, Ethumb_Generate_Cb finished_cb, const void *data, Ein | |||
1549 | } | 1559 | } |
1550 | 1560 | ||
1551 | r = _ethumb_plugin_generate(e); | 1561 | r = _ethumb_plugin_generate(e); |
1562 | fprintf(stderr, "ethumb generate: %i: %p\n", r, e->pdata); | ||
1552 | if (r) | 1563 | if (r) |
1553 | { | 1564 | { |
1554 | ethumb_finished_callback_call(e, r); | ||
1555 | return EINA_TRUE; | 1565 | return EINA_TRUE; |
1556 | } | 1566 | } |
1557 | 1567 | ||
@@ -1688,6 +1698,8 @@ ethumb_dup(const Ethumb *e) | |||
1688 | r->cb_data = NULL; | 1698 | r->cb_data = NULL; |
1689 | r->cb_data_free = NULL; | 1699 | r->cb_data_free = NULL; |
1690 | r->cb_result = 0; | 1700 | r->cb_result = 0; |
1701 | r->plugin = NULL; | ||
1702 | r->pdata = NULL; | ||
1691 | 1703 | ||
1692 | return r; | 1704 | return r; |
1693 | } | 1705 | } |
diff --git a/legacy/ethumb/src/lib/ethumb_private.h b/legacy/ethumb/src/lib/ethumb_private.h index 25f2cd354e..49e4de9f67 100644 --- a/legacy/ethumb/src/lib/ethumb_private.h +++ b/legacy/ethumb/src/lib/ethumb_private.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __ETHUMB_PRIVATE_H__ 1 | 2 | #define __ETHUMB_PRIVATE_H__ 1 |
3 | 3 | ||
4 | #include <Ethumb.h> | 4 | #include <Ethumb.h> |
5 | #include <Ethumb_Plugin.h> | ||
5 | 6 | ||
6 | typedef struct _Ethumb_Frame Ethumb_Frame; | 7 | typedef struct _Ethumb_Frame Ethumb_Frame; |
7 | 8 | ||
@@ -48,6 +49,9 @@ struct _Ethumb | |||
48 | void *cb_data; | 49 | void *cb_data; |
49 | Eina_Free_Cb cb_data_free; | 50 | Eina_Free_Cb cb_data_free; |
50 | int cb_result; | 51 | int cb_result; |
52 | |||
53 | void *pdata; | ||
54 | Ethumb_Plugin *plugin; | ||
51 | }; | 55 | }; |
52 | 56 | ||
53 | #endif /* __ETHUMB_PRIVATE_H__ */ | 57 | #endif /* __ETHUMB_PRIVATE_H__ */ |
diff --git a/legacy/ethumb/src/plugins/emotion/emotion.c b/legacy/ethumb/src/plugins/emotion/emotion.c index 71918ccf31..560e661e8e 100644 --- a/legacy/ethumb/src/plugins/emotion/emotion.c +++ b/legacy/ethumb/src/plugins/emotion/emotion.c | |||
@@ -38,6 +38,9 @@ struct _emotion_plugin | |||
38 | int w, h; | 38 | int w, h; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static Eina_Bool _frame_grab(void *data); | ||
42 | static Eina_Bool _frame_grab_single(void *data); | ||
43 | |||
41 | static void | 44 | static void |
42 | _resize_movie(struct _emotion_plugin *_plugin) | 45 | _resize_movie(struct _emotion_plugin *_plugin) |
43 | { | 46 | { |
@@ -62,6 +65,17 @@ _resize_movie(struct _emotion_plugin *_plugin) | |||
62 | } | 65 | } |
63 | 66 | ||
64 | static void | 67 | static void |
68 | _frame_decode_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) | ||
69 | { | ||
70 | struct _emotion_plugin *_plugin = data; | ||
71 | |||
72 | if (_plugin->ef) | ||
73 | _frame_grab(data); | ||
74 | else | ||
75 | _frame_grab_single(data); | ||
76 | } | ||
77 | |||
78 | static void | ||
65 | _frame_resized_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) | 79 | _frame_resized_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) |
66 | { | 80 | { |
67 | _resize_movie(data); | 81 | _resize_movie(data); |
@@ -168,6 +182,8 @@ _finish_thumb_generation(struct _emotion_plugin *_plugin, int success) | |||
168 | int r = 0; | 182 | int r = 0; |
169 | evas_object_smart_callback_del(_plugin->video, "frame_resize", | 183 | evas_object_smart_callback_del(_plugin->video, "frame_resize", |
170 | _frame_resized_cb); | 184 | _frame_resized_cb); |
185 | evas_object_smart_callback_del(_plugin->video, "frame_decode", | ||
186 | _frame_decode_cb); | ||
171 | emotion_object_play_set(_plugin->video, 0); | 187 | emotion_object_play_set(_plugin->video, 0); |
172 | evas_object_del(_plugin->video); | 188 | evas_object_del(_plugin->video); |
173 | if (_plugin->ef) | 189 | if (_plugin->ef) |
@@ -207,7 +223,7 @@ _frame_grab_single(void *data) | |||
207 | emotion_object_play_set(_plugin->video, 0); | 223 | emotion_object_play_set(_plugin->video, 0); |
208 | evas_object_del(_plugin->video); | 224 | evas_object_del(_plugin->video); |
209 | free(_plugin); | 225 | free(_plugin); |
210 | 226 | ||
211 | ethumb_finished_callback_call(e, 1); | 227 | ethumb_finished_callback_call(e, 1); |
212 | 228 | ||
213 | return EINA_FALSE; | 229 | return EINA_FALSE; |
@@ -294,12 +310,10 @@ _generate_animated_thumb(struct _emotion_plugin *_plugin) | |||
294 | fprintf(stderr, "ERROR: could not open '%s'\n", thumb_path); | 310 | fprintf(stderr, "ERROR: could not open '%s'\n", thumb_path); |
295 | _finish_thumb_generation(_plugin, 0); | 311 | _finish_thumb_generation(_plugin, 0); |
296 | } | 312 | } |
297 | |||
298 | ecore_timer_add(1.0 / ethumb_video_fps_get(e), _frame_grab, _plugin); | ||
299 | } | 313 | } |
300 | 314 | ||
301 | static void | 315 | static void * |
302 | _generate_thumb(Ethumb *e) | 316 | _thumb_generate(Ethumb *e) |
303 | { | 317 | { |
304 | Evas_Object *o; | 318 | Evas_Object *o; |
305 | int r; | 319 | int r; |
@@ -308,7 +322,7 @@ _generate_thumb(Ethumb *e) | |||
308 | struct _emotion_plugin *_plugin = calloc(sizeof(struct _emotion_plugin), 1); | 322 | struct _emotion_plugin *_plugin = calloc(sizeof(struct _emotion_plugin), 1); |
309 | 323 | ||
310 | o = emotion_object_add(ethumb_evas_get(e)); | 324 | o = emotion_object_add(ethumb_evas_get(e)); |
311 | r = emotion_object_init(o, "xine"); | 325 | r = emotion_object_init(o, NULL); |
312 | if (!r) | 326 | if (!r) |
313 | { | 327 | { |
314 | fprintf(stderr, "ERROR: could not start emotion using gstreamer" | 328 | fprintf(stderr, "ERROR: could not start emotion using gstreamer" |
@@ -316,7 +330,7 @@ _generate_thumb(Ethumb *e) | |||
316 | evas_object_del(o); | 330 | evas_object_del(o); |
317 | ethumb_finished_callback_call(e, 0); | 331 | ethumb_finished_callback_call(e, 0); |
318 | free(_plugin); | 332 | free(_plugin); |
319 | return; | 333 | return NULL; |
320 | } | 334 | } |
321 | 335 | ||
322 | _plugin->video = o; | 336 | _plugin->video = o; |
@@ -334,6 +348,8 @@ _generate_thumb(Ethumb *e) | |||
334 | _plugin->pcount = 1; | 348 | _plugin->pcount = 1; |
335 | 349 | ||
336 | _resize_movie(_plugin); | 350 | _resize_movie(_plugin); |
351 | evas_object_smart_callback_add(o, "frame_decode", | ||
352 | _frame_decode_cb, _plugin); | ||
337 | evas_object_smart_callback_add(o, "frame_resize", | 353 | evas_object_smart_callback_add(o, "frame_resize", |
338 | _frame_resized_cb, _plugin); | 354 | _frame_resized_cb, _plugin); |
339 | evas_object_smart_callback_add(o, "decode_stop", | 355 | evas_object_smart_callback_add(o, "decode_stop", |
@@ -343,14 +359,22 @@ _generate_thumb(Ethumb *e) | |||
343 | { | 359 | { |
344 | _generate_animated_thumb(_plugin); | 360 | _generate_animated_thumb(_plugin); |
345 | } | 361 | } |
346 | else | ||
347 | { | ||
348 | ecore_timer_add(0.1, _frame_grab_single, _plugin); | ||
349 | } | ||
350 | 362 | ||
351 | _video_pos_set(_plugin); | 363 | _video_pos_set(_plugin); |
352 | emotion_object_play_set(o, 1); | 364 | emotion_object_play_set(o, 1); |
353 | evas_object_show(o); | 365 | evas_object_show(o); |
366 | |||
367 | return _plugin; | ||
368 | } | ||
369 | |||
370 | static void | ||
371 | _thumb_cancel(Ethumb *e __UNUSED__, void *data) | ||
372 | { | ||
373 | struct _emotion_plugin *_plugin = data; | ||
374 | |||
375 | if (_plugin->ef) eet_close(_plugin->ef); | ||
376 | evas_object_del(_plugin->video); | ||
377 | free(_plugin); | ||
354 | } | 378 | } |
355 | 379 | ||
356 | EAPI Ethumb_Plugin * | 380 | EAPI Ethumb_Plugin * |
@@ -361,7 +385,8 @@ ethumb_plugin_get(void) | |||
361 | static Ethumb_Plugin plugin = | 385 | static Ethumb_Plugin plugin = |
362 | { | 386 | { |
363 | extensions, | 387 | extensions, |
364 | _generate_thumb, | 388 | _thumb_generate, |
389 | _thumb_cancel | ||
365 | }; | 390 | }; |
366 | 391 | ||
367 | _log_dom = eina_log_domain_register("ethumb_emotion", EINA_COLOR_GREEN); | 392 | _log_dom = eina_log_domain_register("ethumb_emotion", EINA_COLOR_GREEN); |
diff --git a/legacy/ethumb/src/plugins/epdf/epdf.c b/legacy/ethumb/src/plugins/epdf/epdf.c index 82e3b8cf3b..62234a9b50 100644 --- a/legacy/ethumb/src/plugins/epdf/epdf.c +++ b/legacy/ethumb/src/plugins/epdf/epdf.c | |||
@@ -76,6 +76,7 @@ ethumb_plugin_get(void) | |||
76 | { | 76 | { |
77 | extensions, | 77 | extensions, |
78 | _generate_thumb, | 78 | _generate_thumb, |
79 | NULL /* This plugin is not assynchronous so not possible to cancel it at all */ | ||
79 | }; | 80 | }; |
80 | 81 | ||
81 | return &plugin; | 82 | return &plugin; |