Simplify mixer setup.
[paraslash.git] / mix.h
1 /*
2  * Copyright (C) 2012 Andre Noll <maan@tuebingen.mpg.de>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** \file mix.h Mixer API for para_mixer. */
8
9 /**
10  * Opaque structure which corresponds to an instance of a mixer.
11  *
12  * A pointer to a structure of this type is returned by ->open().  This pointer
13  * must be passed to most other methods of \ref struct mixer.
14  */
15 struct mixer_handle;
16
17 /**
18  * Operations provided by each mixer plugin.
19  *
20  * Each mixer plugin must define a non-static instance of this structure, with
21  * all pointers initialized to non-NULL values. No other symbols need to be
22  * exported.
23  */
24 struct mixer {
25         /** Used to identify the mixer. */
26         const char * const name;
27         /** Return a handle that can be passed to other methods. */
28         int (*open)(const char *dev, struct mixer_handle **handle);
29         /** Returns a string of all valid mixer channels. */
30         char *(*get_channels)(struct mixer_handle *handle);
31         /** Select the channel for subsequent get/set operations. */
32         int (*set_channel)(struct mixer_handle *handle,
33                 const char *mixer_channel);
34         /** Return the (normalized) current value of the selected channel. */
35         int (*get)(struct mixer_handle *handle);
36         /** Change the value of the selected channel. */
37         int (*set)(struct mixer_handle *handle, int val);
38         /** Free all resources associated with the given handle. */
39         void (*close)(struct mixer_handle **handle);
40 };
41
42 /** Declared even if unsupported because it does not hurt and avoids ifdefs. */
43 extern const struct mixer alsa_mixer, oss_mixer;