[player] Add commands to enable/disable output

This commit is contained in:
chme 2018-02-07 23:05:23 +01:00
parent 93879c6f90
commit decf9f1329
2 changed files with 84 additions and 0 deletions

View File

@ -2534,6 +2534,60 @@ speaker_set(void *arg, int *retval)
return COMMAND_END;
}
static enum command_state
speaker_enable(void *arg, int *retval)
{
uint64_t *id = arg;
struct output_device *device;
*retval = 0;
DPRINTF(E_DBG, L_PLAYER, "Speaker enable: %" PRIu64 "\n", *id);
*retval = 0;
for (device = dev_list; device; device = device->next)
{
if (*id == device->id)
{
*retval = speaker_activate(device);
break;
}
}
if (*retval > 0)
return COMMAND_PENDING; // async
return COMMAND_END;
}
static enum command_state
speaker_disable(void *arg, int *retval)
{
uint64_t *id = arg;
struct output_device *device;
*retval = 0;
DPRINTF(E_DBG, L_PLAYER, "Speaker disable: %" PRIu64 "\n", *id);
*retval = 0;
for (device = dev_list; device; device = device->next)
{
if (*id == device->id)
{
*retval = speaker_deactivate(device);
break;
}
}
if (*retval > 0)
return COMMAND_PENDING; // async
return COMMAND_END;
}
static enum command_state
volume_set(void *arg, int *retval)
{
@ -2965,6 +3019,30 @@ player_speaker_set(uint64_t *ids)
return ret;
}
int
player_speaker_enable(uint64_t id)
{
int ret;
ret = commands_exec_sync(cmdbase, speaker_enable, NULL, &id);
listener_notify(LISTENER_SPEAKER);
return ret;
}
int
player_speaker_disable(uint64_t id)
{
int ret;
ret = commands_exec_sync(cmdbase, speaker_disable, NULL, &id);
listener_notify(LISTENER_SPEAKER);
return ret;
}
int
player_volume_set(int vol)
{

View File

@ -95,6 +95,12 @@ player_speaker_enumerate(spk_enum_cb cb, void *arg);
int
player_speaker_set(uint64_t *ids);
int
player_speaker_enable(uint64_t id);
int
player_speaker_disable(uint64_t id);
void
player_speaker_status_trigger(void);