[Mplayer-cvslog] CVS: main/libmpdemux stream.h,1.32,1.33 network.c,1.38,1.39 cache2.c,1.10,1.11 Makefile,1.21,1.22

Alban Bedel CVS albeu at mplayer.dev.hu
Sat Feb 23 22:22:57 CET 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv4053/libmpdemux

Modified Files:
	stream.h network.c cache2.c Makefile 
Log Message:
Make blocking call in libmpdemux interuptable (only with new input,
awnser to quit, pt_next, pt_up_step and alt_src_step)


Index: stream.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- stream.h	6 Feb 2002 20:16:35 -0000	1.32
+++ stream.h	23 Feb 2002 21:22:55 -0000	1.33
@@ -46,12 +46,12 @@
 } stream_t;
 
 #ifdef USE_STREAM_CACHE
-void stream_enable_cache(stream_t *stream,int size,int min,int prefill);
+int stream_enable_cache(stream_t *stream,int size,int min,int prefill);
 #else
 // no cache
 #define cache_stream_fill_buffer(x) stream_fill_buffer(x)
 #define cache_stream_seek_long(x,y) stream_seek_long(x,y)
-#define stream_enable_cache(x,y)
+#define stream_enable_cache(x,y) 1
 #endif
 
 int cache_stream_fill_buffer(stream_t *s);

Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- network.c	23 Feb 2002 07:40:25 -0000	1.38
+++ network.c	23 Feb 2002 21:22:55 -0000	1.39
@@ -19,6 +19,7 @@
 #include "stream.h"
 #include "demuxer.h"
 #include "../cfgparser.h"
+#include "mpdemux.h"
 
 #include "network.h"
 #include "http.h"
@@ -124,7 +125,7 @@
 connect2Server(char *host, int port) {
 	int socket_server_fd;
 	int err, err_len;
-	int ret;
+	int ret,count = 0;
 	fd_set set;
 	struct timeval tv;
 	struct sockaddr_in server_address;
@@ -160,16 +161,24 @@
 			return -1;
 		}
 	}
-	tv.tv_sec = 15;	// 15 seconds timeout on connection
-	tv.tv_usec = 0;	
+	tv.tv_sec = 0;
+	tv.tv_usec = 500000;
 	FD_ZERO( &set );
 	FD_SET( socket_server_fd, &set );
 	// When the connection will be made, we will have a writable fd
-	ret = select(socket_server_fd+1, NULL, &set, NULL, &tv);
-	if( ret<=0 ) {
-		if( ret<0 ) perror("select failed");
-		else printf("Connection timeout\n");
+	while((ret = select(socket_server_fd+1, NULL, &set, NULL, &tv)) == 0) {
+	      if( ret<0 ) perror("select failed");
+	      else if(ret > 0) break;
+	      else if(count > 15 || mpdemux_check_interrupt(500)) {
+		if(count > 15)
+		  printf("Connection timeout\n");
+		else
+		  printf("Connection interuppted by user\n");
 		return -1;
+	      }
+	      count++;
+	      FD_ZERO( &set );
+	      FD_SET( socket_server_fd, &set );
 	}
 
 	// Turn back the socket as blocking

Index: cache2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cache2.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- cache2.c	25 Dec 2001 11:20:58 -0000	1.10
+++ cache2.c	23 Feb 2002 21:22:55 -0000	1.11
@@ -8,7 +8,7 @@
 
 #define READ_USLEEP_TIME 10000
 #define FILL_USLEEP_TIME 50000
-#define PREFILL_USLEEP_TIME 200000
+#define PREFILL_SLEEP_TIME 200
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -196,7 +196,7 @@
   exit(0);
 }
 
-void stream_enable_cache(stream_t *stream,int size,int min,int prefill){
+int stream_enable_cache(stream_t *stream,int size,int min,int prefill){
   int ss=(stream->type==STREAMTYPE_VCD)?VCD_SECTOR_DATA:STREAM_BUFFER_SIZE;
   cache_vars_t* s=cache_init(size,ss);
   stream->cache_data=s;
@@ -213,9 +213,10 @@
 	    s->max_filepos-s->read_filepos
 	);
 	if(s->eof) break; // file is smaller than prefill size
-	usleep(PREFILL_USLEEP_TIME);
+	if(mpdemux_check_interrupt(PREFILL_SLEEP_TIME))
+	  return 0;
     }
-    return; // parent exits
+    return 1; // parent exits
   }
   
 // cache thread mainloop:

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Makefile	20 Feb 2002 16:59:25 -0000	1.21
+++ Makefile	23 Feb 2002 21:22:55 -0000	1.22
@@ -3,7 +3,7 @@
 
 include ../config.mak
 
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c mpdemux.c
 ifeq ($(STREAMING),yes)
 SRCS += asf_streaming.c url.c http.c network.c rtp.c
 endif




More information about the MPlayer-cvslog mailing list