Adds 2017 to copyrights
[src/app-framework-binder.git] / bindings / audio / audio-alsa.h
1 /*
2  * Copyright (C) 2015, 2016, 2017 "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
26 #define AUDIO_BUFFER "/tmp/audio_buf"
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 unsigned char _alsa_init (const char *, audioCtxHandleT *);
44 void _alsa_free (const char *);
45 void _alsa_play (int);
46 void _alsa_stop (int);
47 unsigned int _alsa_get_volume (int, unsigned int);
48 void _alsa_set_volume (int, unsigned int, unsigned int);
49 void _alsa_set_volume_all (int, unsigned int);
50 unsigned char _alsa_get_mute (int);
51 void _alsa_set_mute (int, unsigned char);
52 void _alsa_set_channels (int, unsigned int);
53
54 void* _alsa_play_thread_fn (void *);
55
56 #endif /* AUDIO_ALSA_H */