summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2004-06-24 13:59:05 +0000
committerCarsten Haitzler <raster@rasterman.com>2004-06-24 13:59:05 +0000
commitccac8daa1a34e95033845d15dc1576f3637d5d26 (patch)
tree89d623f3f3ad1ee5a134022733a9dc9b5cbec8df /legacy/emotion/src/modules
parent2505c9ec3c6f174d9293181609b1478a6f50ad36 (diff)
remove race conditions! SMELLY! this does mean more fd's though ! :(
SVN revision: 10580
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/modules/emotion_xine.c111
-rw-r--r--legacy/emotion/src/modules/emotion_xine.h6
2 files changed, 60 insertions, 57 deletions
diff --git a/legacy/emotion/src/modules/emotion_xine.c b/legacy/emotion/src/modules/emotion_xine.c
index 814247a10d..43c2180077 100644
--- a/legacy/emotion/src/modules/emotion_xine.c
+++ b/legacy/emotion/src/modules/emotion_xine.c
@@ -7,12 +7,6 @@
7#include <pthread.h> 7#include <pthread.h>
8 8
9static int init_count = 0; 9static int init_count = 0;
10static int fd_read = -1;
11static int fd_write = -1;
12Ecore_Fd_Handler *fd_handler = NULL;
13static int fd_ev_read = -1;
14static int fd_ev_write = -1;
15Ecore_Fd_Handler *fd_ev_handler = NULL;
16static xine_t *decoder = NULL; 10static xine_t *decoder = NULL;
17 11
18static int em_init(void); 12static int em_init(void);
@@ -88,40 +82,6 @@ em_init(void)
88 } 82 }
89 } 83 }
90 xine_init(decoder); 84 xine_init(decoder);
91 {
92 int fds[2];
93
94 if (pipe(fds) == 0)
95 {
96 fd_read = fds[0];
97 fd_write = fds[1];
98 fcntl(fd_read, F_SETFL, O_NONBLOCK);
99 fd_handler = ecore_main_fd_handler_add(fd_read,
100 ECORE_FD_READ,
101 _em_fd_active,
102 decoder,
103 NULL,
104 NULL);
105 ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_READ);
106 }
107 }
108 {
109 int fds[2];
110
111 if (pipe(fds) == 0)
112 {
113 fd_ev_read = fds[0];
114 fd_ev_write = fds[1];
115 fcntl(fd_ev_read, F_SETFL, O_NONBLOCK);
116 fd_ev_handler = ecore_main_fd_handler_add(fd_ev_read,
117 ECORE_FD_READ,
118 _em_fd_ev_active,
119 decoder,
120 NULL,
121 NULL);
122 ecore_main_fd_handler_active_set(fd_ev_handler, ECORE_FD_READ);
123 }
124 }
125 } 85 }
126 return init_count; 86 return init_count;
127} 87}
@@ -134,20 +94,7 @@ em_shutdown(void)
134 if (decoder) 94 if (decoder)
135 { 95 {
136 xine_exit(decoder); 96 xine_exit(decoder);
137 ecore_main_fd_handler_del(fd_handler);
138 close(fd_write);
139 close(fd_read);
140 ecore_main_fd_handler_del(fd_ev_handler);
141 close(fd_ev_write);
142 close(fd_ev_read);
143
144 decoder = NULL; 97 decoder = NULL;
145 fd_handler = NULL;
146 fd_read = -1;
147 fd_write = -1;
148 fd_ev_handler = NULL;
149 fd_ev_read = -1;
150 fd_ev_write = -1;
151 } 98 }
152 return 0; 99 return 0;
153} 100}
@@ -164,7 +111,6 @@ em_file_open(const char *file, Evas_Object *obj)
164 ev = calloc(1, sizeof(Emotion_Xine_Video)); 111 ev = calloc(1, sizeof(Emotion_Xine_Video));
165 if (!ev) return NULL; 112 if (!ev) return NULL;
166 ev->obj = obj; 113 ev->obj = obj;
167 ev->fd = fd_write;
168 114
169 /* some notes on parameters we could swizzle for certain inputs */ 115 /* some notes on parameters we could swizzle for certain inputs */
170 if (0) 116 if (0)
@@ -278,6 +224,42 @@ em_file_open(const char *file, Evas_Object *obj)
278 printf("MRL: %s\n", auto_play_mrls[i]); 224 printf("MRL: %s\n", auto_play_mrls[i]);
279 } 225 }
280 } 226 }
227 {
228 int fds[2];
229
230 if (pipe(fds) == 0)
231 {
232 ev->fd_read = fds[0];
233 ev->fd_write = fds[1];
234 fcntl(ev->fd_read, F_SETFL, O_NONBLOCK);
235 ev->fd_handler = ecore_main_fd_handler_add(ev->fd_read,
236 ECORE_FD_READ,
237 _em_fd_active,
238 ev,
239 NULL,
240 NULL);
241 ecore_main_fd_handler_active_set(ev->fd_handler, ECORE_FD_READ);
242 }
243 }
244 {
245 int fds[2];
246
247 if (pipe(fds) == 0)
248 {
249 ev->fd_ev_read = fds[0];
250 ev->fd_ev_write = fds[1];
251 fcntl(ev->fd_ev_read, F_SETFL, O_NONBLOCK);
252 ev->fd_ev_handler = ecore_main_fd_handler_add(ev->fd_ev_read,
253 ECORE_FD_READ,
254 _em_fd_ev_active,
255 ev,
256 NULL,
257 NULL);
258 ecore_main_fd_handler_active_set(ev->fd_ev_handler, ECORE_FD_READ);
259 }
260 }
261 ev->fd = ev->fd_write;
262
281 ev->video = xine_open_video_driver(decoder, "emotion", XINE_VISUAL_TYPE_NONE, ev); 263 ev->video = xine_open_video_driver(decoder, "emotion", XINE_VISUAL_TYPE_NONE, ev);
282 ev->audio = xine_open_audio_driver(decoder, "oss", ev); 264 ev->audio = xine_open_audio_driver(decoder, "oss", ev);
283// ev->audio = xine_open_audio_driver(decoder, "alsa", ev); 265// ev->audio = xine_open_audio_driver(decoder, "alsa", ev);
@@ -288,6 +270,12 @@ em_file_open(const char *file, Evas_Object *obj)
288 xine_event_create_listener_thread(ev->queue, _em_event, ev); 270 xine_event_create_listener_thread(ev->queue, _em_event, ev);
289 if (!xine_open(ev->stream, file)) 271 if (!xine_open(ev->stream, file))
290 { 272 {
273 ecore_main_fd_handler_del(ev->fd_handler);
274 close(ev->fd_write);
275 close(ev->fd_read);
276 ecore_main_fd_handler_del(ev->fd_ev_handler);
277 close(ev->fd_ev_write);
278 close(ev->fd_ev_read);
291 xine_dispose(ev->stream); 279 xine_dispose(ev->stream);
292 if (ev->video) xine_close_video_driver(decoder, ev->video); 280 if (ev->video) xine_close_video_driver(decoder, ev->video);
293 if (ev->audio) xine_close_audio_driver(decoder, ev->audio); 281 if (ev->audio) xine_close_audio_driver(decoder, ev->audio);
@@ -295,7 +283,6 @@ em_file_open(const char *file, Evas_Object *obj)
295 free(ev); 283 free(ev);
296 return NULL; 284 return NULL;
297 } 285 }
298
299 if (xine_get_pos_length(ev->stream, &pos_stream, &pos_time, &length_time)) 286 if (xine_get_pos_length(ev->stream, &pos_stream, &pos_time, &length_time))
300 { 287 {
301 ev->pos = 0.0; 288 ev->pos = 0.0;
@@ -320,6 +307,12 @@ em_file_close(void *ef)
320 307
321 ev = (Emotion_Xine_Video *)ef; 308 ev = (Emotion_Xine_Video *)ef;
322 while (ev->seek_to); 309 while (ev->seek_to);
310 ecore_main_fd_handler_del(ev->fd_handler);
311 close(ev->fd_write);
312 close(ev->fd_read);
313 ecore_main_fd_handler_del(ev->fd_ev_handler);
314 close(ev->fd_ev_write);
315 close(ev->fd_ev_read);
323 xine_stop(ev->stream); 316 xine_stop(ev->stream);
324 xine_close(ev->stream); 317 xine_close(ev->stream);
325 xine_dispose(ev->stream); 318 xine_dispose(ev->stream);
@@ -959,6 +952,7 @@ _em_fd_active(void *data, Ecore_Fd_Handler *fdh)
959 int pos_time = 0; 952 int pos_time = 0;
960 int length_time = 0; 953 int length_time = 0;
961 954
955 ev = data;
962 fd = ecore_main_fd_handler_fd_get(fdh); 956 fd = ecore_main_fd_handler_fd_get(fdh);
963 while ((len = read(fd, &buf, sizeof(buf))) > 0) 957 while ((len = read(fd, &buf, sizeof(buf))) > 0)
964 { 958 {
@@ -1007,7 +1001,9 @@ _em_event(void *data, const xine_event_t *event)
1007{ 1001{
1008 void *buf[2]; 1002 void *buf[2];
1009 Emotion_Xine_Event *new_ev; 1003 Emotion_Xine_Event *new_ev;
1004 Emotion_Xine_Video *ev;
1010 1005
1006 ev = data;
1011 new_ev = calloc(1, sizeof(Emotion_Xine_Event)); 1007 new_ev = calloc(1, sizeof(Emotion_Xine_Event));
1012 if (!new_ev) return; 1008 if (!new_ev) return;
1013 new_ev->type = event->type; 1009 new_ev->type = event->type;
@@ -1023,21 +1019,22 @@ _em_event(void *data, const xine_event_t *event)
1023 } 1019 }
1024 buf[0] = data; 1020 buf[0] = data;
1025 buf[1] = new_ev; 1021 buf[1] = new_ev;
1026 write(fd_ev_write, buf, sizeof(buf)); 1022 write(ev->fd_ev_write, buf, sizeof(buf));
1027} 1023}
1028 1024
1029static int 1025static int
1030_em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh) 1026_em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
1031{ 1027{
1028 Emotion_Xine_Video *ev;
1032 int fd, len; 1029 int fd, len;
1033 void *buf[2]; 1030 void *buf[2];
1034 1031
1032 ev = data;
1035 fd = ecore_main_fd_handler_fd_get(fdh); 1033 fd = ecore_main_fd_handler_fd_get(fdh);
1036 while ((len = read(fd, buf, sizeof(buf))) > 0) 1034 while ((len = read(fd, buf, sizeof(buf))) > 0)
1037 { 1035 {
1038 if (len == sizeof(buf)) 1036 if (len == sizeof(buf))
1039 { 1037 {
1040 Emotion_Xine_Video *ev;
1041 Emotion_Xine_Event *eev; 1038 Emotion_Xine_Event *eev;
1042 1039
1043 ev = buf[0]; 1040 ev = buf[0];
diff --git a/legacy/emotion/src/modules/emotion_xine.h b/legacy/emotion/src/modules/emotion_xine.h
index e7ff00e89d..53e242ad90 100644
--- a/legacy/emotion/src/modules/emotion_xine.h
+++ b/legacy/emotion/src/modules/emotion_xine.h
@@ -24,6 +24,12 @@ struct _Emotion_Xine_Video
24 int seek_to; 24 int seek_to;
25 double seek_to_pos; 25 double seek_to_pos;
26 Ecore_Timer *timer; 26 Ecore_Timer *timer;
27 int fd_read;
28 int fd_write;
29 Ecore_Fd_Handler *fd_handler;
30 int fd_ev_read;
31 int fd_ev_write;
32 Ecore_Fd_Handler *fd_ev_handler;
27 unsigned char play : 1; 33 unsigned char play : 1;
28 unsigned char just_loaded : 1; 34 unsigned char just_loaded : 1;
29 unsigned char video_mute : 1; 35 unsigned char video_mute : 1;