5ac8ea490d49e9526a0ab92339f3d083e8bbaa36
[src/app-framework-binder.git] / plugins / audio / audio-alsa.h
1 /*
2  * Copyright (C) 2015 "IoT.bzh"
3  * Author "Manuel Bachmann"
4  *
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 3 of the License, or
8  * (at your option) any later version.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef AUDIO_ALSA_H
20 #define AUDIO_ALSA_H
21
22 #include <pthread.h>
23 #include <alsa/asoundlib.h>
24
25 #include "audio-api.h"
26 #include "local-def.h"
27
28 typedef struct dev_ctx_alsa dev_ctx_alsa_T;
29
30 struct dev_ctx_alsa {
31   char *name;
32   snd_pcm_t *dev;
33   snd_pcm_hw_params_t *params;
34   snd_mixer_elem_t *mixer_elm;
35   snd_mixer_elem_t *mixer_elm_m;
36   long vol_max;
37   long vol;
38   pthread_t thr;
39   unsigned char thr_should_run;
40   unsigned char thr_finished;
41 };
42
43 PUBLIC unsigned char _alsa_init (const char *, audioCtxHandleT *);
44 PUBLIC void _alsa_free (const char *);
45 PUBLIC void _alsa_play (int);
46 PUBLIC void _alsa_stop (int);
47 PUBLIC unsigned int _alsa_get_volume (int, unsigned int);
48 PUBLIC void _alsa_set_volume (int, unsigned int, unsigned int);
49 PUBLIC void _alsa_set_volume_all (int, unsigned int);
50 PUBLIC unsigned char _alsa_get_mute (int);
51 PUBLIC void _alsa_set_mute (int, unsigned char);
52 PUBLIC void _alsa_set_channels (int, unsigned int);
53 STATIC void* _alsa_play_thread_fn (void *);
54
55 static struct dev_ctx_alsa **dev_ctx_a = NULL;
56
57 #endif /* AUDIO_ALSA_H */