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 +- libvo/vo_xv.c | 6 ++++-- mplayer.c | 9 ++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) 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); diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 511602dfc4..4b66392b19 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -689,7 +689,8 @@ static void uninit(void) #ifdef HAVE_XF86VM vo_vm_close(mDisplay); #endif - mp_input_rm_event_fd(ConnectionNumber(mDisplay)); +// Temporarily disabled until next commit +// mp_input_rm_event_fd(ConnectionNumber(mDisplay)); vo_x11_uninit(); } @@ -811,7 +812,8 @@ static int preinit(const char *arg) fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats); - mp_input_add_event_fd(ConnectionNumber(mDisplay), check_events); +// Temporarily disabled until next commit changes check_events parameters +// mp_input_add_event_fd(ConnectionNumber(mDisplay), check_events); return 0; } diff --git a/mplayer.c b/mplayer.c index 1aeaa06e17..59d274b081 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2534,6 +2534,13 @@ static int seek(MPContext *mpctx, double amount, int style) return 0; } + +static void read_keys(void *ctx) +{ + getch2(); +} + + int main(int argc,char* argv[]){ @@ -2856,7 +2863,7 @@ mp_input_init(use_gui); if(slave_mode) mp_input_add_cmd_fd(0,USE_SELECT,MP_INPUT_SLAVE_CMD_FUNC,NULL); else if(!noconsolecontrols) - mp_input_add_event_fd(0, getch2); + mp_input_add_event_fd(0, read_keys, NULL); // Set the libstream interrupt callback stream_set_interrupt_callback(mp_input_check_interrupt); -- cgit v1.2.3