mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-01 10:13:45 -04:00
[player] Add command to get a single speaker info by its id
This commit is contained in:
parent
c165c55b5b
commit
db7b9c689b
72
src/player.c
72
src/player.c
@ -146,6 +146,12 @@ struct speaker_set_param
|
|||||||
int intval;
|
int intval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct speaker_get_param
|
||||||
|
{
|
||||||
|
uint64_t spk_id;
|
||||||
|
struct spk_info *spk_info;
|
||||||
|
};
|
||||||
|
|
||||||
struct metadata_param
|
struct metadata_param
|
||||||
{
|
{
|
||||||
struct input_metadata *input;
|
struct input_metadata *input;
|
||||||
@ -2407,6 +2413,25 @@ player_speaker_status_trigger(void)
|
|||||||
listener_notify(LISTENER_SPEAKER);
|
listener_notify(LISTENER_SPEAKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
device_to_speaker_info(struct spk_info *spk, struct output_device *device)
|
||||||
|
{
|
||||||
|
memset(spk, 0, sizeof(struct spk_info));
|
||||||
|
spk->id = device->id;
|
||||||
|
strncpy(spk->name, device->name, sizeof(spk->name));
|
||||||
|
spk->name[sizeof(spk->name) - 1] = '\0';
|
||||||
|
strncpy(spk->output_type, device->type_name, sizeof(spk->output_type));
|
||||||
|
spk->output_type[sizeof(spk->output_type) - 1] = '\0';
|
||||||
|
spk->relvol = device->relvol;
|
||||||
|
spk->absvol = device->volume;
|
||||||
|
|
||||||
|
spk->selected = device->selected;
|
||||||
|
spk->has_password = device->has_password;
|
||||||
|
spk->has_video = device->has_video;
|
||||||
|
spk->requires_auth = device->requires_auth;
|
||||||
|
spk->needs_auth_key = (device->requires_auth && device->auth_key == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static enum command_state
|
static enum command_state
|
||||||
speaker_enumerate(void *arg, int *retval)
|
speaker_enumerate(void *arg, int *retval)
|
||||||
{
|
{
|
||||||
@ -2418,18 +2443,7 @@ speaker_enumerate(void *arg, int *retval)
|
|||||||
{
|
{
|
||||||
if (device->advertised || device->selected)
|
if (device->advertised || device->selected)
|
||||||
{
|
{
|
||||||
spk.id = device->id;
|
device_to_speaker_info(&spk, device);
|
||||||
spk.name = device->name;
|
|
||||||
spk.output_type = device->type_name;
|
|
||||||
spk.relvol = device->relvol;
|
|
||||||
spk.absvol = device->volume;
|
|
||||||
|
|
||||||
spk.selected = device->selected;
|
|
||||||
spk.has_password = device->has_password;
|
|
||||||
spk.has_video = device->has_video;
|
|
||||||
spk.requires_auth = device->requires_auth;
|
|
||||||
spk.needs_auth_key = (device->requires_auth && device->auth_key == NULL);
|
|
||||||
|
|
||||||
spk_enum->cb(&spk, spk_enum->arg);
|
spk_enum->cb(&spk, spk_enum->arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2438,6 +2452,28 @@ speaker_enumerate(void *arg, int *retval)
|
|||||||
return COMMAND_END;
|
return COMMAND_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum command_state
|
||||||
|
speaker_get_byid(void *arg, int *retval)
|
||||||
|
{
|
||||||
|
struct speaker_get_param *spk_param = arg;
|
||||||
|
struct output_device *device;
|
||||||
|
|
||||||
|
for (device = dev_list; device; device = device->next)
|
||||||
|
{
|
||||||
|
if ((device->advertised || device->selected)
|
||||||
|
&& device->id == spk_param->spk_id)
|
||||||
|
{
|
||||||
|
device_to_speaker_info(spk_param->spk_info, device);
|
||||||
|
*retval = 0;
|
||||||
|
return COMMAND_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No output device found with matching id
|
||||||
|
*retval = -1;
|
||||||
|
return COMMAND_END;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
speaker_activate(struct output_device *device)
|
speaker_activate(struct output_device *device)
|
||||||
{
|
{
|
||||||
@ -3123,6 +3159,18 @@ player_speaker_set(uint64_t *ids)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
player_speaker_get_byid(uint64_t id, struct spk_info *spk)
|
||||||
|
{
|
||||||
|
struct speaker_get_param param;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
param.spk_id = id;
|
||||||
|
|
||||||
|
ret = commands_exec_sync(cmdbase, speaker_get_byid, NULL, ¶m);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
player_speaker_enable(uint64_t id)
|
player_speaker_enable(uint64_t id)
|
||||||
{
|
{
|
||||||
|
@ -31,8 +31,8 @@ enum repeat_mode {
|
|||||||
|
|
||||||
struct spk_info {
|
struct spk_info {
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
const char *name;
|
char name[255];
|
||||||
const char *output_type;
|
char output_type[50];
|
||||||
int relvol;
|
int relvol;
|
||||||
int absvol;
|
int absvol;
|
||||||
|
|
||||||
@ -95,6 +95,9 @@ player_speaker_enumerate(spk_enum_cb cb, void *arg);
|
|||||||
int
|
int
|
||||||
player_speaker_set(uint64_t *ids);
|
player_speaker_set(uint64_t *ids);
|
||||||
|
|
||||||
|
int
|
||||||
|
player_speaker_get_byid(uint64_t id, struct spk_info *spk);
|
||||||
|
|
||||||
int
|
int
|
||||||
player_speaker_enable(uint64_t id);
|
player_speaker_enable(uint64_t id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user