aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer_all.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-06 21:52:29 +0200
committerMax Kellermann <max@duempel.org>2009-07-06 21:52:29 +0200
commitda8095db546544bb9fe3a455ef5742bfef9c2f4f (patch)
treea9ba7360e17169970b0f1076ae2c78f80247e267 /src/mixer_all.c
parent5d74b1efefb5d992096c2cdfeceb8281114bbd0c (diff)
downloadmpd-da8095db546544bb9fe3a455ef5742bfef9c2f4f.tar.gz
mpd-da8095db546544bb9fe3a455ef5742bfef9c2f4f.tar.xz
mpd-da8095db546544bb9fe3a455ef5742bfef9c2f4f.zip
mixer_all: added mixer_all_set_software_volume()
The special-purpose function is used for saving/restore the software volume control to the state file.
Diffstat (limited to 'src/mixer_all.c')
-rw-r--r--src/mixer_all.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mixer_all.c b/src/mixer_all.c
index 980f854a2..cd05eec85 100644
--- a/src/mixer_all.c
+++ b/src/mixer_all.c
@@ -22,6 +22,9 @@
#include "output_all.h"
#include "output_plugin.h"
#include "output_internal.h"
+#include "pcm_volume.h"
+#include "mixer_api.h"
+#include "mixer_list.h"
#include <glib.h>
@@ -103,3 +106,57 @@ mixer_all_set_volume(unsigned volume)
return success;
}
+
+static int
+output_mixer_get_software_volume(unsigned i)
+{
+ struct audio_output *output;
+ struct mixer *mixer;
+
+ assert(i < audio_output_count());
+
+ output = audio_output_get(i);
+ if (!output->enabled)
+ return -1;
+
+ mixer = output->mixer;
+ if (mixer == NULL || mixer->plugin != &software_mixer_plugin)
+ return -1;
+
+ return mixer_get_volume(mixer);
+}
+
+int
+mixer_all_get_software_volume(void)
+{
+ unsigned count = audio_output_count(), ok = 0;
+ int volume, total = 0;
+
+ for (unsigned i = 0; i < count; i++) {
+ volume = output_mixer_get_software_volume(i);
+ if (volume >= 0) {
+ total += volume;
+ ++ok;
+ }
+ }
+
+ if (ok == 0)
+ return -1;
+
+ return total / ok;
+}
+
+void
+mixer_all_set_software_volume(unsigned volume)
+{
+ unsigned count = audio_output_count();
+
+ assert(volume <= PCM_VOLUME_1);
+
+ for (unsigned i = 0; i < count; i++) {
+ struct audio_output *output = audio_output_get(i);
+ if (output->mixer != NULL &&
+ output->mixer->plugin == &software_mixer_plugin)
+ mixer_set_volume(output->mixer, volume);
+ }
+}