diff options
author | Max Kellermann <max@duempel.org> | 2013-08-04 23:20:56 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-04 23:21:23 +0200 |
commit | 9e715089a4279d08b7cc8d7fbdb3eb8696230e65 (patch) | |
tree | e075d02a6355e58d2241109eb30009b6b5baa2bc /src/OutputCommand.cxx | |
parent | 1a852bc365971960b0c8fd180f71a14396c81d8c (diff) | |
download | mpd-9e715089a4279d08b7cc8d7fbdb3eb8696230e65.tar.gz mpd-9e715089a4279d08b7cc8d7fbdb3eb8696230e65.tar.xz mpd-9e715089a4279d08b7cc8d7fbdb3eb8696230e65.zip |
Commands: new command "toggleoutput"
Diffstat (limited to '')
-rw-r--r-- | src/OutputCommand.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/OutputCommand.cxx b/src/OutputCommand.cxx index bf051babf..f6b35c6ed 100644 --- a/src/OutputCommand.cxx +++ b/src/OutputCommand.cxx @@ -84,3 +84,30 @@ audio_output_disable_index(unsigned idx) 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; +} |