Merge pull request #296 from chme/segfaultaddingitems

Fix adding items while playing through dacp clients
This commit is contained in:
ejurgensen 2016-10-23 09:26:28 +02:00 committed by GitHub
commit ef4be65551
3 changed files with 10 additions and 5 deletions

View File

@ -15,6 +15,10 @@ enum command_state {
* If the function has pending events to complete, it needs to return * If the function has pending events to complete, it needs to return
* COMMAND_PENDING with 'ret' set to the number of pending events to wait for. * COMMAND_PENDING with 'ret' set to the number of pending events to wait for.
* *
* If the function returns with COMMAND_END, command execution will proceed
* with the "bottem half" function (if passed to the command_exec function) only
* if 'ret' is 0.
*
* @param arg Opaque pointer passed by command_exec_sync or command_exec_async * @param arg Opaque pointer passed by command_exec_sync or command_exec_async
* @param ret Pointer to the return value for the caller of the command * @param ret Pointer to the return value for the caller of the command
* @return COMMAND_END if there are no pending events (function execution is * @return COMMAND_END if there are no pending events (function execution is

View File

@ -1122,7 +1122,7 @@ mpd_command_pause(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
else else
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret != 0) if (ret < 0)
{ {
ret = asprintf(errmsg, "Failed to pause playback"); ret = asprintf(errmsg, "Failed to pause playback");
if (ret < 0) if (ret < 0)
@ -1177,7 +1177,7 @@ mpd_command_play(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
else else
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret != 0) if (ret < 0)
{ {
ret = asprintf(errmsg, "Failed to start playback"); ret = asprintf(errmsg, "Failed to start playback");
if (ret < 0) if (ret < 0)
@ -1227,7 +1227,7 @@ mpd_command_playid(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
else else
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret != 0) if (ret < 0)
{ {
ret = asprintf(errmsg, "Failed to start playback"); ret = asprintf(errmsg, "Failed to start playback");
if (ret < 0) if (ret < 0)

View File

@ -2316,7 +2316,7 @@ playback_start_item(union player_arg *cmdarg, int *retval, struct queue_item *qi
status_update(player_state); status_update(player_state);
*retval = 0; *retval = 1; // Value greater 0 will prevent execution of the bottom half function
return COMMAND_END; return COMMAND_END;
} }
@ -2673,7 +2673,8 @@ playback_pause(void *arg, int *retval)
DPRINTF(E_LOG, L_PLAYER, "Could not retrieve current position for pause\n"); DPRINTF(E_LOG, L_PLAYER, "Could not retrieve current position for pause\n");
playback_abort(); playback_abort();
return -1; *retval = -1;
return COMMAND_END;
} }
/* Make sure playback is still running after source_check() */ /* Make sure playback is still running after source_check() */