summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <m.blumenkran@samsung.com>2013-06-18 09:28:07 +0100
committerMike Blumenkrantz <m.blumenkran@samsung.com>2013-06-18 09:28:07 +0100
commitf4641152d0b67248c26c492b8a9c36621469eaeb (patch)
treec3a8a620abde0a5030297933c62209d3986c94da /src
parentd3046a0b3ff2d9c9c7af3c0edd4b3a2ea15cbb5c (diff)
add tmpfile caching for teamwork media and delete video objects more reliably using a hack to work around stupid eo deletion bug
Diffstat (limited to 'src')
-rw-r--r--src/modules/teamwork/e_mod_main.h1
-rw-r--r--src/modules/teamwork/e_mod_tw.c97
2 files changed, 83 insertions, 15 deletions
diff --git a/src/modules/teamwork/e_mod_main.h b/src/modules/teamwork/e_mod_main.h
index 5e6faba69..3a70d7b6e 100644
--- a/src/modules/teamwork/e_mod_main.h
+++ b/src/modules/teamwork/e_mod_main.h
@@ -38,6 +38,7 @@ typedef struct Mod
38 E_Popup *pop; 38 E_Popup *pop;
39 Eina_Bool sticky : 1; 39 Eina_Bool sticky : 1;
40 Eina_Bool force : 1; 40 Eina_Bool force : 1;
41 Eina_Bool hidden : 1;
41} Mod; 42} Mod;
42 43
43extern Teamwork_Config *tw_config; 44extern Teamwork_Config *tw_config;
diff --git a/src/modules/teamwork/e_mod_tw.c b/src/modules/teamwork/e_mod_tw.c
index 533bb81b8..3543af4cd 100644
--- a/src/modules/teamwork/e_mod_tw.c
+++ b/src/modules/teamwork/e_mod_tw.c
@@ -27,6 +27,7 @@ typedef struct Media
27 unsigned long long timestamp; 27 unsigned long long timestamp;
28 unsigned int tries; 28 unsigned int tries;
29 Ecore_Thread *video_thread; 29 Ecore_Thread *video_thread;
30 Eina_Stringshare *tmpfile;
30 Eina_Bool video; 31 Eina_Bool video;
31 Eina_Bool dummy : 1; 32 Eina_Bool dummy : 1;
32 Eina_Bool valid : 1; 33 Eina_Bool valid : 1;
@@ -295,6 +296,8 @@ download_media_free(Media *i)
295 tw_mod->media_list = eina_inlist_remove(tw_mod->media_list, EINA_INLIST_GET(i)); 296 tw_mod->media_list = eina_inlist_remove(tw_mod->media_list, EINA_INLIST_GET(i));
296 if (i->client) ecore_con_url_free(i->client); 297 if (i->client) ecore_con_url_free(i->client);
297 if (i->buf) eina_binbuf_free(i->buf); 298 if (i->buf) eina_binbuf_free(i->buf);
299 if (i->tmpfile) ecore_file_unlink(i->tmpfile);
300 eina_stringshare_del(i->tmpfile);
298 eina_stringshare_del(i->addr); 301 eina_stringshare_del(i->addr);
299 free(i); 302 free(i);
300} 303}
@@ -440,7 +443,10 @@ dbus_link_mouse_in_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const E
440 unsigned int t; 443 unsigned int t;
441 444
442 if (eldbus_message_arguments_get(msg, "suii", &uri, &t, &last_coords.x, &last_coords.y)) 445 if (eldbus_message_arguments_get(msg, "suii", &uri, &t, &last_coords.x, &last_coords.y))
443 dbus_link_show_helper(uri, 0); 446 {
447 dbus_link_show_helper(uri, 0);
448 tw_mod->hidden = 0;
449 }
444 return eldbus_message_method_return_new(msg); 450 return eldbus_message_method_return_new(msg);
445} 451}
446 452
@@ -465,6 +471,9 @@ dbus_link_mouse_out_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const
465 tw_hide(NULL); 471 tw_hide(NULL);
466 tw_mod->force = 0; 472 tw_mod->force = 0;
467 } 473 }
474 else if (tw_tmpthread || tw_tmpfile)
475 tw_hide(NULL);
476 tw_mod->hidden = 1;
468 } 477 }
469 return eldbus_message_method_return_new(msg); 478 return eldbus_message_method_return_new(msg);
470} 479}
@@ -818,6 +827,24 @@ tw_show_helper(Evas_Object *o, int w, int h)
818} 827}
819 828
820#ifdef HAVE_EMOTION 829#ifdef HAVE_EMOTION
830
831static Eina_Bool
832stupid_obj_del_workaround_hack(void *data)
833{
834 evas_object_del(data);
835 return EINA_FALSE;
836}
837
838static void
839tw_video_closed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
840{
841 evas_object_hide(obj);
842 evas_object_hide(data);
843 ecore_timer_add(3.0, stupid_obj_del_workaround_hack, data);
844 if (!tw_tmpfile) return;
845 eina_stringshare_replace(&tw_tmpfile, NULL);
846}
847
821static void 848static void
822tw_video_opened_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 849tw_video_opened_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
823{ 850{
@@ -825,6 +852,11 @@ tw_video_opened_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
825 double ratio = tw_config->popup_size / 100.; 852 double ratio = tw_config->popup_size / 100.;
826 E_Zone *zone; 853 E_Zone *zone;
827 854
855 if (tw_mod->hidden && (!tw_mod->sticky) && (!tw_mod->force))
856 {
857 tw_video_closed_cb(data, obj, NULL);
858 return;
859 }
828 emotion_object_size_get(obj, &iw, &ih); 860 emotion_object_size_get(obj, &iw, &ih);
829 861
830 zone = e_zone_current_get(e_util_container_current_get()); 862 zone = e_zone_current_get(e_util_container_current_get());
@@ -847,7 +879,6 @@ tw_video_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, v
847{ 879{
848 if (emotion_object_file_get(obj) != tw_tmpfile) return; 880 if (emotion_object_file_get(obj) != tw_tmpfile) return;
849 if (!tw_tmpfile) return; 881 if (!tw_tmpfile) return;
850 ecore_file_unlink(tw_tmpfile);
851 eina_stringshare_replace(&tw_tmpfile, NULL); 882 eina_stringshare_replace(&tw_tmpfile, NULL);
852} 883}
853 884
@@ -857,6 +888,7 @@ tw_show_video(Evas_Object *prev, const char *uri)
857 Evas_Object *o; 888 Evas_Object *o;
858 889
859 o = emotion_object_add(e_widget_preview_evas_get(prev)); 890 o = emotion_object_add(e_widget_preview_evas_get(prev));
891 e_util_size_debug_set(o, 1);
860#if (EMOTION_VERSION_MAJOR > 1) || (EMOTION_VERSION_MINOR >= 8) 892#if (EMOTION_VERSION_MAJOR > 1) || (EMOTION_VERSION_MINOR >= 8)
861 emotion_object_init(o, "vlc"); 893 emotion_object_init(o, "vlc");
862#else 894#else
@@ -865,6 +897,7 @@ tw_show_video(Evas_Object *prev, const char *uri)
865 emotion_object_file_set(o, uri); 897 emotion_object_file_set(o, uri);
866 emotion_object_play_set(o, EINA_TRUE); 898 emotion_object_play_set(o, EINA_TRUE);
867 evas_object_smart_callback_add(o, "frame_decode", tw_video_opened_cb, prev); 899 evas_object_smart_callback_add(o, "frame_decode", tw_video_opened_cb, prev);
900 evas_object_smart_callback_add(o, "decode_stop", tw_video_closed_cb, prev);
868 evas_object_resize(o, 1, 1); 901 evas_object_resize(o, 1, 1);
869 if (uri == tw_tmpfile) 902 if (uri == tw_tmpfile)
870 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, tw_video_del_cb, NULL); 903 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, tw_video_del_cb, NULL);
@@ -896,6 +929,7 @@ tw_video_thread_done_cb(void *data, Ecore_Thread *eth)
896 tw_tmpthread_media = NULL; 929 tw_tmpthread_media = NULL;
897 close(tw_tmpfd); 930 close(tw_tmpfd);
898 tw_tmpfd = -1; 931 tw_tmpfd = -1;
932 i->tmpfile = eina_stringshare_ref(tw_tmpfile);
899 prev = e_widget_preview_add(e_util_comp_current_get()->evas, 50, 50); 933 prev = e_widget_preview_add(e_util_comp_current_get()->evas, 50, 50);
900 tw_show_video(prev, tw_tmpfile); 934 tw_show_video(prev, tw_tmpfile);
901 download_media_cleanup(); 935 download_media_cleanup();
@@ -916,7 +950,7 @@ tw_video_thread_cb(void *data, Ecore_Thread *eth)
916 if (ftruncate(fd, 0)) 950 if (ftruncate(fd, 0))
917 { 951 {
918 ERR("TRUNCATE FAILED: %s", strerror(errno)); 952 ERR("TRUNCATE FAILED: %s", strerror(errno));
919 ecore_thread_local_data_add(eth, "dead", (void*)1, NULL, 0); 953 ecore_thread_cancel(eth);
920 return; //fail if file can't be zeroed 954 return; //fail if file can't be zeroed
921 } 955 }
922 tot = eina_binbuf_length_get(i->buf); 956 tot = eina_binbuf_length_get(i->buf);
@@ -927,7 +961,12 @@ tw_video_thread_cb(void *data, Ecore_Thread *eth)
927 961
928 if (pos + num >= tot) 962 if (pos + num >= tot)
929 num = tot - pos; 963 num = tot - pos;
930 if (write(fd, buf + pos, num) < 0) break; 964 if (write(fd, buf + pos, num) < 0)
965 {
966 ERR("WRITE FAILED: %s", strerror(errno));
967 ecore_thread_cancel(eth);
968 return;
969 }
931 pos += num; 970 pos += num;
932 if (ecore_thread_local_data_find(eth, "dead")) break; 971 if (ecore_thread_local_data_find(eth, "dead")) break;
933 } 972 }
@@ -955,20 +994,35 @@ tw_show(Media *i)
955 const char *tmp; 994 const char *tmp;
956 995
957 if (tw_config->disable_video) return; 996 if (tw_config->disable_video) return;
997 while (i->tmpfile)
998 {
999 if (!ecore_file_exists(i->tmpfile))
1000 {
1001 eina_stringshare_replace(&i->tmpfile, NULL);
1002 break;
1003 }
1004 if (tw_tmpthread)
1005 {
1006 ecore_thread_local_data_add(tw_tmpthread, "dead", (void*)1, NULL, 0);
1007 E_FREE_FUNC(tw_tmpthread, ecore_thread_cancel);
1008 tw_tmpthread_media->video_thread = NULL;
1009 }
1010 if (tw_tmpfd != -1)
1011 {
1012 close(tw_tmpfd);
1013 tw_tmpfd = -1;
1014 }
1015 eina_stringshare_del(tw_tmpfile);
1016 tw_tmpfile = eina_stringshare_ref(i->tmpfile);
1017 prev = e_widget_preview_add(e_util_comp_current_get()->evas, 50, 50);
1018 tw_show_video(prev, tw_tmpfile);
1019 return;
1020 }
958 tmp = getenv("XDG_RUNTIME_DIR"); 1021 tmp = getenv("XDG_RUNTIME_DIR");
959 if (!tmp) tmp = "/tmp"; 1022 if (!tmp) tmp = "/tmp";
960 snprintf(buf, sizeof(buf), "%s/teamwork-%s-XXXXXX", tmp, ecore_file_file_get(i->addr)); 1023 snprintf(buf, sizeof(buf), "%s/teamwork-%s-XXXXXX", tmp, ecore_file_file_get(i->addr));
961 if (tw_tmpfile) 1024 if (tw_tmpfile)
962 { 1025 {
963 if (tw_tmpthread_media == i)
964 {
965 if (!tw_tmpthread)
966 {
967 prev = e_widget_preview_add(e_util_comp_current_get()->evas, 50, 50);
968 tw_show_video(prev, tw_tmpfile);
969 }
970 return;
971 }
972 if (tw_tmpthread) 1026 if (tw_tmpthread)
973 { 1027 {
974 ecore_thread_local_data_add(tw_tmpthread, "dead", (void*)1, NULL, 0); 1028 ecore_thread_local_data_add(tw_tmpthread, "dead", (void*)1, NULL, 0);
@@ -976,7 +1030,6 @@ tw_show(Media *i)
976 tw_tmpthread_media->video_thread = NULL; 1030 tw_tmpthread_media->video_thread = NULL;
977 } 1031 }
978 close(tw_tmpfd); 1032 close(tw_tmpfd);
979 ecore_file_unlink(tw_tmpfile);
980 } 1033 }
981 tw_tmpfd = mkstemp(buf); 1034 tw_tmpfd = mkstemp(buf);
982 eina_stringshare_replace(&tw_tmpfile, buf); 1035 eina_stringshare_replace(&tw_tmpfile, buf);
@@ -1077,6 +1130,21 @@ focus_out(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Border_Focus_Out
1077EINTERN Eina_Bool 1130EINTERN Eina_Bool
1078tw_hide(void *d EINA_UNUSED) 1131tw_hide(void *d EINA_UNUSED)
1079{ 1132{
1133 if (tw_tmpthread)
1134 {
1135 ecore_thread_local_data_add(tw_tmpthread, "dead", (void*)1, NULL, 0);
1136 E_FREE_FUNC(tw_tmpthread, ecore_thread_cancel);
1137 tw_tmpthread_media->video_thread = NULL;
1138 }
1139 if (tw_tmpfd != -1)
1140 {
1141 close(tw_tmpfd);
1142 tw_tmpfd = -1;
1143 }
1144 if (tw_tmpfile)
1145 {
1146 eina_stringshare_replace(&tw_tmpfile, NULL);
1147 }
1080 E_FREE_FUNC(tw_mod->pop, e_object_del); 1148 E_FREE_FUNC(tw_mod->pop, e_object_del);
1081 last_coords.x = last_coords.y = 0; 1149 last_coords.x = last_coords.y = 0;
1082 E_FREE_FUNC(tw_hide_timer, ecore_timer_del); 1150 E_FREE_FUNC(tw_hide_timer, ecore_timer_del);
@@ -1168,7 +1236,6 @@ e_tw_shutdown(void)
1168 { 1236 {
1169 close(tw_tmpfd); 1237 close(tw_tmpfd);
1170 tw_tmpfd = -1; 1238 tw_tmpfd = -1;
1171 ecore_file_unlink(tw_tmpfile);
1172 } 1239 }
1173 eina_stringshare_replace(&tw_tmpfile, NULL); 1240 eina_stringshare_replace(&tw_tmpfile, NULL);
1174 E_FREE_FUNC(tw_tmpthread, ecore_thread_cancel); 1241 E_FREE_FUNC(tw_tmpthread, ecore_thread_cancel);