summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2004-07-18 08:04:41 +0000
committerCarsten Haitzler <raster@rasterman.com>2004-07-18 08:04:41 +0000
commitad7ff874ab8704f24b04148a3bbe65d0fd5ff910 (patch)
treecf4e33fe95652095a07eb945d24eef515221b7bf
parent6b9f49e51f96fcd6d704d4b3fe8b6fa8b57b94bc (diff)
moved dome things off into threads of their own to minimise main ap impact
SVN revision: 10897
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c8
-rw-r--r--legacy/emotion/src/modules/emotion_xine.c163
-rw-r--r--legacy/emotion/src/modules/emotion_xine.h16
3 files changed, 135 insertions, 52 deletions
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index d33da425b8..89ca196fb0 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -163,12 +163,16 @@ emotion_object_file_set(Evas_Object *obj, const char *file)
163 sd->pos = 0; 163 sd->pos = 0;
164 sd->seek_pos = 0; 164 sd->seek_pos = 0;
165 sd->len = 0; 165 sd->len = 0;
166 if (file) 166 if ((file) && (strlen(file) > 0))
167 { 167 {
168 int w, h; 168 int w, h;
169 169
170 sd->file = strdup(file); 170 sd->file = strdup(file);
171 if (sd->video) sd->module->file_close(sd->video); 171 if (sd->video)
172 {
173 sd->module->file_close(sd->video);
174 evas_object_image_size_set(sd->obj, 0, 0);
175 }
172 if (sd->module) _emotion_module_close(sd->module); 176 if (sd->module) _emotion_module_close(sd->module);
173 sd->module = _emotion_module_open("emotion_decoder_xine.so"); 177 sd->module = _emotion_module_open("emotion_decoder_xine.so");
174 if (!sd->module) return; 178 if (!sd->module) return;
diff --git a/legacy/emotion/src/modules/emotion_xine.c b/legacy/emotion/src/modules/emotion_xine.c
index 43c2180077..c5f0758501 100644
--- a/legacy/emotion/src/modules/emotion_xine.c
+++ b/legacy/emotion/src/modules/emotion_xine.c
@@ -2,10 +2,6 @@
2#include "emotion_private.h" 2#include "emotion_private.h"
3#include "emotion_xine.h" 3#include "emotion_xine.h"
4 4
5#include <unistd.h>
6#include <fcntl.h>
7#include <pthread.h>
8
9static int init_count = 0; 5static int init_count = 0;
10static xine_t *decoder = NULL; 6static xine_t *decoder = NULL;
11 7
@@ -56,11 +52,14 @@ static void em_speed_set(void *ef, double speed);
56static double em_speed_get(void *ef); 52static double em_speed_get(void *ef);
57static int em_eject(void *ef); 53static int em_eject(void *ef);
58 54
55
59static void *_em_seek (void *par); 56static void *_em_seek (void *par);
60static int _em_fd_active (void *data, Ecore_Fd_Handler *fdh); 57static int _em_fd_active (void *data, Ecore_Fd_Handler *fdh);
61static void _em_event (void *data, const xine_event_t *event); 58static void _em_event (void *data, const xine_event_t *event);
62static int _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh); 59static int _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh);
63static int _em_timer (void *data); 60static int _em_timer (void *data);
61static void *_em_get_pos_len_th(void *par);
62static void _em_get_pos_len (Emotion_Xine_Video *ev);
64 63
65static int 64static int
66em_init(void) 65em_init(void)
@@ -112,6 +111,15 @@ em_file_open(const char *file, Evas_Object *obj)
112 if (!ev) return NULL; 111 if (!ev) return NULL;
113 ev->obj = obj; 112 ev->obj = obj;
114 113
114 if (1)
115 {
116 xine_cfg_entry_t cf;
117 if (xine_config_lookup_entry(decoder, "input.dvd_use_readahead", &cf))
118 {
119 cf.num_value = 1; // 0 or 1
120 xine_config_update_entry(decoder, &cf);
121 }
122 }
115 /* some notes on parameters we could swizzle for certain inputs */ 123 /* some notes on parameters we could swizzle for certain inputs */
116 if (0) 124 if (0)
117 { 125 {
@@ -134,7 +142,7 @@ em_file_open(const char *file, Evas_Object *obj)
134 } 142 }
135 if (xine_config_lookup_entry(decoder, "input.dvd_use_readahead", &cf)) 143 if (xine_config_lookup_entry(decoder, "input.dvd_use_readahead", &cf))
136 { 144 {
137 cf.num_value = 0; // 0 or 1 145 cf.num_value = 1; // 0 or 1
138 xine_config_update_entry(decoder, &cf); 146 xine_config_update_entry(decoder, &cf);
139 } 147 }
140 // these are used any time in runtime - so changing affects all dvd's 148 // these are used any time in runtime - so changing affects all dvd's
@@ -297,6 +305,23 @@ em_file_open(const char *file, Evas_Object *obj)
297 v = xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_RATIO); 305 v = xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_RATIO);
298 ev->ratio = (double)v / 10000.0; 306 ev->ratio = (double)v / 10000.0;
299 ev->just_loaded = 1; 307 ev->just_loaded = 1;
308
309 {
310 pthread_attr_t thattr;
311
312 pthread_cond_init(&(ev->seek_cond), NULL);
313 pthread_cond_init(&(ev->get_pos_len_cond), NULL);
314 pthread_mutex_init(&(ev->seek_mutex), NULL);
315 pthread_mutex_init(&(ev->get_pos_len_mutex), NULL);
316
317 pthread_attr_init(&thattr);
318 pthread_create(&ev->seek_th, NULL, _em_seek, ev);
319 pthread_attr_destroy(&thattr);
320
321 pthread_attr_init(&thattr);
322 pthread_create(&ev->get_pos_len_th, NULL, _em_get_pos_len_th, ev);
323 pthread_attr_destroy(&thattr);
324 }
300 return ev; 325 return ev;
301} 326}
302 327
@@ -306,16 +331,26 @@ em_file_close(void *ef)
306 Emotion_Xine_Video *ev; 331 Emotion_Xine_Video *ev;
307 332
308 ev = (Emotion_Xine_Video *)ef; 333 ev = (Emotion_Xine_Video *)ef;
334 printf("xn stop\n");
335 xine_stop(ev->stream);
336 ev->delete_me = 1;
337// pthread_mutex_lock(&(ev->seek_mutex));
338 pthread_cond_broadcast(&(ev->seek_cond));
339// pthread_mutex_lock(&(ev->get_pos_len_mutex));
340 pthread_cond_broadcast(&(ev->get_pos_len_cond));
309 while (ev->seek_to); 341 while (ev->seek_to);
342 while (ev->get_poslen);
310 ecore_main_fd_handler_del(ev->fd_handler); 343 ecore_main_fd_handler_del(ev->fd_handler);
311 close(ev->fd_write); 344 close(ev->fd_write);
312 close(ev->fd_read); 345 close(ev->fd_read);
313 ecore_main_fd_handler_del(ev->fd_ev_handler); 346 ecore_main_fd_handler_del(ev->fd_ev_handler);
314 close(ev->fd_ev_write); 347 close(ev->fd_ev_write);
315 close(ev->fd_ev_read); 348 close(ev->fd_ev_read);
316 xine_stop(ev->stream); 349 printf("xn close\n");
317 xine_close(ev->stream); 350 xine_close(ev->stream);
351 printf("xn dispose\n");
318 xine_dispose(ev->stream); 352 xine_dispose(ev->stream);
353 printf("xn dispose evq\n");
319 xine_event_dispose_queue(ev->queue); 354 xine_event_dispose_queue(ev->queue);
320 if (ev->video) xine_close_video_driver(decoder, ev->video); 355 if (ev->video) xine_close_video_driver(decoder, ev->video);
321 if (ev->audio) xine_close_audio_driver(decoder, ev->audio); 356 if (ev->audio) xine_close_audio_driver(decoder, ev->audio);
@@ -401,14 +436,7 @@ em_pos_set(void *ef, double pos)
401 if (ev->seek_to_pos == pos) return; 436 if (ev->seek_to_pos == pos) return;
402 ev->seek_to_pos = pos; 437 ev->seek_to_pos = pos;
403 ev->seek_to++; 438 ev->seek_to++;
404 if (ev->seek_to == 1) 439 pthread_cond_broadcast(&(ev->seek_cond));
405 {
406 pthread_t th;
407 pthread_attr_t thattr;
408
409 if (pthread_create(&th, NULL, _em_seek, ev) != 0)
410 ev->seek_to--;
411 }
412} 440}
413 441
414static double 442static double
@@ -922,21 +950,28 @@ static void *
922_em_seek(void *par) 950_em_seek(void *par)
923{ 951{
924 Emotion_Xine_Video *ev; 952 Emotion_Xine_Video *ev;
925 double ppos = -1.0;
926 953
927 ev = (Emotion_Xine_Video *)par; 954 ev = (Emotion_Xine_Video *)par;
928 while (ev->seek_to > 0) 955 pthread_mutex_lock(&(ev->seek_mutex));
956 for (;;)
929 { 957 {
930 if (ppos != ev->seek_to_pos) 958 double ppos = -1.0;
959
960 pthread_cond_wait(&(ev->seek_cond), &(ev->seek_mutex));
961 while (ev->seek_to > 0)
931 { 962 {
932 ppos = ev->seek_to_pos; 963 if (ppos != ev->seek_to_pos)
933 xine_play(ev->stream, 0, ev->seek_to_pos * 1000); 964 {
965 ppos = ev->seek_to_pos;
966 xine_play(ev->stream, 0, ev->seek_to_pos * 1000);
967 }
968 ev->seek_to = 0;
969 if (ev->delete_me) return NULL;
934 } 970 }
935 ev->seek_to--; 971 if (!ev->play)
936 } 972 xine_set_param(ev->stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE);
937 if (!ev->play) 973 if (ev->delete_me) return NULL;
938 { 974 usleep(1000000 / 10);
939 xine_set_param(ev->stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE);
940 } 975 }
941 return NULL; 976 return NULL;
942} 977}
@@ -948,9 +983,6 @@ _em_fd_active(void *data, Ecore_Fd_Handler *fdh)
948 int fd, len; 983 int fd, len;
949 Emotion_Xine_Video_Frame *fr; 984 Emotion_Xine_Video_Frame *fr;
950 Emotion_Xine_Video *ev; 985 Emotion_Xine_Video *ev;
951 int pos_stream = 0;
952 int pos_time = 0;
953 int length_time = 0;
954 986
955 ev = data; 987 ev = data;
956 fd = ecore_main_fd_handler_fd_get(fdh); 988 fd = ecore_main_fd_handler_fd_get(fdh);
@@ -968,18 +1000,11 @@ _em_fd_active(void *data, Ecore_Fd_Handler *fdh)
968 ev->cur_frame->done_func(ev->cur_frame->done_data); 1000 ev->cur_frame->done_func(ev->cur_frame->done_data);
969 } 1001 }
970 ev->cur_frame = fr; 1002 ev->cur_frame = fr;
971 if (xine_get_pos_length(ev->stream, 1003 _em_get_pos_len(ev);
972 &pos_stream,
973 &pos_time,
974 &length_time))
975 {
976
977 ev->pos = (double)pos_time / 1000.0;
978 ev->len = (double)length_time / 1000.0;
979 }
980 if ((xine_get_stream_info(ev->stream, XINE_STREAM_INFO_HAS_VIDEO)) && 1004 if ((xine_get_stream_info(ev->stream, XINE_STREAM_INFO_HAS_VIDEO)) &&
981 (xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_HANDLED))) 1005 (xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_HANDLED)))
982 { 1006 {
1007
983 if (ev->video_mute) 1008 if (ev->video_mute)
984 { 1009 {
985 if (ev->cur_frame->done_func) 1010 if (ev->cur_frame->done_func)
@@ -1065,6 +1090,13 @@ _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
1065 _emotion_title_set(ev->obj, e->str); 1090 _emotion_title_set(ev->obj, e->str);
1066 } 1091 }
1067 break; 1092 break;
1093 case XINE_EVENT_FRAME_FORMAT_CHANGE:
1094 {
1095 xine_format_change_data_t *e;
1096
1097 e = eev->xine_event;
1098 }
1099 break;
1068 case XINE_EVENT_UI_MESSAGE: 1100 case XINE_EVENT_UI_MESSAGE:
1069 { 1101 {
1070 xine_ui_message_data_t *e; 1102 xine_ui_message_data_t *e;
@@ -1145,20 +1177,9 @@ static int
1145_em_timer(void *data) 1177_em_timer(void *data)
1146{ 1178{
1147 Emotion_Xine_Video *ev; 1179 Emotion_Xine_Video *ev;
1148 int pos_stream = 0;
1149 int pos_time = 0;
1150 int length_time = 0;
1151 1180
1152 ev = data; 1181 ev = data;
1153 if (xine_get_pos_length(ev->stream, 1182 _em_get_pos_len(ev);
1154 &pos_stream,
1155 &pos_time,
1156 &length_time))
1157 {
1158
1159 ev->pos = (double)pos_time / 1000.0;
1160 ev->len = (double)length_time / 1000.0;
1161 }
1162 if ((xine_get_stream_info(ev->stream, XINE_STREAM_INFO_HAS_VIDEO)) && 1183 if ((xine_get_stream_info(ev->stream, XINE_STREAM_INFO_HAS_VIDEO)) &&
1163 (xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_HANDLED))) 1184 (xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_HANDLED)))
1164 _emotion_frame_new(ev->obj); 1185 _emotion_frame_new(ev->obj);
@@ -1166,6 +1187,52 @@ _em_timer(void *data)
1166 return 1; 1187 return 1;
1167} 1188}
1168 1189
1190static void *
1191_em_get_pos_len_th(void *par)
1192{
1193 Emotion_Xine_Video *ev;
1194
1195 ev = (Emotion_Xine_Video *)par;
1196
1197 pthread_mutex_lock(&(ev->get_pos_len_mutex));
1198 for (;;)
1199 {
1200 pthread_cond_wait(&(ev->get_pos_len_cond), &(ev->get_pos_len_mutex));
1201 while (ev->get_poslen > 0)
1202 {
1203 int pos_stream = 0;
1204 int pos_time = 0;
1205 int length_time = 0;
1206
1207 if (xine_get_pos_length(ev->stream,
1208 &pos_stream,
1209 &pos_time,
1210 &length_time))
1211 {
1212
1213 ev->pos = (double)pos_time / 1000.0;
1214 ev->len = (double)length_time / 1000.0;
1215 }
1216 if (ev->delete_me)
1217 {
1218 ev->get_poslen = 0;
1219 return NULL;
1220 }
1221 ev->get_poslen = 0;
1222// printf("get pos %3.3f\n", ev->pos);
1223 usleep(1000000 / 10);
1224 }
1225 }
1226 return NULL;
1227}
1228
1229static void
1230_em_get_pos_len(Emotion_Xine_Video *ev)
1231{
1232 if (ev->get_poslen) return;
1233 ev->get_poslen++;
1234 pthread_cond_broadcast(&(ev->get_pos_len_cond));
1235}
1169 1236
1170 1237
1171 1238
diff --git a/legacy/emotion/src/modules/emotion_xine.h b/legacy/emotion/src/modules/emotion_xine.h
index 53e242ad90..8b9f2a7080 100644
--- a/legacy/emotion/src/modules/emotion_xine.h
+++ b/legacy/emotion/src/modules/emotion_xine.h
@@ -2,6 +2,9 @@
2#define EMOTION_XINE_H 2#define EMOTION_XINE_H
3 3
4#include <xine.h> 4#include <xine.h>
5#include <unistd.h>
6#include <fcntl.h>
7#include <pthread.h>
5 8
6typedef struct _Emotion_Xine_Video Emotion_Xine_Video; 9typedef struct _Emotion_Xine_Video Emotion_Xine_Video;
7typedef struct _Emotion_Xine_Video_Frame Emotion_Xine_Video_Frame; 10typedef struct _Emotion_Xine_Video_Frame Emotion_Xine_Video_Frame;
@@ -21,8 +24,9 @@ struct _Emotion_Xine_Video
21 int w, h; 24 int w, h;
22 Evas_Object *obj; 25 Evas_Object *obj;
23 Emotion_Xine_Video_Frame *cur_frame; 26 Emotion_Xine_Video_Frame *cur_frame;
24 int seek_to; 27 volatile int seek_to;
25 double seek_to_pos; 28 volatile int get_poslen;
29 volatile double seek_to_pos;
26 Ecore_Timer *timer; 30 Ecore_Timer *timer;
27 int fd_read; 31 int fd_read;
28 int fd_write; 32 int fd_write;
@@ -35,6 +39,14 @@ struct _Emotion_Xine_Video
35 unsigned char video_mute : 1; 39 unsigned char video_mute : 1;
36 unsigned char audio_mute : 1; 40 unsigned char audio_mute : 1;
37 unsigned char spu_mute : 1; 41 unsigned char spu_mute : 1;
42 volatile unsigned char delete_me : 1;
43
44 pthread_t seek_th;
45 pthread_t get_pos_len_th;
46 pthread_cond_t seek_cond;
47 pthread_cond_t get_pos_len_cond;
48 pthread_mutex_t seek_mutex;
49 pthread_mutex_t get_pos_len_mutex;
38}; 50};
39 51
40struct _Emotion_Xine_Video_Frame 52struct _Emotion_Xine_Video_Frame