Commands: new command "toggleoutput"
This commit is contained in:
parent
1a852bc365
commit
9e715089a4
2
NEWS
2
NEWS
|
@ -1,4 +1,6 @@
|
||||||
ver 0.18 (2012/??/??)
|
ver 0.18 (2012/??/??)
|
||||||
|
* protocol:
|
||||||
|
- new command "toggleoutput"
|
||||||
* innput:
|
* innput:
|
||||||
- soup: plugin removed
|
- soup: plugin removed
|
||||||
* decoder:
|
* decoder:
|
||||||
|
|
|
@ -1876,6 +1876,20 @@ OK
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry id="command_toggleoutput">
|
||||||
|
<term>
|
||||||
|
<cmdsynopsis>
|
||||||
|
<command>toggleoutput</command>
|
||||||
|
<arg choice="req"><replaceable>ID</replaceable></arg>
|
||||||
|
</cmdsynopsis>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Turns an output on or off, depending on the current
|
||||||
|
state.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry id="command_outputs">
|
<varlistentry id="command_outputs">
|
||||||
<term>
|
<term>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
|
|
|
@ -159,6 +159,7 @@ static const struct command commands[] = {
|
||||||
{ "swap", PERMISSION_CONTROL, 2, 2, handle_swap },
|
{ "swap", PERMISSION_CONTROL, 2, 2, handle_swap },
|
||||||
{ "swapid", PERMISSION_CONTROL, 2, 2, handle_swapid },
|
{ "swapid", PERMISSION_CONTROL, 2, 2, handle_swapid },
|
||||||
{ "tagtypes", PERMISSION_READ, 0, 0, handle_tagtypes },
|
{ "tagtypes", PERMISSION_READ, 0, 0, handle_tagtypes },
|
||||||
|
{ "toggleoutput", PERMISSION_ADMIN, 1, 1, handle_toggleoutput },
|
||||||
{ "unsubscribe", PERMISSION_READ, 1, 1, handle_unsubscribe },
|
{ "unsubscribe", PERMISSION_READ, 1, 1, handle_unsubscribe },
|
||||||
{ "update", PERMISSION_CONTROL, 0, 1, handle_update },
|
{ "update", PERMISSION_CONTROL, 0, 1, handle_update },
|
||||||
{ "urlhandlers", PERMISSION_READ, 0, 0, handle_urlhandlers },
|
{ "urlhandlers", PERMISSION_READ, 0, 0, handle_urlhandlers },
|
||||||
|
|
|
@ -84,3 +84,30 @@ audio_output_disable_index(unsigned idx)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
audio_output_toggle_index(unsigned idx)
|
||||||
|
{
|
||||||
|
struct audio_output *ao;
|
||||||
|
|
||||||
|
if (idx >= audio_output_count())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ao = audio_output_get(idx);
|
||||||
|
const bool enabled = ao->enabled = !ao->enabled;
|
||||||
|
idle_add(IDLE_OUTPUT);
|
||||||
|
|
||||||
|
if (!enabled) {
|
||||||
|
Mixer *mixer = ao->mixer;
|
||||||
|
if (mixer != nullptr) {
|
||||||
|
mixer_close(mixer);
|
||||||
|
idle_add(IDLE_MIXER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ao->player_control->UpdateAudio();
|
||||||
|
|
||||||
|
++audio_output_state_version;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -41,4 +41,11 @@ audio_output_enable_index(unsigned idx);
|
||||||
bool
|
bool
|
||||||
audio_output_disable_index(unsigned idx);
|
audio_output_disable_index(unsigned idx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles an audio output. Returns false if the specified output
|
||||||
|
* does not exist.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
audio_output_toggle_index(unsigned idx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,6 +64,22 @@ handle_disableoutput(Client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
return COMMAND_RETURN_OK;
|
return COMMAND_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum command_return
|
||||||
|
handle_toggleoutput(Client *client, gcc_unused int argc, char *argv[])
|
||||||
|
{
|
||||||
|
unsigned device;
|
||||||
|
if (!check_unsigned(client, &device, argv[1]))
|
||||||
|
return COMMAND_RETURN_ERROR;
|
||||||
|
|
||||||
|
if (!audio_output_toggle_index(device)) {
|
||||||
|
command_error(client, ACK_ERROR_NO_EXIST,
|
||||||
|
"No such audio output");
|
||||||
|
return COMMAND_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return COMMAND_RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
enum command_return
|
enum command_return
|
||||||
handle_devices(Client *client,
|
handle_devices(Client *client,
|
||||||
G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
|
G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
|
||||||
|
|
|
@ -30,6 +30,9 @@ handle_enableoutput(Client *client, int argc, char *argv[]);
|
||||||
enum command_return
|
enum command_return
|
||||||
handle_disableoutput(Client *client, int argc, char *argv[]);
|
handle_disableoutput(Client *client, int argc, char *argv[]);
|
||||||
|
|
||||||
|
enum command_return
|
||||||
|
handle_toggleoutput(Client *client, int argc, char *argv[]);
|
||||||
|
|
||||||
enum command_return
|
enum command_return
|
||||||
handle_devices(Client *client, int argc, char *argv[]);
|
handle_devices(Client *client, int argc, char *argv[]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue