[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[315] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-10 10:58:35
|
Revision: 315 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=315&view=rev Author: nickols_k Date: 2012-11-10 10:58:25 +0000 (Sat, 10 Nov 2012) Log Message: ----------- new version of input: input2 Modified Paths: -------------- mplayerxp/dump.c mplayerxp/dump.h mplayerxp/input/input.c mplayerxp/input/input.h mplayerxp/libmpcodecs/dec_video.c mplayerxp/libmpcodecs/dec_video.h mplayerxp/libmpcodecs/vd.c mplayerxp/libmpcodecs/vd.h mplayerxp/libmpcodecs/vd_divx4.c mplayerxp/libmpcodecs/vd_dmo.c mplayerxp/libmpcodecs/vd_dshow.c mplayerxp/libmpcodecs/vd_ffmpeg.c mplayerxp/libmpcodecs/vd_huffyuv.c mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpcodecs/vd_libdv.c mplayerxp/libmpcodecs/vd_libmpeg2.c mplayerxp/libmpcodecs/vd_mpegpes.c mplayerxp/libmpcodecs/vd_null.c mplayerxp/libmpcodecs/vd_nuv.c mplayerxp/libmpcodecs/vd_qtvideo.c mplayerxp/libmpcodecs/vd_raw.c mplayerxp/libmpcodecs/vd_real.c mplayerxp/libmpcodecs/vd_theora.c mplayerxp/libmpcodecs/vd_vfw.c mplayerxp/libmpcodecs/vd_xanim.c mplayerxp/libmpcodecs/vd_xvid.c mplayerxp/libmpconf/cfgparser.c mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpdemux/asf_mmst_streaming.c mplayerxp/libmpdemux/asf_streaming.c mplayerxp/libmpdemux/cache2.c mplayerxp/libmpdemux/cdd.h mplayerxp/libmpdemux/cddb.c mplayerxp/libmpdemux/demuxer.c mplayerxp/libmpdemux/mpdemux.c mplayerxp/libmpdemux/mpdemux.h mplayerxp/libmpdemux/network.c mplayerxp/libmpdemux/network.h mplayerxp/libmpdemux/s_cdd.c mplayerxp/libmpdemux/s_dvdnav.c mplayerxp/libmpdemux/s_dvdread.c mplayerxp/libmpdemux/s_ffmpeg.c mplayerxp/libmpdemux/s_file.c mplayerxp/libmpdemux/s_ftp.c mplayerxp/libmpdemux/s_network.c mplayerxp/libmpdemux/s_oss.c mplayerxp/libmpdemux/s_rtsp.c mplayerxp/libmpdemux/s_tv.c mplayerxp/libmpdemux/s_udp.c mplayerxp/libmpdemux/s_vcdnav.c mplayerxp/libmpdemux/stream.c mplayerxp/libmpdemux/stream.h mplayerxp/libmpdemux/tcp.c mplayerxp/libmpdemux/tcp.h mplayerxp/libmpdemux/test.c mplayerxp/libplaytree/asxparser.c mplayerxp/libplaytree/asxparser.h mplayerxp/libplaytree/playtree.h mplayerxp/libplaytree/playtreeparser.c mplayerxp/libplaytree/playtreeparser.h mplayerxp/mplayerxp.c mplayerxp/mplayerxp.h mplayerxp/postproc/libmenu/menu.c mplayerxp/postproc/libmenu/menu.h mplayerxp/postproc/libmenu/menu_cmdlist.c mplayerxp/postproc/libmenu/menu_console.c mplayerxp/postproc/libmenu/menu_filesel.c mplayerxp/postproc/libmenu/menu_param.c mplayerxp/postproc/libmenu/menu_pt.c mplayerxp/postproc/vf.c mplayerxp/postproc/vf.h mplayerxp/postproc/vf_menu.c Added Paths: ----------- mplayerxp/libmpdemux/asf_streaming.h Modified: mplayerxp/dump.c =================================================================== --- mplayerxp/dump.c 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/dump.c 2012-11-10 10:58:25 UTC (rev 315) @@ -73,16 +73,17 @@ #define MUX_HAVE_VIDEO 0x02 #define MUX_HAVE_SUBS 0x04 typedef struct priv_s { - int my_use_pts; - FILE *mux_file; - muxer_t *muxer; + int my_use_pts; + FILE* mux_file; + muxer_t* muxer; muxer_stream_t *m_audio,*m_video,*m_subs; - unsigned decoded_frameno; - unsigned a_frameno; - int mux_type; - uint64_t vsize,asize,ssize; - float timer_corr; /* use common time-base */ - float vtimer; + unsigned decoded_frameno; + unsigned a_frameno; + int mux_type; + uint64_t vsize,asize,ssize; + float timer_corr; /* use common time-base */ + float vtimer; + any_t* libinput; }priv_t; void __FASTCALL__ dump_stream_event_handler(struct stream_s *s,const stream_packet_t*sp) @@ -93,12 +94,12 @@ returns: 0 - nothing interested -1 - quit */ -static int check_cmd(void) +static int check_cmd(priv_t* priv) { mp_cmd_t* cmd; int retval; retval = 0; - while((cmd = mp_input_get_cmd(0,0,0)) != NULL) + while((cmd = mp_input_get_cmd(priv->libinput,0,0,0)) != NULL) { switch(cmd->id) { @@ -112,124 +113,108 @@ return retval; } -void dump_mux_init(demuxer_t *demuxer) +void dump_mux_init(demuxer_t *demuxer,any_t* libinput) { sh_audio_t* sha=demuxer->audio->sh; sh_video_t* shv=demuxer->video->sh; - char stream_dump_name[1024]; - /* TODO copy it from demuxer */ - if(demuxer->priv) return; - demuxer->priv=mp_mallocz(sizeof(priv_t)); - priv_t*priv=demuxer->priv; - /* describe other useless dumps */ - priv->mux_type=MUX_HAVE_AUDIO|MUX_HAVE_VIDEO|MUX_HAVE_SUBS; - if(port) - { - if(strcmp(port,"audio") ==0 ) { strcpy(stream_dump_name,"a_"); priv->mux_type&=~(MUX_HAVE_VIDEO|MUX_HAVE_SUBS); } - else - if(strcmp(port,"video") ==0 ) { strcpy(stream_dump_name,"v_"); priv->mux_type&=~(MUX_HAVE_AUDIO|MUX_HAVE_SUBS); } - else - if(strcmp(port,"sub") ==0 ) { strcpy(stream_dump_name,"s_"); priv->mux_type&=~(MUX_HAVE_AUDIO|MUX_HAVE_VIDEO); } - else strcpy(stream_dump_name,port); - } - else strcpy(stream_dump_name,"avs_"); - if(strcmp(media,"lavf") == 0) { strcpy(stream_dump_name,"avs_dump."); strcat(stream_dump_name,port); } - else - if(strcmp(media,"mpxp") == 0) strcat(stream_dump_name,"dump.mpxp"); - else - if(strcmp(media,"raw") == 0) strcat(stream_dump_name,"dump.raw"); - else - { - MSG_FATAL("Unsupported muxer format %s found\n",media); - exit_player(MSGTR_Exit_error); - } - priv->mux_file=fopen(stream_dump_name,"wb"); - MSG_DBG2("Preparing stream dumping: %s\n",stream_dump_name); - if(!priv->mux_file){ - MSG_FATAL(MSGTR_CantOpenDumpfile); - exit_player(MSGTR_Exit_error); - } - if(!(priv->muxer=muxer_new_muxer(media,port,priv->mux_file))) - { - MSG_FATAL("Can't initialize muxer\n"); - exit_player(MSGTR_Exit_error); - } - if(sha && (priv->mux_type&MUX_HAVE_AUDIO)) - { - priv->m_audio=muxer_new_stream(priv->muxer,MUXER_TYPE_AUDIO); - priv->m_audio->buffer_size=0x100000; //16384; - priv->m_audio->source=sha; - priv->m_audio->codec=0; - if(!sha->wf) - { - sha->wf=mp_malloc(sizeof(WAVEFORMATEX)); - sha->wf->nBlockAlign = 1; //mux_a->h.dwSampleSize; - sha->wf->wFormatTag = sha->wtag; - sha->wf->nChannels = sha->nch; - sha->wf->nSamplesPerSec = sha->rate; - sha->wf->nAvgBytesPerSec=sha->i_bps; //mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec; - sha->wf->wBitsPerSample = 16; // FIXME - sha->wf->cbSize=0; // FIXME for l3codeca.acm + char stream_dump_name[1024]; + /* TODO copy it from demuxer */ + if(demuxer->priv) return; + demuxer->priv=mp_mallocz(sizeof(priv_t)); + priv_t*priv=demuxer->priv; + priv->libinput=libinput; + /* describe other useless dumps */ + priv->mux_type=MUX_HAVE_AUDIO|MUX_HAVE_VIDEO|MUX_HAVE_SUBS; + if(port) { + if(strcmp(port,"audio") ==0 ) { strcpy(stream_dump_name,"a_"); priv->mux_type&=~(MUX_HAVE_VIDEO|MUX_HAVE_SUBS); } + else if(strcmp(port,"video") ==0 ) { strcpy(stream_dump_name,"v_"); priv->mux_type&=~(MUX_HAVE_AUDIO|MUX_HAVE_SUBS); } + else if(strcmp(port,"sub") ==0 ) { strcpy(stream_dump_name,"s_"); priv->mux_type&=~(MUX_HAVE_AUDIO|MUX_HAVE_VIDEO); } + else strcpy(stream_dump_name,port); + } else strcpy(stream_dump_name,"avs_"); + if(strcmp(media,"lavf") == 0) { strcpy(stream_dump_name,"avs_dump."); strcat(stream_dump_name,port); } + else if(strcmp(media,"mpxp") == 0) strcat(stream_dump_name,"dump.mpxp"); + else if(strcmp(media,"raw") == 0) strcat(stream_dump_name,"dump.raw"); + else { + MSG_FATAL("Unsupported muxer format %s found\n",media); + exit_player(MSGTR_Exit_error); } - priv->m_audio->wf=mp_malloc(sha->wf->cbSize+sizeof(WAVEFORMATEX)); - memcpy(priv->m_audio->wf,sha->wf,sha->wf->cbSize+sizeof(WAVEFORMATEX)); - if(!sha->wf->cbSize && sha->codecdata_len) - { - priv->m_audio->wf->cbSize=sha->wf->cbSize=sha->codecdata_len; - priv->m_audio->wf=mp_realloc(priv->m_audio->wf,sha->wf->cbSize+sizeof(WAVEFORMATEX)); - memcpy((char *)(priv->m_audio->wf+1),sha->codecdata,sha->codecdata_len); + priv->mux_file=fopen(stream_dump_name,"wb"); + MSG_DBG2("Preparing stream dumping: %s\n",stream_dump_name); + if(!priv->mux_file){ + MSG_FATAL(MSGTR_CantOpenDumpfile); + exit_player(MSGTR_Exit_error); } - if(!sha->i_bps) sha->i_bps=priv->m_audio->wf->nAvgBytesPerSec; - if(sha->audio.dwScale){ - priv->m_audio->h.dwSampleSize=sha->audio.dwSampleSize; - priv->m_audio->h.dwScale=sha->audio.dwScale; - priv->m_audio->h.dwRate=sha->audio.dwRate; - } else { - priv->m_audio->h.dwSampleSize=priv->m_audio->wf->nBlockAlign; - priv->m_audio->h.dwScale=priv->m_audio->h.dwSampleSize; - priv->m_audio->h.dwRate=priv->m_audio->wf->nAvgBytesPerSec; + if(!(priv->muxer=muxer_new_muxer(media,port,priv->mux_file))) { + MSG_FATAL("Can't initialize muxer\n"); + exit_player(MSGTR_Exit_error); } - } - else priv->m_audio=NULL; - if(shv && (priv->mux_type&MUX_HAVE_VIDEO)) - { - priv->m_video=muxer_new_stream(priv->muxer,MUXER_TYPE_VIDEO); - priv->m_video->buffer_size=0x200000; // 2MB - priv->m_video->source=shv; - priv->m_video->h.dwSampleSize=0; // VBR - priv->m_video->h.dwScale=10000; - priv->m_video->h.dwRate=priv->m_video->h.dwScale*shv->fps; - priv->m_video->h.dwSuggestedBufferSize=shv->video.dwSuggestedBufferSize; - if(!shv->bih) - { - shv->bih=mp_malloc(sizeof(BITMAPINFOHEADER)); - shv->bih->biSize=sizeof(BITMAPINFOHEADER); - shv->bih->biWidth=shv->src_w; - shv->bih->biHeight=shv->src_h; - shv->bih->biCompression=shv->fourcc; - shv->bih->biPlanes=1; - shv->bih->biBitCount=24; // FIXME!!! - shv->bih->biSizeImage=shv->bih->biWidth*shv->bih->biHeight*(shv->bih->biBitCount/8); - } - priv->m_video->bih=mp_malloc(shv->bih->biSize); - memcpy(priv->m_video->bih,shv->bih,shv->bih->biSize); - priv->m_video->ImageDesc=shv->ImageDesc; - priv->m_video->aspect=shv->aspect; - priv->m_video->codec=0; - } - else priv->m_video=NULL; - if(demuxer->sub->sh && (priv->mux_type&MUX_HAVE_SUBS)) - { - priv->m_subs=muxer_new_stream(priv->muxer,MUXER_TYPE_SUBS); - priv->m_subs->buffer_size=0x100000; //16384; - priv->m_subs->source=NULL; - priv->m_subs->codec=0; - } - else priv->m_subs=NULL; - MSG_DBG2("Opening dump: %X\n",demuxer); - MSG_INFO("Dumping stream to %s\n",stream_dump_name); - muxer_fix_parameters(priv->muxer); - muxer_write_header(priv->muxer,demuxer); + if(sha && (priv->mux_type&MUX_HAVE_AUDIO)) { + priv->m_audio=muxer_new_stream(priv->muxer,MUXER_TYPE_AUDIO); + priv->m_audio->buffer_size=0x100000; //16384; + priv->m_audio->source=sha; + priv->m_audio->codec=0; + if(!sha->wf) { + sha->wf=mp_malloc(sizeof(WAVEFORMATEX)); + sha->wf->nBlockAlign = 1; //mux_a->h.dwSampleSize; + sha->wf->wFormatTag = sha->wtag; + sha->wf->nChannels = sha->nch; + sha->wf->nSamplesPerSec = sha->rate; + sha->wf->nAvgBytesPerSec=sha->i_bps; //mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec; + sha->wf->wBitsPerSample = 16; // FIXME + sha->wf->cbSize=0; // FIXME for l3codeca.acm + } + priv->m_audio->wf=mp_malloc(sha->wf->cbSize+sizeof(WAVEFORMATEX)); + memcpy(priv->m_audio->wf,sha->wf,sha->wf->cbSize+sizeof(WAVEFORMATEX)); + if(!sha->wf->cbSize && sha->codecdata_len) { + priv->m_audio->wf->cbSize=sha->wf->cbSize=sha->codecdata_len; + priv->m_audio->wf=mp_realloc(priv->m_audio->wf,sha->wf->cbSize+sizeof(WAVEFORMATEX)); + memcpy((char *)(priv->m_audio->wf+1),sha->codecdata,sha->codecdata_len); + } + if(!sha->i_bps) sha->i_bps=priv->m_audio->wf->nAvgBytesPerSec; + if(sha->audio.dwScale){ + priv->m_audio->h.dwSampleSize=sha->audio.dwSampleSize; + priv->m_audio->h.dwScale=sha->audio.dwScale; + priv->m_audio->h.dwRate=sha->audio.dwRate; + } else { + priv->m_audio->h.dwSampleSize=priv->m_audio->wf->nBlockAlign; + priv->m_audio->h.dwScale=priv->m_audio->h.dwSampleSize; + priv->m_audio->h.dwRate=priv->m_audio->wf->nAvgBytesPerSec; + } + } else priv->m_audio=NULL; + if(shv && (priv->mux_type&MUX_HAVE_VIDEO)) { + priv->m_video=muxer_new_stream(priv->muxer,MUXER_TYPE_VIDEO); + priv->m_video->buffer_size=0x200000; // 2MB + priv->m_video->source=shv; + priv->m_video->h.dwSampleSize=0; // VBR + priv->m_video->h.dwScale=10000; + priv->m_video->h.dwRate=priv->m_video->h.dwScale*shv->fps; + priv->m_video->h.dwSuggestedBufferSize=shv->video.dwSuggestedBufferSize; + if(!shv->bih) { + shv->bih=mp_malloc(sizeof(BITMAPINFOHEADER)); + shv->bih->biSize=sizeof(BITMAPINFOHEADER); + shv->bih->biWidth=shv->src_w; + shv->bih->biHeight=shv->src_h; + shv->bih->biCompression=shv->fourcc; + shv->bih->biPlanes=1; + shv->bih->biBitCount=24; // FIXME!!! + shv->bih->biSizeImage=shv->bih->biWidth*shv->bih->biHeight*(shv->bih->biBitCount/8); + } + priv->m_video->bih=mp_malloc(shv->bih->biSize); + memcpy(priv->m_video->bih,shv->bih,shv->bih->biSize); + priv->m_video->ImageDesc=shv->ImageDesc; + priv->m_video->aspect=shv->aspect; + priv->m_video->codec=0; + } else priv->m_video=NULL; + if(demuxer->sub->sh && (priv->mux_type&MUX_HAVE_SUBS)) { + priv->m_subs=muxer_new_stream(priv->muxer,MUXER_TYPE_SUBS); + priv->m_subs->buffer_size=0x100000; //16384; + priv->m_subs->source=NULL; + priv->m_subs->codec=0; + } else priv->m_subs=NULL; + MSG_DBG2("Opening dump: %X\n",demuxer); + MSG_INFO("Dumping stream to %s\n",stream_dump_name); + muxer_fix_parameters(priv->muxer); + muxer_write_header(priv->muxer,demuxer); } void dump_mux_close(demuxer_t *demuxer) @@ -371,7 +356,7 @@ The ideal case is: type=read_packet(ANY_TYPE); put_packet(type); */ in_size=ds_get_packet_r(sha->ds,&start,&a_pts); - cmd = check_cmd(); + cmd = check_cmd(priv); if(cmd == -1) goto done; else a_duration=(float)in_size/(float)(sha->i_bps); @@ -406,7 +391,7 @@ { float v_pts; in_size=video_read_frame(shv,&frame_time,&v_pts,&start,0); - cmd = check_cmd(); + cmd = check_cmd(priv); if(cmd == -1) goto done; else if(mpeg_vtimer==HUGE) mpeg_vtimer=v_pts; @@ -438,7 +423,7 @@ in_size=ds_get_packet_r(demuxer->sub,&start,&s_pts); seof=demuxer->sub->eof; if(seof) break; - cmd = check_cmd(); + cmd = check_cmd(priv); if(cmd == -1) goto done; else MSG_V("Got sub frame: %f\n",s_pts); Modified: mplayerxp/dump.h =================================================================== --- mplayerxp/dump.h 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/dump.h 2012-11-10 10:58:25 UTC (rev 315) @@ -8,7 +8,7 @@ extern int dump_parse(const char *param); extern void dump_stream(stream_t *stream); -extern void dump_mux_init(demuxer_t *demuxer); +extern void dump_mux_init(demuxer_t *demuxer,any_t*libinput); extern void dump_mux(demuxer_t *demuxer,int use_pts,const char *seek_to_sec,unsigned play_n_frames); extern void dump_mux_close(demuxer_t *demuxer); extern void __FASTCALL__ dump_stream_event_handler(struct stream_s *s,const stream_packet_t*sp); Modified: mplayerxp/input/input.c =================================================================== --- mplayerxp/input/input.c 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/input/input.c 2012-11-10 10:58:25 UTC (rev 315) @@ -37,6 +37,72 @@ #include "in_msg.h" +#ifndef MP_MAX_KEY_FD +#define MP_MAX_KEY_FD 10 +#endif + +#ifndef MP_MAX_CMD_FD +#define MP_MAX_CMD_FD 10 +#endif + +#define MP_FD_EOF (1<<0) +#define MP_FD_DROP (1<<1) +#define MP_FD_DEAD (1<<2) +#define MP_FD_GOT_CMD (1<<3) +#define MP_FD_NO_SELECT (1<<4) + +#define CMD_QUEUE_SIZE 100 + +typedef struct mp_input_fd { + int fd; + any_t* read_func; + mp_close_func_t close_func; + int flags; + // This fields are for the cmd fds + char* buffer; + int pos,size; +} mp_input_fd_t; + +typedef struct mp_cmd_filter_st mp_cmd_filter_t; + +struct mp_cmd_filter_st { + mp_input_cmd_filter filter; + any_t* ctx; + mp_cmd_filter_t* next; +}; + +typedef struct priv_s { + // These are the user defined binds + mp_cmd_bind_t* cmd_binds; + mp_cmd_filter_t* cmd_filters; + + mp_input_fd_t key_fds[MP_MAX_KEY_FD]; + unsigned int num_key_fd; + mp_input_fd_t cmd_fds[MP_MAX_CMD_FD]; + unsigned int num_cmd_fd; + mp_cmd_t* cmd_queue[CMD_QUEUE_SIZE]; + unsigned int cmd_queue_length,cmd_queue_start,cmd_queue_end; + // this is the key currently down + int key_down[MP_MAX_KEY_DOWN]; + unsigned int num_key_down,last_key_down; + // Autorepeat stuff + short ar_state; + mp_cmd_t* ar_cmd; + unsigned int last_ar; + + int in_file_fd; + char key_str[12]; + int joystick_fd; +}priv_t; + +typedef struct input_conf_s { + int use_joystick,use_lirc,use_lircc; + unsigned ar_delay,ar_rate; + const char* js_dev; + const char* in_file; +}input_conf_t; +static input_conf_t libinput_conf = { 1, 1, 1, 100, 8, "/dev/input/js0", NULL }; + /// This array defines all know commands. /// The first field is an id used to recognize the command without too many strcmp /// The second is abviously the command name @@ -332,79 +398,18 @@ { { 0 }, NULL } }; +static char* config_file = "input.conf"; -#ifndef MP_MAX_KEY_FD -#define MP_MAX_KEY_FD 10 -#endif - -#ifndef MP_MAX_CMD_FD -#define MP_MAX_CMD_FD 10 -#endif - -#define MP_FD_EOF (1<<0) -#define MP_FD_DROP (1<<1) -#define MP_FD_DEAD (1<<2) -#define MP_FD_GOT_CMD (1<<3) -#define MP_FD_NO_SELECT (1<<4) - -#define CMD_QUEUE_SIZE 100 - -typedef struct mp_input_fd { - int fd; - any_t* read_func; - mp_close_func_t close_func; - int flags; - // This fields are for the cmd fds - char* buffer; - int pos,size; -} mp_input_fd_t; - -typedef struct mp_cmd_filter_st mp_cmd_filter_t; - -struct mp_cmd_filter_st { - mp_input_cmd_filter filter; - any_t* ctx; - mp_cmd_filter_t* next; -}; - -// These are the user defined binds -static mp_cmd_bind_t* cmd_binds = NULL; -static mp_cmd_filter_t* cmd_filters = NULL; - // Callback to allow the menu filter to grab the incoming keys void (*mp_input_key_cb)(int code) = NULL; -static mp_input_fd_t key_fds[MP_MAX_KEY_FD]; -static unsigned int num_key_fd = 0; -static mp_input_fd_t cmd_fds[MP_MAX_CMD_FD]; -static unsigned int num_cmd_fd = 0; -static mp_cmd_t* cmd_queue[CMD_QUEUE_SIZE]; -static unsigned int cmd_queue_length = 0,cmd_queue_start = 0, cmd_queue_end = 0; +static int mp_input_print_key_list(any_t*,const config_t* cfg); +static int mp_input_print_cmd_list(any_t*,const config_t* cfg); -// this is the key currently down -static int key_down[MP_MAX_KEY_DOWN]; -static unsigned int num_key_down = 0, last_key_down = 0; - -// Autorepeat stuff -static short ar_state = -1; -static mp_cmd_t* ar_cmd = NULL; -static unsigned int ar_delay = 100, ar_rate = 8, last_ar = 0; - -static int use_joystick = 1, use_lirc = 1, use_lircc = 1; -static char* config_file = "input.conf"; - -static const char* js_dev = "/dev/input/js0"; - -static const char* in_file = NULL; -static int in_file_fd = -1; - -static int mp_input_print_key_list(const config_t* cfg); -static int mp_input_print_cmd_list(const config_t* cfg); - static const config_t joystick_conf[] = { - { "on", &use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of joystick" }, - { "off", &use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, "disables using of joystick" }, - { "dev", &js_dev, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies the joystick device" }, + { "on", &libinput_conf.use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of joystick" }, + { "off", &libinput_conf.use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, "disables using of joystick" }, + { "dev", &libinput_conf.js_dev, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies the joystick device" }, { NULL, NULL, 0, 0, 0, 0, NULL} }; @@ -412,18 +417,18 @@ // Our command line options static const config_t input_conf[] = { { "conf", &config_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies alternative input.conf" }, - { "ar-delay", &ar_delay, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "autorepeate a key delay in milliseconds (0 to disable)" }, - { "ar-rate", &ar_rate, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "number of key-presses per second generating on autorepeat" }, + { "ar-delay", &libinput_conf.ar_delay, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "autorepeate a key delay in milliseconds (0 to disable)" }, + { "ar-rate", &libinput_conf.ar_rate, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "number of key-presses per second generating on autorepeat" }, { "keylist", mp_input_print_key_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, "prints all keys that can be bound to commands" }, { "cmdlist", mp_input_print_cmd_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, "prints all commands that can be bound to keys" }, - { "file", &in_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifes file with commands (useful for FIFO)" }, + { "file", &libinput_conf.in_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifes file with commands (useful for FIFO)" }, #ifdef HAVE_LIRC { "lircconf", &lirc_configfile, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies a config.file for LIRC"}, #endif - { "lirc", &use_lirc, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of lirc" }, - { "nolirc", &use_lirc, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, "disables using of lirc" }, - { "lircc", &use_lircc, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of lirc daemon" }, - { "nolircc", &use_lircc, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, "disables using of lirc daemon" }, + { "lirc", &libinput_conf.use_lirc, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of lirc" }, + { "nolirc", &libinput_conf.use_lirc, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, "disables using of lirc" }, + { "lircc", &libinput_conf.use_lircc, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of lirc daemon" }, + { "nolircc", &libinput_conf.use_lircc, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, "disables using of lirc daemon" }, { "joystick", &joystick_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Joystick related options" }, { NULL, NULL, 0, 0, 0, 0, NULL} }; @@ -435,61 +440,65 @@ 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); +static char* mp_input_get_key_name(any_t*,int key); -MPXP_Rc mp_input_add_cmd_fd(int fd, int sel, mp_cmd_func_t read_func, mp_close_func_t close_func) { - if(num_cmd_fd == MP_MAX_CMD_FD) { +MPXP_Rc mp_input_add_cmd_fd(any_t* handle,int fd, int sel, mp_cmd_func_t read_func, mp_close_func_t close_func) { + priv_t* priv = (priv_t*)handle; + if(priv->num_cmd_fd == MP_MAX_CMD_FD) { MSG_ERR("Too much command fd, unable to register fd %d\n",fd); return MPXP_False; } - 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_input_default_cmd_func; - cmd_fds[num_cmd_fd].close_func = close_func; - if(!sel) cmd_fds[num_cmd_fd].flags = MP_FD_NO_SELECT; - num_cmd_fd++; + memset(&priv->cmd_fds[priv->num_cmd_fd],0,sizeof(mp_input_fd_t)); + priv->cmd_fds[priv->num_cmd_fd].fd = fd; + priv->cmd_fds[priv->num_cmd_fd].read_func = read_func ? read_func : mp_input_default_cmd_func; + priv->cmd_fds[priv->num_cmd_fd].close_func = close_func; + if(!sel) priv->cmd_fds[priv->num_cmd_fd].flags = MP_FD_NO_SELECT; + priv->num_cmd_fd++; return MPXP_Ok; } -void mp_input_rm_cmd_fd(int fd) { +void mp_input_rm_cmd_fd(any_t* handle,int fd) { + priv_t* priv = (priv_t*)handle; unsigned int i; - for(i = 0; i < num_cmd_fd; i++) { - if(cmd_fds[i].fd == fd) break; + for(i = 0; i < priv->num_cmd_fd; i++) { + if(priv->cmd_fds[i].fd == fd) break; } - if(i == num_cmd_fd) return; - if(cmd_fds[i].close_func) cmd_fds[i].close_func(cmd_fds[i].fd); - if(cmd_fds[i].buffer) mp_free(cmd_fds[i].buffer); - if(i + 1 < num_cmd_fd) memmove(&cmd_fds[i],&cmd_fds[i+1],(num_cmd_fd - i - 1)*sizeof(mp_input_fd_t)); - num_cmd_fd--; + if(i == priv->num_cmd_fd) return; + if(priv->cmd_fds[i].close_func) priv->cmd_fds[i].close_func(priv->cmd_fds[i].fd); + if(priv->cmd_fds[i].buffer) mp_free(priv->cmd_fds[i].buffer); + if(i + 1 < priv->num_cmd_fd) memmove(&priv->cmd_fds[i],&priv->cmd_fds[i+1],(priv->num_cmd_fd - i - 1)*sizeof(mp_input_fd_t)); + priv->num_cmd_fd--; } -void mp_input_rm_key_fd(int fd) { +void mp_input_rm_key_fd(any_t* handle,int fd) { + priv_t* priv = (priv_t*)handle; unsigned int i; - for(i = 0; i < num_key_fd; i++) { - if(key_fds[i].fd == fd) break; + for(i = 0; i < priv->num_key_fd; i++) { + if(priv->key_fds[i].fd == fd) break; } - if(i == num_key_fd) return; - if(key_fds[i].close_func) key_fds[i].close_func(key_fds[i].fd); - if(i + 1 < num_key_fd) memmove(&key_fds[i],&key_fds[i+1],(num_key_fd - i - 1)*sizeof(mp_input_fd_t)); - num_key_fd--; + if(i == priv->num_key_fd) return; + if(priv->key_fds[i].close_func) priv->key_fds[i].close_func(priv->key_fds[i].fd); + if(i + 1 < priv->num_key_fd) memmove(&priv->key_fds[i],&priv->key_fds[i+1],(priv->num_key_fd - i - 1)*sizeof(mp_input_fd_t)); + priv->num_key_fd--; } -MPXP_Rc mp_input_add_key_fd(int fd, int sel, mp_key_func_t read_func, mp_close_func_t close_func) { - if(num_key_fd == MP_MAX_KEY_FD) { +MPXP_Rc mp_input_add_key_fd(any_t* handle,int fd, int sel, mp_key_func_t read_func, mp_close_func_t close_func) { + priv_t* priv = (priv_t*)handle; + if(priv->num_key_fd == MP_MAX_KEY_FD) { MSG_ERR("Too much key fd, unable to register fd %d\n",fd); return MPXP_False; } - 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 ? read_func : mp_input_default_key_func; - key_fds[num_key_fd].close_func = close_func; - if(!sel) key_fds[num_key_fd].flags |= MP_FD_NO_SELECT; - num_key_fd++; + memset(&priv->key_fds[priv->num_key_fd],0,sizeof(mp_input_fd_t)); + priv->key_fds[priv->num_key_fd].fd = fd; + priv->key_fds[priv->num_key_fd].read_func = read_func ? read_func : mp_input_default_key_func; + priv->key_fds[priv->num_key_fd].close_func = close_func; + if(!sel) priv->key_fds[priv->num_key_fd].flags |= MP_FD_NO_SELECT; + priv->num_key_fd++; return MPXP_Ok; } @@ -700,16 +709,16 @@ } } -void mp_input_add_cmd_filter(mp_input_cmd_filter func, any_t* ctx) { +void mp_input_add_cmd_filter(any_t* handle,mp_input_cmd_filter func, any_t* ctx) { + priv_t* priv = (priv_t*)handle; mp_cmd_filter_t* filter = mp_malloc(sizeof(mp_cmd_filter_t))/*, *prev*/; filter->filter = func; filter->ctx = ctx; - filter->next = cmd_filters; - cmd_filters = filter; + filter->next = priv->cmd_filters; + priv->cmd_filters = filter; } - static char* mp_input_find_bind_for_key(const mp_cmd_bind_t* binds, int n,int* keys) { int j; @@ -731,34 +740,37 @@ return binds[j].cmd; } -static mp_cmd_t* mp_input_get_cmd_from_keys(int n,int* keys, int paused) { +static mp_cmd_t* mp_input_get_cmd_from_keys(any_t* handle,int n,int* keys, int paused) { + priv_t* priv = (priv_t*)handle; char* cmd = NULL; mp_cmd_t* ret; - if(cmd_binds) cmd = mp_input_find_bind_for_key(cmd_binds,n,keys); - if(cmd == NULL) cmd = mp_input_find_bind_for_key(def_cmd_binds,n,keys); + UNUSED(paused); + if(priv->cmd_binds) cmd = mp_input_find_bind_for_key(priv->cmd_binds,n,keys); + if(cmd == NULL) cmd = mp_input_find_bind_for_key(def_cmd_binds,n,keys); if(cmd == NULL) { - MSG_WARN("No bind found for key %s",mp_input_get_key_name(keys[0])); + MSG_WARN("No bind found for key %s",mp_input_get_key_name(priv,keys[0])); if(n > 1) { int s; - for(s=1; s < n; s++) MSG_WARN("-%s",mp_input_get_key_name(keys[s])); + for(s=1; s < n; s++) MSG_WARN("-%s",mp_input_get_key_name(priv,keys[s])); } MSG_WARN(" \n"); return NULL; } ret = mp_input_parse_cmd(cmd); if(!ret) { - MSG_ERR("Invalid command for binded key %s",mp_input_get_key_name(key_down[0])); - if( num_key_down > 1) { + MSG_ERR("Invalid command for binded key %s",mp_input_get_key_name(priv,priv->key_down[0])); + if(priv->num_key_down > 1) { unsigned int s; - for(s=1; s < num_key_down; s++) MSG_ERR("-%s",mp_input_get_key_name(key_down[s])); + for(s=1; s < priv->num_key_down; s++) MSG_ERR("-%s",mp_input_get_key_name(priv,priv->key_down[s])); } MSG_ERR(" : %s \n",cmd); } return ret; } -int mp_input_read_key_code(int tim) { +static int mp_input_read_key_code(any_t* handle,int tim) { + priv_t* priv = (priv_t*)handle; #ifndef HAVE_NO_POSIX_SELECT fd_set fds; struct timeval tv,*time_val; @@ -766,27 +778,27 @@ int i,n=0,max_fd = 0; static int last_loop = 0; - if(num_key_fd == 0) return MP_INPUT_NOTHING; + if(priv->num_key_fd == 0) return MP_INPUT_NOTHING; #ifndef HAVE_NO_POSIX_SELECT FD_ZERO(&fds); #endif // Remove fd marked as dead and build the fd_set // n == number of fd's to be select() checked - for(i = 0; (unsigned int)i < num_key_fd; i++) { - if( (key_fds[i].flags & MP_FD_DEAD) ) { - mp_input_rm_key_fd(key_fds[i].fd); + for(i = 0; (unsigned int)i < priv->num_key_fd; i++) { + if( (priv->key_fds[i].flags & MP_FD_DEAD) ) { + mp_input_rm_key_fd(priv,priv->key_fds[i].fd); i--; continue; - } else if(key_fds[i].flags & MP_FD_NO_SELECT) continue; - if(key_fds[i].fd > max_fd) max_fd = key_fds[i].fd; + } else if(priv->key_fds[i].flags & MP_FD_NO_SELECT) continue; + if(priv->key_fds[i].fd > max_fd) max_fd = priv->key_fds[i].fd; #ifndef HAVE_NO_POSIX_SELECT - FD_SET(key_fds[i].fd,&fds); + FD_SET(priv->key_fds[i].fd,&fds); #endif n++; } - if(num_key_fd == 0) return MP_INPUT_NOTHING; + if(priv->num_key_fd == 0) return MP_INPUT_NOTHING; #ifndef HAVE_NO_POSIX_SELECT // if we have fd's without MP_FD_NO_SELECT flag, call select(): if(n>0){ @@ -807,39 +819,40 @@ for(i = last_loop + 1 ; i != last_loop ; i++) { int code = -1; // This is to check all fd in turn - if((unsigned int)i >= num_key_fd) { + if((unsigned int)i >= priv->num_key_fd) { i = -1; last_loop++; - last_loop %= (num_key_fd+1); + last_loop %= (priv->num_key_fd+1); continue; } #ifndef HAVE_NO_POSIX_SELECT // No input from this fd - if(! (key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(key_fds[i].fd,&fds)) + if(! (priv->key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(priv->key_fds[i].fd,&fds)) continue; #endif - if(key_fds[i].fd == 0) { // stdin is handled by getch2 + if(priv->key_fds[i].fd == 0) { // stdin is handled by getch2 code = getch2(tim); if(code < 0) code = MP_INPUT_NOTHING; - } else code = ((mp_key_func_t)key_fds[i].read_func)(key_fds[i].fd); + } else code = ((mp_key_func_t)priv->key_fds[i].read_func)(priv->key_fds[i].fd); if(code >= 0) return code; - if(code == MP_INPUT_ERROR) MSG_ERR("Error on key input fd %d\n",key_fds[i].fd); + if(code == MP_INPUT_ERROR) MSG_ERR("Error on key input fd %d\n",priv->key_fds[i].fd); else if(code == MP_INPUT_DEAD) { - MSG_ERR("Dead key input on fd %d\n",key_fds[i].fd); - key_fds[i].flags |= MP_FD_DEAD; + MSG_ERR("Dead key input on fd %d\n",priv->key_fds[i].fd); + priv->key_fds[i].flags |= MP_FD_DEAD; } } return MP_INPUT_NOTHING; } -static mp_cmd_t* mp_input_read_keys(int tim,int paused) { - int code = mp_input_read_key_code(tim); +static mp_cmd_t* mp_input_read_keys(any_t*handle,int tim,int paused) { + priv_t* priv = (priv_t*)handle; + int code = mp_input_read_key_code(priv,tim); unsigned int j; mp_cmd_t* ret; if(mp_input_key_cb) { - for( ; code >= 0 ; code = mp_input_read_key_code(0) ) { + for( ; code >= 0 ; code = mp_input_read_key_code(priv,0) ) { if(code & MP_KEY_DOWN) continue; code &= ~(MP_KEY_DOWN|MP_NO_REPEAT_KEY); mp_input_key_cb(code); @@ -847,78 +860,79 @@ return NULL; } - for( ; code >= 0 ; code = mp_input_read_key_code(0) ) { + for( ; code >= 0 ; code = mp_input_read_key_code(priv,0) ) { // key pushed if(code & MP_KEY_DOWN) { - if(num_key_down > MP_MAX_KEY_DOWN) { + if(priv->num_key_down > MP_MAX_KEY_DOWN) { MSG_ERR("Too much key down at the same time\n"); continue; } code &= ~MP_KEY_DOWN; // Check if we don't already have this key as pushed - for(j = 0; j < num_key_down; j++) { - if(key_down[j] == code) + for(j = 0; j < priv->num_key_down; j++) { + if(priv->key_down[j] == code) break; } - if(j != num_key_down) continue; - key_down[num_key_down] = code; - num_key_down++; - last_key_down = GetTimer(); - ar_state = 0; + if(j != priv->num_key_down) continue; + priv->key_down[priv->num_key_down] = code; + priv->num_key_down++; + priv->last_key_down = GetTimer(); + priv->ar_state = 0; continue; } // key released // Check if the key is in the down key, driver which can't send push event // send only release event - for(j = 0; j < num_key_down; j++) { - if(key_down[j] == code) break; + for(j = 0; j < priv->num_key_down; j++) { + if(priv->key_down[j] == code) break; } - if(j == num_key_down) { // key was not in the down keys : add it - if(num_key_down > MP_MAX_KEY_DOWN) { + if(j == priv->num_key_down) { // key was not in the down keys : add it + if(priv->num_key_down > MP_MAX_KEY_DOWN) { MSG_ERR("Too much key down at the same time\n"); continue; } - key_down[num_key_down] = code; - num_key_down++; - last_key_down = 1; + priv->key_down[priv->num_key_down] = code; + priv->num_key_down++; + priv->last_key_down = 1; } // We ignore key from last combination - ret = last_key_down ? mp_input_get_cmd_from_keys(num_key_down,key_down,paused) : NULL; + ret = priv->last_key_down ? mp_input_get_cmd_from_keys(priv,priv->num_key_down,priv->key_down,paused) : NULL; // Remove the key - if(j+1 < num_key_down) memmove(&key_down[j],&key_down[j+1],(num_key_down-(j+1))*sizeof(int)); - num_key_down--; - last_key_down = 0; - ar_state = -1; - if(ar_cmd) { - mp_cmd_free(ar_cmd); - ar_cmd = NULL; + if(j+1 < priv->num_key_down) memmove(&priv->key_down[j],&priv->key_down[j+1],(priv->num_key_down-(j+1))*sizeof(int)); + priv->num_key_down--; + priv->last_key_down = 0; + priv->ar_state = -1; + if(priv->ar_cmd) { + mp_cmd_free(priv->ar_cmd); + priv->ar_cmd = NULL; } if(ret) return ret; } // No input : autorepeat ? - if(ar_rate > 0 && ar_state >=0 && num_key_down > 0 && ! (key_down[num_key_down-1] & MP_NO_REPEAT_KEY)) { + if(libinput_conf.ar_rate > 0 && priv->ar_state >=0 && priv->num_key_down > 0 && !(priv->key_down[priv->num_key_down-1]&MP_NO_REPEAT_KEY)) { unsigned int t = GetTimer(); // First time : wait delay - if(ar_state == 0 && (t - last_key_down) >= ar_delay*1000) { - ar_cmd = mp_input_get_cmd_from_keys(num_key_down,key_down,paused); - if(!ar_cmd) { - ar_state = -1; + if(priv->ar_state == 0 && (t - priv->last_key_down) >= libinput_conf.ar_delay*1000) { + priv->ar_cmd = mp_input_get_cmd_from_keys(priv,priv->num_key_down,priv->key_down,paused); + if(!priv->ar_cmd) { + priv->ar_state = -1; return NULL; } - ar_state = 1; - last_ar = t; - return mp_cmd_clone(ar_cmd); + priv->ar_state = 1; + priv->last_ar = t; + return mp_cmd_clone(priv->ar_cmd); // Then send rate / sec event - } else if(ar_state == 1 && (t -last_ar) >= 1000000/ar_rate) { - last_ar = t; - return mp_cmd_clone(ar_cmd); + } else if(priv->ar_state == 1 && (t -priv->last_ar) >= 1000000/libinput_conf.ar_rate) { + priv->last_ar = t; + return mp_cmd_clone(priv->ar_cmd); } } return NULL; } -static mp_cmd_t* mp_input_read_cmds(int tim) { +static mp_cmd_t* mp_input_read_cmds(any_t* handle,int tim) { + priv_t* priv = (priv_t*)handle; #ifndef HAVE_NO_POSIX_SELECT fd_set fds; struct timeval tv,*time_val; @@ -927,25 +941,25 @@ mp_cmd_t* ret; static int last_loop = 0; - if(num_cmd_fd == 0) return NULL; + if(priv->num_cmd_fd == 0) return NULL; #ifndef HAVE_NO_POSIX_SELECT FD_ZERO(&fds); #endif - for(i = 0; (unsigned int)i < num_cmd_fd ; i++) { - if( (cmd_fds[i].flags & MP_FD_DEAD) || (cmd_fds[i].flags & MP_FD_EOF) ) { - mp_input_rm_cmd_fd(cmd_fds[i].fd); + for(i = 0; (unsigned int)i < priv->num_cmd_fd ; i++) { + if( (priv->cmd_fds[i].flags & MP_FD_DEAD) || (priv->cmd_fds[i].flags & MP_FD_EOF) ) { + mp_input_rm_cmd_fd(priv,priv->cmd_fds[i].fd); i--; continue; - } else if(cmd_fds[i].flags & MP_FD_NO_SELECT) continue; - if(cmd_fds[i].flags & MP_FD_GOT_CMD) got_cmd = 1; - if(cmd_fds[i].fd > max_fd) max_fd = cmd_fds[i].fd; + } else if(priv->cmd_fds[i].flags & MP_FD_NO_SELECT) continue; + if(priv->cmd_fds[i].flags & MP_FD_GOT_CMD) got_cmd = 1; + if(priv->cmd_fds[i].fd > max_fd) max_fd = priv->cmd_fds[i].fd; #ifndef HAVE_NO_POSIX_SELECT - FD_SET(cmd_fds[i].fd,&fds); + FD_SET(priv->cmd_fds[i].fd,&fds); #endif n++; } - if(num_cmd_fd == 0) return NULL; + if(priv->num_cmd_fd == 0) return NULL; #ifndef HAVE_NO_POSIX_SELECT if(tim >= 0) { tv.tv_sec=tim/1000; @@ -966,20 +980,20 @@ for(i = last_loop + 1; i != last_loop ; i++) { int r = 0; char* cmd; - if((unsigned int)i >= num_cmd_fd) { + if((unsigned int)i >= priv->num_cmd_fd) { i = -1; last_loop++; - last_loop %= (num_cmd_fd+1); + last_loop %= (priv->num_cmd_fd+1); continue; } #ifndef HAVE_NO_POSIX_SELECT - if( ! (cmd_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(cmd_fds[i].fd,&fds) && ! (cmd_fds[i].flags & MP_FD_GOT_CMD) ) + if(!(priv->cmd_fds[i].flags&MP_FD_NO_SELECT) && !FD_ISSET(priv->cmd_fds[i].fd,&fds) && !(priv->cmd_fds[i].flags & MP_FD_GOT_CMD)) continue; #endif - r = mp_input_read_cmd(&cmd_fds[i],&cmd); + r = mp_input_read_cmd(&priv->cmd_fds[i],&cmd); if(r < 0) { - if(r == MP_INPUT_ERROR) MSG_ERR("Error on cmd fd %d\n",cmd_fds[i].fd); - else if(r == MP_INPUT_DEAD) cmd_fds[i].flags |= MP_FD_DEAD; + if(r == MP_INPUT_ERROR) MSG_ERR("Error on cmd fd %d\n",priv->cmd_fds[i].fd); + else if(r == MP_INPUT_DEAD) priv->cmd_fds[i].flags |= MP_FD_DEAD; continue; } ret = mp_input_parse_cmd(cmd); @@ -992,24 +1006,26 @@ return NULL; } -MPXP_Rc mp_input_queue_cmd(mp_cmd_t* cmd) { - if(cmd_queue_length >= CMD_QUEUE_SIZE) return MPXP_False; - cmd_queue[cmd_queue_end] = cmd; - cmd_queue_end = (cmd_queue_end + 1) % CMD_QUEUE_SIZE; - cmd_queue_length++; +MPXP_Rc mp_input_queue_cmd(any_t* handle,mp_cmd_t* cmd) { + priv_t* priv = (priv_t*)handle; + if(priv->cmd_queue_length >= CMD_QUEUE_SIZE) return MPXP_False; + priv->cmd_queue[priv->cmd_queue_end] = cmd; + priv->cmd_queue_end = (priv->cmd_queue_end + 1) % CMD_QUEUE_SIZE; + priv->cmd_queue_length++; return MPXP_Ok; } -static mp_cmd_t* mp_input_get_queued_cmd(int peek_only) { +static mp_cmd_t* mp_input_get_queued_cmd(any_t* handle,int peek_only) { + priv_t* priv = (priv_t*)handle; mp_cmd_t* ret; - if(cmd_queue_length == 0) return NULL; + if(priv->cmd_queue_length == 0) return NULL; - ret = cmd_queue[cmd_queue_start]; + ret = priv->cmd_queue[priv->cmd_queue_start]; if (!peek_only) { - cmd_queue_length--; - cmd_queue_start = (cmd_queue_start + 1) % CMD_QUEUE_SIZE; + priv->cmd_queue_length--; + priv->cmd_queue_start = (priv->cmd_queue_start + 1) % CMD_QUEUE_SIZE; } return ret; } @@ -1018,29 +1034,30 @@ * \param peek_only when set, the returned command stays in the queue. * Do not mp_free the returned cmd whe you set this! */ -mp_cmd_t* mp_input_get_cmd(int tim, int paused, int peek_only) { +mp_cmd_t* mp_input_get_cmd(any_t*handle,int tim, int paused, int peek_only) { + priv_t* priv = (priv_t*)handle; mp_cmd_t* ret = NULL; mp_cmd_filter_t* cf; int from_queue; while(1) { from_queue = 1; - ret = mp_input_get_queued_cmd(peek_only); + ret = mp_input_get_queued_cmd(priv,peek_only); if(ret) break; from_queue = 0; - ret = mp_input_read_keys(tim,paused); + ret = mp_input_read_keys(priv,tim,paused); if(ret) break; - ret = mp_input_read_cmds(tim); + ret = mp_input_read_cmds(priv,tim); break; } if(!ret) return NULL; - for(cf = cmd_filters ; cf ; cf = cf->next) { + for(cf = priv->cmd_filters ; cf ; cf = cf->next) { if(cf->filter(ret,paused,cf->ctx)) return NULL; } - if (!from_queue && peek_only) mp_input_queue_cmd(ret); + if (!from_queue && peek_only) mp_input_queue_cmd(priv,ret); return ret; } @@ -1078,23 +1095,22 @@ return ret; } -static char key_str[12]; +static char* mp_input_get_key_name(any_t* handle,int key) { + priv_t* priv = (priv_t*)handle; + unsigned i; -static char* mp_input_get_key_name(int key) { - int i; - for(i = 0; key_names[i].name != NULL; i++) { if(key_names[i].key == key) return key_names[i].name; } if(isascii(key)) { - snprintf(key_str,12,"%c",(char)key); - return key_str; + snprintf(priv->key_str,12,"%c",(char)key); + return priv->key_str; } // Print the hex key code - snprintf(key_str,12,"%#-8x",key); - return key_str; + snprintf(priv->key_str,12,"%#-8x",key); + return priv->key_str; } static int mp_input_get_key_from_name(char* name) { @@ -1132,7 +1148,8 @@ return 1; } -void mp_input_bind_keys(int keys[MP_MAX_KEY_DOWN+1], char* cmd) { +static void mp_input_bind_keys(any_t* handle,int keys[MP_MAX_KEY_DOWN+1], char* cmd) { + priv_t* priv = (priv_t*)handle; int i = 0,j; mp_cmd_bind_t* _bind = NULL; @@ -1141,20 +1158,20 @@ assert(cmd != NULL); #endif - if(cmd_binds) { - for(i = 0; cmd_binds[i].cmd != NULL ; i++) { - for(j = 0 ; cmd_binds[i].input[j] == keys[j] && keys[j] != 0 ; j++) /* NOTHING */; - if(keys[j] == 0 && cmd_binds[i].input[j] == 0 ) { - _bind = &cmd_binds[i]; + if(priv->cmd_binds) { + for(i = 0; priv->cmd_binds[i].cmd != NULL ; i++) { + for(j = 0 ; priv->cmd_binds[i].input[j] == keys[j] && keys[j] != 0 ; j++) /* NOTHING */; + if(keys[j] == 0 && priv->cmd_binds[i].input[j] == 0 ) { + _bind = &priv->cmd_binds[i]; break; } } } if(!_bind) { - cmd_binds = (mp_cmd_bind_t*)mp_realloc(cmd_binds,(i+2)*sizeof(mp_cmd_bind_t)); - memset(&cmd_binds[i],0,2*sizeof(mp_cmd_bind_t)); - _bind = &cmd_binds[i]; + priv->cmd_binds = (mp_cmd_bind_t*)mp_realloc(priv->cmd_binds,(i+2)*sizeof(mp_cmd_bind_t)); + memset(&priv->cmd_binds[i],0,2*sizeof(mp_cmd_bind_t)); + _bind = &priv->cmd_binds[i]; } if(_bind->cmd) mp_free(_bind->cmd); _bind->cmd = mp_strdup(cmd); @@ -1171,7 +1188,8 @@ #define BS_MAX 256 #define SPACE_CHAR " \n\r\t" -static int mp_input_parse_config(char *file) { +static int mp_input_parse_config(any_t* handle,char *file) { + priv_t* priv = (priv_t*)handle; int fd; int bs = 0,r,eof = 0,comments = 0; char *iter,*end; @@ -1208,7 +1226,7 @@ // Empty buffer : return if(bs <= 1) { MSG_INFO("Input config file %s parsed : %d binds\n",file,n_binds); - if(binds) cmd_binds = binds; + if(binds) priv->cmd_binds = binds; close(fd); return 1; } @@ -1268,8 +1286,8 @@ // Found new line if(iter[0] == '\n' || iter[0] == '\r') { int i; - MSG_ERR("No command found for key %s" ,mp_input_get_key_name(keys[0])); - for(i = 1; keys[i] != 0 ; i++) MSG_ERR("-%s",mp_input_get_key_name(keys[i])); + MSG_ERR("No command found for key %s" ,mp_input_get_key_name(priv,keys[0])); + for(i = 1; keys[i] != 0 ; i++) MSG_ERR("-%s",mp_input_get_key_name(priv,keys[i])); MSG_ERR("\n"); keys[0] = 0; if(iter > buffer) { @@ -1294,7 +1312,7 @@ strncpy(cmd,iter,end-iter); cmd[end-iter] = '\0'; //printf("Set bind %d => %s\n",keys[0],cmd); - mp_input_bind_keys(keys,cmd); + mp_input_bind_keys(priv,keys,cmd); n_binds++; keys[0] = 0; end++; @@ -1309,102 +1327,120 @@ return 0; } -void mp_input_init(void) { +static void mp_input_init(any_t* handle) { + priv_t* priv = (priv_t*)handle; char* file; file = config_file[0] != '/' ? get_path(config_file) : config_file; if(!file) return; - if(! mp_input_parse_config(file)) { + if(! mp_input_parse_config(handle,file)) { // Try global conf dir file = CONFDIR "/input.conf"; - if(! mp_input_parse_config(file)) MSG_WARN("Falling back on default (hardcoded) input config\n"); + if(! mp_input_parse_config(handle,file)) MSG_WARN("Falling back on default (hardcoded) input config\n"); } #ifdef HAVE_JOYSTICK - if(use_joystick) { - int fd = mp_input_joystick_init(js_dev); - if(fd < 0) MSG_ERR("Can't init input joystick with using: %s\n",js_dev); - else mp_input_add_key_fd(fd,1,mp_input_joystick_read,(mp_close_func_t)close); + if(libinput_conf.use_joystick) { + priv->joystick_fd = mp_input_joystick_init(libinput_conf.js_dev); + if(priv->joystick_fd<=0) MSG_ERR("Can't init input joystick with using: %s\n",libinput_conf.js_dev); + else mp_input_add_key_fd(priv,priv->joystick_fd,1,mp_input_joystick_read,(mp_close_func_t)close); } #endif #ifdef HAVE_LIRC - if(use_lirc) { + if(libinput_conf.use_lirc) { int fd = mp_input_lirc_init(); if(fd > 0) mp_input_add_cmd_fd(fd,0,mp_input_lirc_read,mp_input_lirc_close); } #endif #ifdef HAVE_LIRCC - if(use_lircc) { + if(libinput_conf.use_lircc) { int fd = lircc_init("mplayer", NULL); if(fd >= 0) mp_input_add_cmd_fd(fd,1,NULL,(mp_close_func_t)lircc_cleanup); } #endif - if(in_file) { + if(libinput_conf.in_file) { struct stat st; - if(stat(in_file,&st)) MSG_ERR("Can't stat %s: %s\n",in_file,strerror(errno)); + if(stat(libinput_conf.in_file,&st)) MSG_ERR("Can't stat %s: %s\n",libinput_conf.in_file,strerror(errno)); else { - in_file_fd = open(in_file,S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY); - if(in_file_fd >= 0) mp_input_add_cmd_fd(in_file_fd,1,NULL,(mp_close_func_t)close); - else MSG_ERR("Can't open %s: %s\n",in_file,strerror(errno)); + priv->in_file_fd = open(libinput_conf.in_file,S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY); + if(priv->in_file_fd >= 0) mp_input_add_cmd_fd(priv,priv->in_file_fd,1,NULL,(mp_close_func_t)close); + else MSG_ERR("Can't open %s: %s\n",libinput_conf.in_file,strerror(errno)); } } } -void mp_input_uninit(void) { +static void mp_input_uninit(any_t* handle) { + priv_t* priv = (priv_t*)handle; unsigned int i; - for(i=0; i < num_key_fd; i++) { - if(key_fds[i].close_func) key_fds[i].close_func(key_fds[i].fd); + for(i=0; i < priv->num_key_fd; i++) { + if(priv->key_fds[i].close_func) priv->key_fds[i].close_func(priv->key_fds[i].fd); } - for(i=0; i < num_cmd_fd; i++) { - if(cmd_fds[i].close_func) cmd_fds[i].close_func(cmd_fds[i].fd); + for(i=0; i < priv->num_cmd_fd; i++) { + if(priv->cmd_fds[i].close_func) priv->cmd_fds[i].close_func(priv->cmd_fds[i].fd); } - if(cmd_binds) { - unsigned i=0; + if(priv->cmd_binds) { for(i=0;;i++) { - if(cmd_binds[i].cmd != NULL) mp_free(cmd_binds[i].cmd); + if(priv->cmd_binds[i].cmd != NULL) mp_free(priv->cmd_binds[i].cmd); else break; } - mp_free(cmd_binds); - cmd_binds=NULL; + mp_free(priv->cmd_binds); + priv->cmd_binds=NULL; } } +any_t* mp_input_open(void) { + priv_t* priv; + priv=mp_mallocz(sizeof(priv_t)); + priv->ar_state=-1; + priv->in_file_fd=-1; + mp_input_init(priv); + return priv; +} + +void mp_input_close(any_t* handle) { + mp_input_uninit(handle); + mp_free(handle); +} + void mp_input_register_options(m_config_t* cfg) { m_config_register_options(cfg,mp_input_opts); } -void mp_input_print_keys(void) { +void mp_input_print_keys(any_t*handle) { unsigned i; + UNUSED(handle); MSG_INFO("List of available KEYS:\n"); for(i= 0; key_names[i].name != NULL ; i++) MSG_INFO("%s\n",key_names[i].name); } -static int mp_input_print_key_list(const config_t* cfg) { - mp_input_print_keys(); +static int mp_input_print_key_list(any_t*handle,const config_t* cfg) { + UNUSED(cfg); + mp_input_print_keys(handle); exit(0); } -void mp_input_print_binds(void) { +void mp_input_print_binds(any_t*handle) { unsigned i,j; MSG_INFO("List of available key bindings:\n"); for(i=0; def_cmd_binds[i].cmd != NULL ; i++) { for(j=0;def_cmd_binds[i].input[j] != 0;j++) { - MSG_INFO(" %-20s",mp_input_get_key_name(def_cmd_binds[i].input[j])); + MSG_INFO(" %-20s",mp_input_get_key_name(handle,def_cmd_binds[i].input[j])); } MSG_INFO(" %s\n",def_cmd_binds[i].cmd); } } -void mp_input_print_cmds(void) { +void mp_input_print_cmds(any_t*handle) { const mp_cmd_t *cmd; int i,j; char* type; + UNUSED(handle); MSG_INFO("List of available input commands:\n"); for(i = 0; (cmd = &mp_cmds[i])->name != NULL ; i++) { MSG_INFO(" %-20.20s",cmd->name); @@ -1429,14 +1465,16 @@ } } -static int mp_input_print_cmd_list(const config_t* cfg) { - mp_input_print_cmds(); +static int mp_input_print_cmd_list(any_t*handle,const config_t* cfg) { + UNUSED(cfg); + mp_input_print_cmds(handle); exit(0); } -MPXP_Rc mp_input_check_interrupt(int tim) { +MPXP_Rc mp_input_check_interrupt(any_t* handle,int tim) { + priv_t* priv = (priv_t*)handle; mp_cmd_t* cmd; - if((cmd = mp_input_get_cmd(tim,0,1)) == NULL) return 0; + if((cmd = mp_input_get_cmd(handle,tim,0,1)) == NULL) return 0; switch(cmd->id) { case MP_CMD_QUIT: case MP_CMD_SOFT_QUIT: @@ -1447,7 +1485,7 @@ return MPXP_Ok; //<-- memory leaks here } // remove the cmd from the queue - cmd = mp_input_get_cmd(tim,0,0); + cmd = mp_input_get_cmd(priv,tim,0,0); mp_cmd_free(cmd); return MPXP_False; } Modified: mplayerxp/input/input.h =================================================================== --- mplayerxp/input/input.h 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/input/input.h 2012-11-10 10:58:25 UTC (rev 315) @@ -85,9 +85,7 @@ MP_CMD_ARG_STRING =2, MP_CMD_ARG_VOID =3, -#ifndef MP_CMD_MAX_ARGS MP_CMD_MAX_ARGS =10 -#endif }; // Error codes for the drivers @@ -106,33 +104,33 @@ }; typedef union mp_cmd_arg_value { - int i; - float f; - char* s; - any_t* v; + int i; + float f; + char* s; + any_t* v; } mp_cmd_arg_value_t; typedef struct mp_cmd_arg { - int type; - mp_cmd_arg_value_t v; + int type; + mp_cmd_arg_value_t v; } mp_cmd_arg_t; typedef struct mp_cmd { - int id; - char* name; - int nargs; - mp_cmd_arg_t args[MP_CMD_MAX_ARGS]; + int id; + char* name; + int nargs; + mp_cmd_arg_t args[MP_CMD_MAX_ARGS]; } mp_cmd_t; typedef struct mp_cmd_bind { - int input[MP_MAX_KEY_DOWN+1]; - char* cmd; + int input[MP_MAX_KEY_DOWN+1]; + char* cmd; } mp_cmd_bind_t; typedef struct mp_key_name { - int key; - char* name; + int key; + char* name; } mp_key_name_t; // These typedefs are for the drivers. They are the functions used to retrive @@ -152,32 +150,32 @@ // fd will be used. // The last arg can be NULL if nothing is needed to close the driver. The close // function can be used -extern MPXP_Rc mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func, mp_close_func_t close_func); +extern MPXP_Rc mp_input_add_cmd_fd(any_t* handle,int fd, int select, mp_cmd_func_t read_func, mp_close_func_t close_func); // This remove a cmd driver, you usally don't need to use it -extern void mp_input_rm_cmd_fd(int fd); +extern void mp_input_rm_cmd_fd(any_t* handle,int fd); // The args are the sames as for the keys drivers. If you don't use any valid fd you MUST // give a read_func. -extern MPXP_Rc mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t close_func); +extern MPXP_Rc mp_input_add_key_fd(any_t*handle,int fd, int select, mp_key_func_t read_func, mp_close_func_t close_func); // As for the cmd one you usally don't need this function -extern void mp_input_rm_key_fd(int fd); +extern void mp_input_rm_key_fd(any_t* handle,int fd); // This function can be used to reput a command in the system. It's used by libmpdemux // when it perform a blocking operation to resend the command it received to the main // loop. -extern MPXP_Rc mp_input_queue_cmd(mp_cmd_t* cmd); +extern MPXP_Rc mp_input_queue_cmd(any_t* handle,mp_cmd_t* cmd); // This function retrive the next avaible command waiting no more than time msec. // If pause is true, the next input will always return a pause command. -extern mp_cmd_t* mp_input_get_cmd(int time, int paused, int peek_only); +extern mp_cmd_t* mp_input_get_cmd(any_t*handle,int time, int paused, int peek_only); extern mp_cmd_t* mp_input_parse_cmd(char* str); /// These filter allow you to process the command before mplayer /// If a filter return a true value mp_input_get_cmd will return NULL -extern void mp_input_add_cmd_filter(mp_input_cmd_filter, any_t* ctx); +extern void mp_input_add_cmd_filter(any_t* handle,mp_input_cmd_filter, any_t* ctx); // After getting a command from mp_input_get_cmd you need to mp_free it using this // function @@ -187,14 +185,13 @@ extern mp_cmd_t* mp_cmd_clone(mp_cmd_t* cmd); // When you create a new driver you should add it in this 2 functions. -extern void mp_input_init(void); +extern any_t* mp_input_open(void); +extern void mp_input_close(any_t* handle); -extern void mp_input_uninit(void); - // Interruptible usleep: (used by libmpdemux) -extern MPXP_Rc mp_input_check_interrupt(int time); +extern MPXP_Rc mp_input_check_interrupt(any_t* handle,int time); -extern void mp_input_print_keys(void); -extern void mp_input_print_cmds(void); -extern void mp_input_print_binds(void); +extern void mp_input_print_keys(any_t*handle); +extern void mp_input_print_cmds(any_t*handle); +extern void mp_input_print_binds(any_t*handle); #endif Modified: mplayerxp/libmpcodecs/dec_video.c =================================================================== --- mplayerxp/libmpcodecs/dec_video.c 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/libmpcodecs/dec_video.c 2012-11-10 10:58:25 UTC (rev 315) @@ -120,10 +120,10 @@ #endif } -MPXP_Rc mpcv_ffmpeg_init(sh_video_t*sh_video) { +MPXP_Rc mpcv_ffmpeg_init(sh_video_t*sh_video,any_t* libinput) { /* Use ffmpeg's drivers as last hope */ mpvdec=mpcv_find_driver_by_name("ffmpeg"); - if(mpvdec->init(sh_video)!=MPXP_Ok){ + if(mpvdec->init(sh_video,libinput)!=MPXP_Ok){ MSG_ERR(MSGTR_CODEC_CANT_INITV); return MPXP_False; } @@ -131,7 +131,7 @@ return MPXP_Ok; } -MPXP_Rc mpcv_init(sh_video_t *sh_video,const char* codecname,const char * vfm,int status){ +MPXP_Rc mpcv_init(sh_video_t *sh_video,const char* codecname,const char * vfm,int status,any_t*libinput){ sh_video->codec=NULL; MSG_DBG3("mpcv_init(%p, %s, %s, %i)\n",sh_video,codecname,vfm,status); while((sh_video->codec=find_codec(sh_video->fourcc, @@ -159,7 +159,7 @@ if(!(mpvdec=mpcv_find_driver_by_name(sh_video->codec->driver_name))) continue; else MSG_DBG3("mpcv_init: mpcodecs_vd_drivers[%s]->mpvdec==0\n",mpcodecs_vd_drivers[i]->info->driver_name); // it's available, let's try to init! - if(mpvdec->init(sh_video)!=MPXP_Ok){ + if(mpvdec->init(sh_video,libinput)!=MPXP_Ok){ MSG_ERR(MSGTR_CODEC_CANT_INITV); continue; // try next... } Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/libmpcodecs/dec_video.h 2012-11-10 10:58:25 UTC (rev 315) @@ -3,9 +3,9 @@ #include "xmpcore/xmp_enums.h" // dec_video.c: -extern MPXP_Rc __FASTCALL__ mpcv_init(sh_video_t *sh_video, const char *codec_name,const char *family,int status); +extern MPXP_Rc __FASTCALL__ mpcv_init(sh_video_t *sh_video, const char *codec_name,const char *family,int status,any_t*libinput); extern void __FASTCALL__ mpcv_uninit(sh_video_t *sh_video); -extern MPXP_Rc __FASTCALL__ mpcv_ffmpeg_init(sh_video_t*); +extern MPXP_Rc __FASTCALL__ mpcv_ffmpeg_init(sh_video_t*,any_t* libinput); extern int __FASTCALL__ mpcv_decode(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame,float pts); Modified: mplayerxp/libmpcodecs/vd.c =================================================================== --- mplayerxp/libmpcodecs/vd.c 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/libmpcodecs/vd.c 2012-11-10 10:58:25 UTC (rev 315) @@ -96,7 +96,7 @@ extern vo_data_t* vo_data; extern const vd_functions_t* mpvdec; // FIXME! -MPXP_Rc mpcodecs_config_vo(sh_video_t *sh, int w, int h, any_t*tune){ +MPXP_Rc mpcodecs_config_vo(sh_video_t *sh, int w, int h, any_t*tune, any_t* libinput){ int i,j; unsigned int out_fmt=0; int screen_size_x=0;//SCREEN_SIZE_X; @@ -154,13 +154,13 @@ MSG_WARN("'%s' ",vo_format_name(sh->codec->outfmt[ind])); } MSG_WARN("Trying -vf fmtcvt\n"); - sc=vf=vf_open_filter(vf,sh,"fmtcvt",NULL); + sc=vf=vf_open_filter(vf,sh,"fmtcvt",NULL,libinput); goto csp_again; } else if(palette==1){ MSG_V("vd: Trying -vf palette...\n"); palette=-1; - vf=vf_open_filter(vf,sh,"palette",NULL); + vf=vf_open_filter(vf,sh,"palette",NULL,libinput); goto csp_again; } else { // sws failed, if the last filter (vf_vo) support MPEGPES try to append vf_lavc @@ -194,7 +194,7 @@ if(vo_data->flags&VFCAP_FLIPPED) vo_FLIP_REVERT(vo_data); if(vo_FLIP(vo_data) && !(vo_data->flags&VFCAP_FLIP)){ // we need to flip, but no flipping filter avail. - sh->vfilter=vf=vf_open_filter(vf,sh,"mirror","x"); + sh->vfilter=vf=vf_open_filter(vf,sh,"mirror","x",libinput); } // time to do aspect ratio corrections... Modified: mplayerxp/libmpcodecs/vd.h =================================================================== --- mplayerxp/libmpcodecs/vd.h 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/libmpcodecs/vd.h 2012-11-10 10:58:25 UTC (rev 315) @@ -17,7 +17,7 @@ { const vd_info_t* info; const config_t* options;/**< Optional: MPlayerXP's option related */ - MPXP_Rc (*__FASTCALL__ init)(sh_video_t *sh); + MPXP_Rc (*__FASTCALL__ init)(sh_video_t *sh,any_t* libinput); void (*__FASTCALL__ uninit)(sh_video_t *sh); MPXP_Rc (* control)(sh_video_t *sh,int cmd,any_t* arg, ...); mp_image_t* (*__FASTCALL__ decode)(sh_video_t *sh,any_t* data,int len,int flags); @@ -34,7 +34,7 @@ VDCTRL_RESYNC_STREAM =7 /* resync video stream if needed */ }; // callbacks: -MPXP_Rc __FASTCALL__ mpcodecs_config_vo(sh_video_t *sh, int w, int h, any_t*tune); +MPXP_Rc __FASTCALL__ mpcodecs_config_vo(sh_video_t *sh, int w, int h, any_t*tune, any_t* libinput); mp_image_t* __FASTCALL__ mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag,int w, int h); void __FASTCALL__ mpcodecs_draw_slice(sh_video_t* sh, mp_image_t*); void __FASTCALL__ mpcodecs_draw_image(sh_video_t* sh, mp_image_t *mpi); Modified: mplayerxp/libmpcodecs/vd_divx4.c =================================================================== --- mplayerxp/libmpcodecs/vd_divx4.c 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/libmpcodecs/vd_divx4.c 2012-11-10 10:58:25 UTC (rev 315) @@ -187,12 +187,12 @@ } // init driver -static MPXP_Rc init(sh_video_t *sh){ +static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ DecInit dinit; priv_t*p; int bits=12; if(!load_lib("libdivx"SLIBSUFFIX)) return MPXP_False; - if(!(mpcodecs_config_vo(sh,sh->src_w,sh->src_h,NULL))) return MPXP_False; + if(!(mpcodecs_config_vo(sh,sh->src_w,sh->src_h,NULL,libinput))) return MPXP_False; switch(sh->codec->outfmt[sh->outfmtidx]){ case IMGFMT_YV12: case IMGFMT_I420: Modified: mplayerxp/libmpcodecs/vd_dmo.c =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.c 2012-11-09 15:57:27 UTC (rev 314) +++ mplayerxp/libmpcodecs/vd_dmo.c 2012-11-10 10:58:25 UTC (rev 315) @@ -45,7 +45,7 @@ } // init driver -static MPXP_Rc init(sh_video_t *sh){ +static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ unsigned int out_fmt; if(!(sh->context=DMO_VideoDecoder_Open(sh->codec->dll_name,&sh->codec->guid, sh->bih, 0, 0))){ MSG_ERR(MSGTR_MissingDLLcodec,sh->codec->dll_name); @@ -53,7 +53,7 @@ "package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.tar.bz... [truncated message content] |