configure.ac: Move WAVE Encoder to Encoder Plugins.
[mpd-mk.git] / test / read_mixer.c
blob1b5b093a31de42a055a62185c509677b03ec454a
1 /*
2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "config.h"
21 #include "mixer_control.h"
22 #include "mixer_list.h"
23 #include "filter_registry.h"
24 #include "pcm_volume.h"
25 #include "event_pipe.h"
27 #include <glib.h>
29 #include <assert.h>
30 #include <string.h>
31 #include <unistd.h>
33 #ifdef HAVE_PULSE
34 #include "output/pulse_output_plugin.h"
36 void
37 pulse_output_set_mixer(G_GNUC_UNUSED struct pulse_output *po,
38 G_GNUC_UNUSED struct pulse_mixer *pm)
42 void
43 pulse_output_clear_mixer(G_GNUC_UNUSED struct pulse_output *po,
44 G_GNUC_UNUSED struct pulse_mixer *pm)
48 bool
49 pulse_output_set_volume(G_GNUC_UNUSED struct pulse_output *po,
50 G_GNUC_UNUSED const struct pa_cvolume *volume,
51 G_GNUC_UNUSED GError **error_r)
53 return false;
56 #endif
58 void
59 event_pipe_emit(G_GNUC_UNUSED enum pipe_event event)
63 const struct filter_plugin *
64 filter_plugin_by_name(G_GNUC_UNUSED const char *name)
66 assert(false);
67 return NULL;
70 bool
71 pcm_volume(G_GNUC_UNUSED void *buffer, G_GNUC_UNUSED int length,
72 G_GNUC_UNUSED const struct audio_format *format,
73 G_GNUC_UNUSED int volume)
75 assert(false);
76 return false;
79 int main(int argc, G_GNUC_UNUSED char **argv)
81 GError *error = NULL;
82 struct mixer *mixer;
83 bool success;
84 int volume;
86 if (argc != 2) {
87 g_printerr("Usage: read_mixer PLUGIN\n");
88 return 1;
91 g_thread_init(NULL);
93 mixer = mixer_new(&alsa_mixer_plugin, NULL, NULL, &error);
94 if (mixer == NULL) {
95 g_printerr("mixer_new() failed: %s\n", error->message);
96 g_error_free(error);
97 return 2;
100 success = mixer_open(mixer, &error);
101 if (!success) {
102 mixer_free(mixer);
103 g_printerr("failed to open the mixer: %s\n", error->message);
104 g_error_free(error);
105 return 2;
108 volume = mixer_get_volume(mixer, &error);
109 mixer_close(mixer);
110 mixer_free(mixer);
112 assert(volume >= -1 && volume <= 100);
114 if (volume < 0) {
115 if (error != NULL) {
116 g_printerr("failed to read volume: %s\n",
117 error->message);
118 g_error_free(error);
119 } else
120 g_printerr("failed to read volume\n");
121 return 2;
124 g_print("%d\n", volume);
125 return 0;