027cc6f9a626acdd117a6f98c0ae83629e1b8ebf
[src/app-framework-binder.git] / plugins / 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 #include "local-def.h"
28
29 typedef struct dev_ctx_pulse dev_ctx_pulse_T;
30 typedef struct alsa_info alsa_info_T;
31
32 struct dev_ctx_pulse {
33   char *sink_name;
34   char **card_name;
35   pa_mainloop *pa_loop;
36   pa_context *pa_context;
37   pa_simple *pa;
38   pa_cvolume volume;
39   int mute;
40   unsigned char refresh;
41   pthread_t thr;
42   unsigned char thr_should_run;
43   unsigned char thr_finished;
44 };
45
46 struct alsa_info {
47   char *device;
48   char *synonyms;
49 };
50
51 PUBLIC unsigned char _pulse_init (const char *, audioCtxHandleT *);
52 PUBLIC void _pulse_free (audioCtxHandleT *);
53 PUBLIC void _pulse_play (audioCtxHandleT *);
54 PUBLIC void _pulse_stop (audioCtxHandleT *);
55 PUBLIC unsigned int _pulse_get_volume (audioCtxHandleT *, unsigned int);
56 PUBLIC void _pulse_set_volume (audioCtxHandleT *, unsigned int, unsigned int);
57 PUBLIC void _pulse_set_volume_all (audioCtxHandleT *, unsigned int);
58 PUBLIC unsigned char _pulse_get_mute (audioCtxHandleT *);
59 PUBLIC void _pulse_set_mute (audioCtxHandleT *, unsigned char);
60
61 STATIC void  _pulse_context_cb (pa_context *, void *);
62 STATIC void  _pulse_sink_list_cb (pa_context *, const pa_sink_info *, int, void *);
63 STATIC void  _pulse_sink_info_cb (pa_context *, const pa_sink_info *, int, void *);
64 STATIC void* _pulse_play_thread_fn (void *);
65 PUBLIC void  _pulse_refresh_sink (dev_ctx_pulse_T *);
66
67 static struct alsa_info **alsa_info = NULL;
68 static struct dev_ctx_pulse **dev_ctx_p = NULL;
69 static unsigned int client_count = 0;
70
71 #endif /* AUDIO_PULSE_H */