changing the license to apache 2
[src/app-framework-binder.git] / plugins / audio / audio-alsa.h
1 /*
2  * Copyright (C) 2015 "IoT.bzh"
3  * Author "Manuel Bachmann"
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef AUDIO_ALSA_H
19 #define AUDIO_ALSA_H
20
21 #include <pthread.h>
22 #include <alsa/asoundlib.h>
23
24 #include "audio-api.h"
25 #include "local-def.h"
26
27 typedef struct dev_ctx_alsa dev_ctx_alsa_T;
28
29 struct dev_ctx_alsa {
30   char *name;
31   snd_pcm_t *dev;
32   snd_pcm_hw_params_t *params;
33   snd_mixer_elem_t *mixer_elm;
34   snd_mixer_elem_t *mixer_elm_m;
35   long vol_max;
36   long vol;
37   pthread_t thr;
38   unsigned char thr_should_run;
39   unsigned char thr_finished;
40 };
41
42 PUBLIC unsigned char _alsa_init (const char *, audioCtxHandleT *);
43 PUBLIC void _alsa_free (const char *);
44 PUBLIC void _alsa_play (int);
45 PUBLIC void _alsa_stop (int);
46 PUBLIC unsigned int _alsa_get_volume (int, unsigned int);
47 PUBLIC void _alsa_set_volume (int, unsigned int, unsigned int);
48 PUBLIC void _alsa_set_volume_all (int, unsigned int);
49 PUBLIC unsigned char _alsa_get_mute (int);
50 PUBLIC void _alsa_set_mute (int, unsigned char);
51 PUBLIC void _alsa_set_channels (int, unsigned int);
52 STATIC void* _alsa_play_thread_fn (void *);
53
54 static struct dev_ctx_alsa **dev_ctx_a = NULL;
55
56 #endif /* AUDIO_ALSA_H */