[MPlayer-cvslog] r24152 - in trunk: input/input.c input/input.h mplayer.c

uau subversion at mplayerhq.hu
Sat Aug 25 06:28:15 CEST 2007


Author: uau
Date: Sat Aug 25 06:28:14 2007
New Revision: 24152

Log:
Add separate event input type for terminal+vo

Add an input/input.c fd type whose read function takes no arguments and
returns no value. If such a function reads key or command events it'll
add them to the queues itself. Use this type for terminal input which
was special-cased before. The event function for X11-based VOs will use
the same type later.


Modified:
   trunk/input/input.c
   trunk/input/input.h
   trunk/mplayer.c

Modified: trunk/input/input.c
==============================================================================
--- trunk/input/input.c	(original)
+++ trunk/input/input.c	Sat Aug 25 06:28:14 2007
@@ -500,6 +500,7 @@ typedef struct mp_input_fd {
   int dead : 1;
   int got_cmd : 1;
   int no_select : 1;
+  int no_readfunc_retval : 1;
   // These fields are for the cmd fds.
   char* buffer;
   int pos,size;
@@ -665,6 +666,28 @@ mp_input_add_key_fd(int fd, int select, 
   return 1;
 }
 
+int
+mp_input_add_event_fd(int fd, void (*read_func)(void))
+{
+  if(num_key_fd == MP_MAX_KEY_FD) {
+    mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantRegister2ManyKeyFds,fd);
+    return 0;
+  }
+
+  memset(&key_fds[num_key_fd],0,sizeof(mp_input_fd_t));
+  key_fds[num_key_fd].fd = fd;
+  key_fds[num_key_fd].read_func = read_func;
+  key_fds[num_key_fd].close_func = NULL;
+  key_fds[num_key_fd].no_readfunc_retval = 1;
+  num_key_fd++;
+
+  return 1;
+}
+
+void mp_input_rm_event_fd(int fd)
+{
+    mp_input_rm_key_fd(fd);
+}
 
 
 mp_cmd_t*
@@ -1148,8 +1171,8 @@ static mp_cmd_t *read_events(int time, i
 #endif
 
 	int code;
-	if (key_fds[i].fd == 0) {   // getch2 handler special-cased for now
-	    getch2();
+	if (key_fds[i].no_readfunc_retval) {   // getch2 handler special-cased for now
+	    ((void (*)(void))key_fds[i].read_func)();
 	    code = mplayer_get_key(0);
 	    if (code < 0)
 		code = MP_INPUT_NOTHING;

Modified: trunk/input/input.h
==============================================================================
--- trunk/input/input.h	(original)
+++ trunk/input/input.h	Sat Aug 25 06:28:14 2007
@@ -230,6 +230,10 @@ mp_input_add_key_fd(int fd, int select, 
 void
 mp_input_rm_key_fd(int fd);
 
+int mp_input_add_event_fd(int fd, void (*read_func)(void));
+
+void mp_input_rm_event_fd(int fd);
+
 // This function can be used to put a command in the system again. It's used by libmpdemux
 // when it performs a blocking operation to resend the command it received to the main
 // loop.

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	(original)
+++ trunk/mplayer.c	Sat Aug 25 06:28:14 2007
@@ -2605,7 +2605,7 @@ if(slave_mode)
   mp_input_add_cmd_fd(0,0,mp_input_win32_slave_cmd_func,NULL);
 #endif
 else if(!noconsolecontrols)
-  mp_input_add_key_fd(0,1,NULL,NULL);
+    mp_input_add_event_fd(0, getch2);
 
 inited_flags|=INITED_INPUT;
 current_module = NULL;



More information about the MPlayer-cvslog mailing list