diff -u input/input.c input/input.c --- input/input.c 2004-09-15 21:36:43.000000000 +0200 +++ input/input.c 2004-10-09 16:34:03.212506318 +0200 @@ -1126,7 +1126,7 @@ } static mp_cmd_t* -mp_input_get_queued_cmd(void) { +mp_input_get_queued_cmd(int peek_only) { mp_cmd_t* ret; if(cmd_queue_length == 0) @@ -1134,20 +1134,29 @@ ret = cmd_queue[cmd_queue_start]; + if (!peek_only) { cmd_queue_length--; cmd_queue_start = (cmd_queue_start + 1) % CMD_QUEUE_SIZE; + } return ret; } +/** + * \param peek_only when set, the returned command stays in the queue. + * Do not free the returned cmd whe you set this! + */ mp_cmd_t* -mp_input_get_cmd(int time, int paused) { +mp_input_get_cmd(int time, int paused, int peek_only) { mp_cmd_t* ret = NULL; mp_cmd_filter_t* cf; + int from_queue; while(1) { - ret = mp_input_get_queued_cmd(); + from_queue = 1; + ret = mp_input_get_queued_cmd(peek_only); if(ret) break; + from_queue = 0; ret = mp_input_read_keys(time,paused); if(ret) break; ret = mp_input_read_cmds(time); @@ -1160,6 +1169,9 @@ return NULL; } + if (!from_queue && peek_only) + mp_input_queue_cmd(ret); + return ret; } @@ -1610,7 +1622,7 @@ int mp_input_check_interrupt(int time) { mp_cmd_t* cmd; - if((cmd = mp_input_get_cmd(time,0)) == NULL) + if((cmd = mp_input_get_cmd(time,0,1)) == NULL) return 0; switch(cmd->id) { case MP_CMD_QUIT: @@ -1618,12 +1630,10 @@ case MP_CMD_PLAY_TREE_UP_STEP: case MP_CMD_PLAY_ALT_SRC_STEP: // The cmd will be executed when we are back in the main loop - if(! mp_input_queue_cmd(cmd)) { - mp_msg(MSGT_INPUT,MSGL_ERR,"mpdemux_check_interrupt: can't queue cmd %s\n",cmd->name); - mp_cmd_free(cmd); - } return 1; } + // remove the cmd from the queue + cmd = mp_input_get_cmd(time,0,0); mp_cmd_free(cmd); return 0; } diff -u input/input.h input/input.h --- input/input.h 2004-09-15 14:57:48.000000000 +0200 +++ input/input.h 2004-10-09 16:11:53.123617629 +0200 @@ -195,7 +195,7 @@ // This function retrieves the next available command waiting no more than time msec. // If pause is true, the next input will always return a pause command. mp_cmd_t* -mp_input_get_cmd(int time, int paused); +mp_input_get_cmd(int time, int paused, int peek_only); mp_cmd_t* mp_input_parse_cmd(char* str); --- mplayer.c 2004-10-07 17:16:15.000000000 +0200 +++ mplayer.c 2004-10-09 16:28:38.368748389 +0200 @@ -628,7 +628,7 @@ // The function return a new value for eof. static int libmpdemux_was_interrupted(int eof) { mp_cmd_t* cmd; - if((cmd = mp_input_get_cmd(0,0)) != NULL) { + if((cmd = mp_input_get_cmd(0,0,0)) != NULL) { switch(cmd->id) { case MP_CMD_QUIT: exit_player_with_rc(MSGTR_Exit_quit, (cmd->nargs > 0)? cmd->args[0].v.i : 0); @@ -1234,7 +1240,7 @@ usec_sleep(20000); guiEventHandling(); guiGetEvent( guiReDraw,NULL ); - if ( (cmd = mp_input_get_cmd(0,0)) != NULL) guiGetEvent( guiIEvent,(char *)cmd->id ); + if ( (cmd = mp_input_get_cmd(0,0,0)) != NULL) guiGetEvent( guiIEvent,(char *)cmd->id ); } guiGetEvent( guiSetParameters,NULL ); if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM ) @@ -2468,7 +2474,7 @@ if (audio_out && sh_audio) audio_out->pause(); // pause audio, keep data if possible - while( (cmd = mp_input_get_cmd(20,1)) == NULL) { + while( (cmd = mp_input_get_cmd(20,1,1)) == NULL) { if(sh_video && video_out && vo_config_count) video_out->check_events(); #ifdef HAVE_NEW_GUI if(use_gui){ @@ -2483,7 +2489,10 @@ #endif usec_sleep(20000); } + if (cmd->id == MP_CMD_PAUSE) { + cmd = mp_input_get_cmd(0,1,0); mp_cmd_free(cmd); + } osd_function=OSD_PLAY; if (audio_out && sh_audio) audio_out->resume(); // resume audio @@ -2548,7 +2557,7 @@ { mp_cmd_t* cmd; int brk_cmd = 0; - while( !brk_cmd && (cmd = mp_input_get_cmd(0,0)) != NULL) { + while( !brk_cmd && (cmd = mp_input_get_cmd(0,0,0)) != NULL) { switch(cmd->id) { case MP_CMD_SEEK : { int v,abs;