add .gitreview
[src/app-framework-binder.git] / bindings / audio / audio-pulse.h
1 /*
2  * Copyright (C) 2016 "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_PULSE_H
19 #define AUDIO_PULSE_H
20
21 #include <sys/time.h>
22 #include <pulse/pulseaudio.h>
23 #include <pulse/simple.h>
24 #include <pulse/error.h>
25
26 #include "audio-alsa.h"
27
28 typedef struct dev_ctx_pulse dev_ctx_pulse_T;
29 typedef struct alsa_info alsa_info_T;
30
31 struct dev_ctx_pulse {
32   char *sink_name;
33   char **card_name;
34   pa_mainloop *pa_loop;
35   pa_context *pa_context;
36   pa_simple *pa;
37   pa_cvolume volume;
38   int mute;
39   unsigned char refresh;
40   pthread_t thr;
41   unsigned char thr_should_run;
42   unsigned char thr_finished;
43 };
44
45 struct alsa_info {
46   char *device;
47   char *synonyms;
48 };
49
50 unsigned char _pulse_init (const char *, audioCtxHandleT *);
51 void _pulse_free (audioCtxHandleT *);
52 void _pulse_play (audioCtxHandleT *);
53 void _pulse_stop (audioCtxHandleT *);
54 unsigned int _pulse_get_volume (audioCtxHandleT *, unsigned int);
55 void _pulse_set_volume (audioCtxHandleT *, unsigned int, unsigned int);
56 void _pulse_set_volume_all (audioCtxHandleT *, unsigned int);
57 unsigned char _pulse_get_mute (audioCtxHandleT *);
58 void _pulse_set_mute (audioCtxHandleT *, unsigned char);
59
60 void  _pulse_context_cb (pa_context *, void *);
61 void  _pulse_sink_list_cb (pa_context *, const pa_sink_info *, int, void *);
62 void  _pulse_sink_info_cb (pa_context *, const pa_sink_info *, int, void *);
63 void* _pulse_play_thread_fn (void *);
64 void  _pulse_refresh_sink (dev_ctx_pulse_T *);
65
66 #endif /* AUDIO_PULSE_H */