[input] Fixup 2: Seeking when rewinding to 0

This commit is contained in:
ejurgensen 2019-02-17 13:13:45 +01:00
parent c74b305983
commit de55acf797

View File

@ -226,8 +226,8 @@ flush(short *flags)
#endif #endif
} }
static enum command_state static void
stop(void *arg, int *retval) stop(void)
{ {
short flags; short flags;
int type; int type;
@ -242,15 +242,12 @@ stop(void *arg, int *retval)
flush(&flags); flush(&flags);
clear(&input_now_reading); clear(&input_now_reading);
*retval = 0;
return COMMAND_END;
} }
static int static int
seek(struct input_source *source, int seek_ms) seek(struct input_source *source, int seek_ms)
{ {
if (seek_ms > 0 && inputs[source->type]->seek) if (inputs[source->type]->seek)
return inputs[source->type]->seek(source, seek_ms); return inputs[source->type]->seek(source, seek_ms);
else else
return 0; return 0;
@ -287,14 +284,17 @@ setup(struct input_source *source, struct db_queue_item *queue_item, int seek_ms
source->open = true; source->open = true;
ret = seek(source, seek_ms); if (seek_ms > 0)
if (ret < 0) {
goto seek_error; ret = seek(source, seek_ms);
if (ret < 0)
goto seek_error;
}
return ret; return ret;
seek_error: seek_error:
stop(NULL, NULL); stop();
setup_error: setup_error:
clear(source); clear(source);
return -1; return -1;
@ -320,7 +320,7 @@ start(void *arg, int *retval)
else else
{ {
if (input_now_reading.open) if (input_now_reading.open)
stop(NULL, NULL); stop();
// Get the queue_item from the db // Get the queue_item from the db
queue_item = db_queue_fetch_byitemid(cmdarg->item_id); queue_item = db_queue_fetch_byitemid(cmdarg->item_id);
@ -351,6 +351,15 @@ start(void *arg, int *retval)
return COMMAND_END; return COMMAND_END;
} }
static enum command_state
stop_cmd(void *arg, int *retval)
{
stop();
*retval = 0;
return COMMAND_END;
}
/* /*
static enum command_state static enum command_state
next(void *arg, int *retval) next(void *arg, int *retval)
@ -699,7 +708,7 @@ input_start(uint32_t item_id)
void void
input_stop(void) input_stop(void)
{ {
commands_exec_async(cmdbase, stop, NULL); commands_exec_async(cmdbase, stop_cmd, NULL);
} }
void void