From e5e8effca82c24cdf4e15f91cc6fe29893ac0675 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 4 Apr 2008 03:26:33 +0300 Subject: Add a context argument to mp_input_add_event_fd callback --- input/input.c | 6 ++++-- input/input.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'input') diff --git a/input/input.c b/input/input.c index d2df5195be..a49de3c229 100644 --- a/input/input.c +++ b/input/input.c @@ -507,6 +507,7 @@ typedef struct mp_input_fd { int fd; void* read_func; mp_close_func_t close_func; + void *ctx; unsigned eof : 1; unsigned drop : 1; unsigned dead : 1; @@ -691,7 +692,7 @@ mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t } int -mp_input_add_event_fd(int fd, void (*read_func)(void)) +mp_input_add_event_fd(int fd, void (*read_func)(void *ctx), void *ctx) { if(num_key_fd == MP_MAX_KEY_FD) { mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantRegister2ManyKeyFds,fd); @@ -705,6 +706,7 @@ mp_input_add_event_fd(int fd, void (*read_func)(void)) key_fds[num_key_fd] = (struct mp_input_fd){ .fd = fd, .read_func = read_func, + .ctx = ctx, .no_readfunc_retval = 1, }; num_key_fd++; @@ -1230,7 +1232,7 @@ static mp_cmd_t *read_events(int time, int paused) #endif if (key_fds[i].no_readfunc_retval) { // getch2 handler special-cased for now - ((void (*)(void))key_fds[i].read_func)(); + ((void (*)(void *))key_fds[i].read_func)(key_fds[i].ctx); if (cmd_queue_length) return NULL; code = mplayer_get_key(0); diff --git a/input/input.h b/input/input.h index e6381b3e34..27c1bdb83f 100644 --- a/input/input.h +++ b/input/input.h @@ -240,7 +240,7 @@ mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t void mp_input_rm_key_fd(int fd); -int mp_input_add_event_fd(int fd, void (*read_func)(void)); +int mp_input_add_event_fd(int fd, void (*read_func)(void *ctx), void *ctx); void mp_input_rm_event_fd(int fd); -- cgit v1.2.3