Debian Codegraph @

pulse/conf_pulse.c

raw symbols SCIP
1 /*-*- linux-c -*-*/
2
3 /*
4 * ALSA configuration function extensions for pulse
5 *
6 * Copyright (c) 2008 by Sjoerd Simons <[email protected]>
7 *
8 * This library is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 * 02111-1307 USA
22 *
23 */
24
25 #include <stdio.h>
26
27 #include <alsa/asoundlib.h>
28 #include <pulse/pulseaudio.h>
29
30
31 /* Not actually part of the alsa api.... */
32 extern int
33 snd_config_hook_load(snd_config_t * root, snd_config_t * config,
34 snd_config_t ** dst, snd_config_t * private_data);
35
36 int
37 conf_pulse_hook_load_if_running(snd_config_t * root, snd_config_t * config,
38 snd_config_t ** dst,
39 snd_config_t * private_data)
40 {
41 pa_mainloop *loop = NULL;
42 pa_context *context = NULL;
43 int ret = 0, err, state;
44
45 *dst = NULL;
46
47 /* Defined if we're called inside the pulsedaemon itself */
48 if (getenv("PULSE_INTERNAL") != NULL)
49 goto out;
50
51 loop = pa_mainloop_new();
52 if (loop == NULL)
53 goto out;
54
55 context = pa_context_new(pa_mainloop_get_api(loop), "Alsa hook");
56 if (context == NULL)
57 goto out;
58
59 err = pa_context_connect(context, NULL, 0, NULL);
60 if (err < 0)
61 goto out;
62
63 do {
64 err = pa_mainloop_iterate(loop, 1, NULL);
65 if (err < 0)
66 goto out;
67
68 state = pa_context_get_state(context);
69 } while (state < PA_CONTEXT_AUTHORIZING);
70
71 if (state > PA_CONTEXT_READY)
72 goto out;
73
74 ret = snd_config_hook_load(root, config, dst, private_data);
75
76 out:
77 if (context != NULL)
78 pa_context_unref(context);
79
80 if (loop != NULL)
81 pa_mainloop_free(loop);
82
83 return ret;
84 }
85
86 SND_DLSYM_BUILD_VERSION(conf_pulse_hook_load_if_running,
87 SND_CONFIG_DLSYM_VERSION_HOOK);