mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
[player] Add player_speaker_authorize()
A more straightforward function for device verification, using the new outputs_device_authorize() function.
This commit is contained in:
parent
2fa2d33602
commit
18e75c2445
36
src/player.c
36
src/player.c
@ -147,6 +147,8 @@ struct speaker_attr_param
|
||||
|
||||
bool prevent_playback;
|
||||
bool busy;
|
||||
|
||||
const char *pin;
|
||||
};
|
||||
|
||||
struct speaker_get_param
|
||||
@ -1552,7 +1554,7 @@ device_activate_cb(struct output_device *device, enum output_device_state status
|
||||
retval = commands_exec_returnvalue(cmdbase);
|
||||
if (!device)
|
||||
{
|
||||
DPRINTF(E_WARN, L_PLAYER, "Output device disappeared during startup!\n");
|
||||
DPRINTF(E_WARN, L_PLAYER, "Output device disappeared during activation!\n");
|
||||
|
||||
if (retval != -2)
|
||||
retval = -1;
|
||||
@ -2752,6 +2754,24 @@ speaker_resurrect_bh(void *arg, int *retval)
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
static enum command_state
|
||||
speaker_authorize(void *arg, int *retval)
|
||||
{
|
||||
struct speaker_attr_param *param = arg;
|
||||
struct output_device *device;
|
||||
|
||||
device = outputs_device_get(param->spk_id);
|
||||
if (!device)
|
||||
return COMMAND_END;
|
||||
|
||||
*retval = outputs_device_authorize(device, param->pin, device_activate_cb);
|
||||
|
||||
if (*retval > 0)
|
||||
return COMMAND_PENDING; // async
|
||||
|
||||
return COMMAND_END;
|
||||
}
|
||||
|
||||
static enum command_state
|
||||
volume_set(void *arg, int *retval)
|
||||
{
|
||||
@ -3227,6 +3247,20 @@ player_speaker_resurrect(void *arg)
|
||||
commands_exec_sync(cmdbase, speaker_resurrect, speaker_resurrect_bh, ¶m);
|
||||
}
|
||||
|
||||
int
|
||||
player_speaker_authorize(uint64_t id, const char *pin)
|
||||
{
|
||||
struct speaker_attr_param param;
|
||||
int ret;
|
||||
|
||||
param.spk_id = id;
|
||||
param.pin = pin;
|
||||
|
||||
ret = commands_exec_sync(cmdbase, speaker_authorize, speaker_generic_bh, ¶m);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
player_volume_set(int vol)
|
||||
{
|
||||
|
@ -114,6 +114,9 @@ player_speaker_busy_set(uint64_t id, bool busy);
|
||||
void
|
||||
player_speaker_resurrect(void *arg);
|
||||
|
||||
int
|
||||
player_speaker_authorize(uint64_t id, const char *pin);
|
||||
|
||||
int
|
||||
player_playback_start(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user