Audio Plugin: add PulseAudio support
[src/app-framework-binder.git] / plugins / audio / audio-pulse.h
1 /*
2  * Copyright (C) 2016 "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_PULSE_H
20 #define AUDIO_PULSE_H
21
22 #include <sys/time.h>
23 #include <pulse/pulseaudio.h>
24 #include <pulse/simple.h>
25 #include <pulse/error.h>
26
27 #include "audio-alsa.h"
28 #include "local-def.h"
29
30 typedef struct dev_ctx_pulse dev_ctx_pulse_T;
31 typedef struct alsa_info alsa_info_T;
32
33 struct dev_ctx_pulse {
34   char *sink_name;
35   char **card_name;
36   pa_mainloop *pa_loop;
37   pa_context *pa_context;
38   pa_simple *pa;
39   pa_cvolume volume;
40   int mute;
41   unsigned char refresh;
42   pthread_t thr;
43   unsigned char thr_should_run;
44   unsigned char thr_finished;
45 };
46
47 struct alsa_info {
48   char *device;
49   char *synonyms;
50 };
51
52 STATIC void  _pulse_context_cb (pa_context *, void *);
53 STATIC void  _pulse_sink_list_cb (pa_context *, const pa_sink_info *, int, void *);
54 STATIC void  _pulse_sink_info_cb (pa_context *, const pa_sink_info *, int, void *);
55 STATIC void* _pulse_play_thread_fn (void *);
56 PUBLIC void  _pulse_refresh_sink (dev_ctx_pulse_T *);
57
58 static struct alsa_info **alsa_info = NULL;
59 static struct dev_ctx_pulse **dev_ctx_p = NULL;
60 static unsigned int client_count = 0;
61
62 #endif /* AUDIO_PULSE_H */