]> code.delx.au - pulseaudio/blob - src/modules/bluetooth/bluez5-util.c
0f23bff2d981c99480247544b319b4da9fc27817
[pulseaudio] / src / modules / bluetooth / bluez5-util.c
1 /***
2 This file is part of PulseAudio.
3
4 Copyright 2008-2013 João Paulo Rechi Vita
5
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <pulse/xmalloc.h>
27
28 #include <pulsecore/core.h>
29 #include <pulsecore/macro.h>
30 #include <pulsecore/refcnt.h>
31 #include <pulsecore/shared.h>
32
33 #include "bluez5-util.h"
34
35 struct pa_bluetooth_discovery {
36 PA_REFCNT_DECLARE;
37
38 pa_core *core;
39 };
40
41 pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
42 pa_bluetooth_discovery *y;
43
44 if ((y = pa_shared_get(c, "bluetooth-discovery")))
45 return pa_bluetooth_discovery_ref(y);
46
47 y = pa_xnew0(pa_bluetooth_discovery, 1);
48 PA_REFCNT_INIT(y);
49 y->core = c;
50
51 pa_shared_set(c, "bluetooth-discovery", y);
52
53 return y;
54 }
55
56 pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y) {
57 pa_assert(y);
58 pa_assert(PA_REFCNT_VALUE(y) > 0);
59
60 PA_REFCNT_INC(y);
61
62 return y;
63 }
64
65 void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
66 pa_assert(y);
67 pa_assert(PA_REFCNT_VALUE(y) > 0);
68
69 if (PA_REFCNT_DEC(y) > 0)
70 return;
71
72 pa_shared_remove(y->core, "bluetooth-discovery");
73 pa_xfree(y);
74 }