mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 07:35:57 -05:00
Merge pull request #281 from chme/fixretrun
Fix return values in command functions
This commit is contained in:
commit
58f0451625
@ -65,7 +65,7 @@ command_cb_async(struct commands_base *cmdbase, struct command *cmd)
|
||||
cmdstate = cmd->func(cmd->arg, &cmd->ret);
|
||||
|
||||
// Only free arg if there are no pending events (used in worker.c)
|
||||
if (cmdstate == COMMAND_END && cmd->arg)
|
||||
if (cmdstate != COMMAND_PENDING && cmd->arg)
|
||||
free(cmd->arg);
|
||||
|
||||
free(cmd);
|
||||
@ -84,7 +84,13 @@ command_cb_sync(struct commands_base *cmdbase, struct command *cmd)
|
||||
pthread_mutex_lock(&cmd->lck);
|
||||
|
||||
cmdstate = cmd->func(cmd->arg, &cmd->ret);
|
||||
if (cmdstate == COMMAND_END)
|
||||
if (cmdstate == COMMAND_PENDING)
|
||||
{
|
||||
// Command execution is waiting for pending events before returning to the caller
|
||||
cmdbase->current_cmd = cmd;
|
||||
cmd->pending = cmd->ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Command execution finished, execute the bottom half function
|
||||
if (cmd->ret == 0 && cmd->func_bh)
|
||||
@ -98,12 +104,6 @@ command_cb_sync(struct commands_base *cmdbase, struct command *cmd)
|
||||
|
||||
event_add(cmdbase->command_event, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Command execution is waiting for pending events before returning to the caller
|
||||
cmdbase->current_cmd = cmd;
|
||||
cmd->pending = cmd->ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
16
src/player.c
16
src/player.c
@ -2346,7 +2346,8 @@ playback_start_item(union player_arg *cmdarg, int *retval, struct queue_item *qi
|
||||
if (ret < 0)
|
||||
{
|
||||
playback_abort();
|
||||
return -1;
|
||||
*retval = -1;
|
||||
return COMMAND_END;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2529,7 +2530,8 @@ playback_prev_bh(void *arg, int *retval)
|
||||
{
|
||||
playback_abort();
|
||||
|
||||
return -1;
|
||||
*retval = -1;
|
||||
return COMMAND_END;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2936,7 +2938,10 @@ volume_setrel_speaker(void *arg, int *retval)
|
||||
continue;
|
||||
|
||||
if (!device->selected)
|
||||
return 0;
|
||||
{
|
||||
*retval = 0;
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
device->relvol = relvol;
|
||||
device->volume = rel_to_vol(relvol);
|
||||
@ -3015,7 +3020,10 @@ repeat_set(void *arg, int *retval)
|
||||
union player_arg *cmdarg = arg;
|
||||
|
||||
if (cmdarg->mode == repeat)
|
||||
return 0;
|
||||
{
|
||||
*retval = 0;
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
switch (cmdarg->mode)
|
||||
{
|
||||
|
@ -1068,7 +1068,8 @@ playback_eot(void *arg, int *retval)
|
||||
if (SP_ERROR_OK != err)
|
||||
{
|
||||
DPRINTF(E_LOG, L_SPOTIFY, "Playback end of track failed: %s\n", fptr_sp_error_message(err));
|
||||
return -1;
|
||||
*retval = -1;
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
g_state = SPOTIFY_STATE_STOPPING;
|
||||
|
Loading…
Reference in New Issue
Block a user