summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-10-10 17:39:07 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-10-10 17:39:07 +0000
commit830b241f3ff30e013db38be3077616f191289203 (patch)
tree79360743b078d3947a8d258e509f668bb9b4c1a3 /input
parent320e68675a1976afd2fdc6e8bcd465634bea9b05 (diff)
downloadmpv-830b241f3ff30e013db38be3077616f191289203.tar.bz2
mpv-830b241f3ff30e013db38be3077616f191289203.tar.xz
Do not loose commands while paused.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13604 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'input')
-rw-r--r--input/input.c26
-rw-r--r--input/input.h2
2 files changed, 19 insertions, 9 deletions
diff --git a/input/input.c b/input/input.c
index 89d289c714..d2e4833bca 100644
--- a/input/input.c
+++ b/input/input.c
@@ -1126,7 +1126,7 @@ mp_input_queue_cmd(mp_cmd_t* cmd) {
}
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 @@ mp_input_get_queued_cmd(void) {
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 @@ mp_input_get_cmd(int time, int paused) {
return NULL;
}
+ if (!from_queue && peek_only)
+ mp_input_queue_cmd(ret);
+
return ret;
}
@@ -1610,7 +1622,7 @@ static int mp_input_print_cmd_list(m_option_t* cfg) {
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 @@ mp_input_check_interrupt(int time) {
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 --git a/input/input.h b/input/input.h
index a6b1948806..1c218aaa2a 100644
--- a/input/input.h
+++ b/input/input.h
@@ -195,7 +195,7 @@ mp_input_queue_cmd(mp_cmd_t* cmd);
// 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);