[Mplayer-cvslog] CVS: main/input input.c,1.53,1.54 input.h,1.21,1.22

Alban Bedel CVS albeu at mplayerhq.hu
Fri Oct 25 18:06:42 CEST 2002


Update of /cvsroot/mplayer/main/input
In directory mail:/var/tmp.root/cvs-serv15410/input

Modified Files:
	input.c input.h 
Log Message:
Reverse Arpi's commit and put the right fix in place.


Index: input.c
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- input.c	25 Oct 2002 14:58:30 -0000	1.53
+++ input.c	25 Oct 2002 16:06:24 -0000	1.54
@@ -343,6 +343,9 @@
 static int
 mp_input_default_key_func(int fd);
 
+static int
+mp_input_default_cmd_func(int fd,char* buf, int l);
+
 static char*
 mp_input_get_key_name(int key);
 
@@ -356,7 +359,7 @@
 
   memset(&cmd_fds[num_cmd_fd],0,sizeof(mp_input_fd_t));
   cmd_fds[num_cmd_fd].fd = fd;
-  cmd_fds[num_cmd_fd].read_func = read_func ? read_func : (mp_cmd_func_t)read;
+  cmd_fds[num_cmd_fd].read_func = read_func ? read_func : mp_input_default_cmd_func;
   cmd_fds[num_cmd_fd].close_func = close_func;
   if(!select)
     cmd_fds[num_cmd_fd].flags = MP_FD_NO_SELECT;
@@ -542,8 +545,6 @@
 mp_input_read_cmd(mp_input_fd_t* mp_fd, char** ret) {
   char* end;
   (*ret) = NULL;
-  
-  if(mp_fd->flags & MP_FD_DEAD) return MP_INPUT_NOTHING;
 
   // Allocate the buffer if it dont exist
   if(!mp_fd->buffer) {
@@ -556,21 +557,19 @@
   while( !(mp_fd->flags & MP_FD_GOT_CMD) && !(mp_fd->flags & MP_FD_EOF) && (mp_fd->size - mp_fd->pos > 1) ) {
     int r = ((mp_cmd_func_t)mp_fd->read_func)(mp_fd->fd,mp_fd->buffer+mp_fd->pos,mp_fd->size - 1 - mp_fd->pos);
     // Error ?
-    if(r == MP_INPUT_NOTHING) break;
     if(r < 0) {
-      if(errno == EINTR)
-	continue;
-      else if(errno == EAGAIN)
-	break;
-      mp_msg(MSGT_INPUT,MSGL_WARN,"Error while reading cmd fd %d : %s\n",mp_fd->fd,strerror(errno));
-      return r; // MP_INPUT_ERROR or MP_INPUT_DEAD
+      switch(r) {
+      case MP_INPUT_ERROR:
+      case MP_INPUT_DEAD:
+	mp_msg(MSGT_INPUT,MSGL_ERR,"Error while reading cmd fd %d : %s\n",mp_fd->fd,strerror(errno));
+      case MP_INPUT_NOTHING:
+	return r;
+      }
       // EOF ?
-    }
-    if(r == 0) {
+    } else if(r == 0) {
       mp_fd->flags |= MP_FD_EOF;
       break;
     }
-    // r > 0
     mp_fd->pos += r;
     break;
   }
@@ -618,6 +617,25 @@
     return 1;
   else
     return MP_INPUT_NOTHING;
+}
+
+static int
+mp_input_default_cmd_func(int fd,char* buf, int l) {
+
+  while(1) {
+    int r = read(fd,buf,l);
+    // Error ?
+    if(r < 0) {
+      if(errno == EINTR)
+	continue;
+      else if(errno == EAGAIN)
+	return MP_INPUT_NOTHING;
+      return MP_INPUT_ERROR;
+      // EOF ?
+    }
+    return r;
+  }
+
 }
 
 static char*

Index: input.h
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- input.h	23 Oct 2002 14:46:19 -0000	1.21
+++ input.h	25 Oct 2002 16:06:25 -0000	1.22
@@ -117,7 +117,7 @@
 
 // These functions should return the key code or one of the error code
 typedef int (*mp_key_func_t)(int fd);
-// These functions should act like read
+// These functions should act like read but they must use our error code (if needed ;-)
 typedef int (*mp_cmd_func_t)(int fd,char* dest,int size);
 // These are used to close the driver
 typedef void (*mp_close_func_t)(int fd);




More information about the MPlayer-cvslog mailing list