1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-11 08:37:59 +00:00

Add a context argument to mp_input_add_event_fd callback

This commit is contained in:
Uoti Urpala 2008-04-04 03:26:33 +03:00
parent 1f086d4376
commit e5e8effca8
4 changed files with 17 additions and 6 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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);