~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulsecore/dbus-shared.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-05-05 14:18:20 UTC
  • mfrom: (1.2.4 upstream) (1.1.8 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090505141820-rrr2mtdd1jkllvr8
Tags: 1:0.9.15-1ubuntu1
* Merge from unreleased Debian pulseaudio git, remaining changes:
  - epoch (my stupid fault :S)
  - Don't build against, and create jack package. Jack is not in main
  - use linear resampler to work better with lack of PREEMPT in jaunty's
    -generic kernel config, also change buffer size
  - Add alsa configuration files to route alsa applications via pulseaudio
  - Move libasound2-plugins from Recommends to Depends
  - Add pm-utils sleep hook to suspend (and resume) users' pulseaudio
    daemons
  - patch to fix source/sink and suspend-on-idle race
  - Make initscript more informative in the default case of per-user
    sessions
  - create /var/run/pulse, and make restart more robust
  - add status check for system wide pulseaudio instance
  - LSB {Required-*,Should-*} should specify hal instead of dbus,
    since hal is required (and already requires dbus)
  - indicate that the system pulseaudio instance is being started from the init
    script
  - Install more upstream man pages
  - Link to pacat for parec man page
  - check whether pulseaudio is running before preloading the padsp library
  - Add DEB_OPT_FLAG = -O3 as per recommendation from
    pulseaudio-discuss/2007-December/001017.html
  - cache /usr/share/sounds/ubuntu/stereo/ wav files on pulseaudio load
  - disable glitch free (use tsched=0)
  - Generate a PO template on build
  - add special case to disable pulseaudio loading if accessibility/speech
    is being used
  - the sd wrapper script should not load pulseaudio if pulseaudio is being
    used as a system service
  - add a pulseaudio apport hook
  - fix some typos in README.Debian
  - demote paprefs to suggests
  - drop padevchooser(Recommends) and pavucontrol (Suggests)
  - drop libasyncns-dev build dependency, its in universe
* add libudev-dev as a build-dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***
 
2
  This file is part of PulseAudio.
 
3
 
 
4
  Copyright 2004-2006, 2009 Lennart Poettering
 
5
  Copyright 2006 Shams E. King
 
6
 
 
7
  PulseAudio is free software; you can redistribute it and/or modify
 
8
  it under the terms of the GNU Lesser General Public License as published
 
9
  by the Free Software Foundation; either version 2.1 of the License,
 
10
  or (at your option) any later version.
 
11
 
 
12
  PulseAudio is distributed in the hope that it will be useful, but
 
13
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
15
  General Public License for more details.
 
16
 
 
17
  You should have received a copy of the GNU Lesser General Public License
 
18
  along with PulseAudio; if not, write to the Free Software
 
19
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 
20
  USA.
 
21
***/
 
22
 
 
23
#ifdef HAVE_CONFIG_H
 
24
#include <config.h>
 
25
#endif
 
26
 
 
27
#include <stdarg.h>
 
28
 
 
29
#include <pulse/xmalloc.h>
 
30
#include <pulse/timeval.h>
 
31
#include <pulsecore/log.h>
 
32
#include <pulsecore/shared.h>
 
33
 
 
34
#include "dbus-shared.h"
 
35
 
 
36
struct pa_dbus_connection {
 
37
    PA_REFCNT_DECLARE;
 
38
 
 
39
    pa_dbus_wrap_connection *connection;
 
40
    pa_core *core;
 
41
    const char *property_name;
 
42
};
 
43
 
 
44
static pa_dbus_connection* dbus_connection_new(pa_core *c, pa_dbus_wrap_connection *conn, const char *name) {
 
45
    pa_dbus_connection *pconn;
 
46
 
 
47
    pconn = pa_xnew(pa_dbus_connection, 1);
 
48
    PA_REFCNT_INIT(pconn);
 
49
    pconn->core = c;
 
50
    pconn->property_name = name;
 
51
    pconn->connection = conn;
 
52
 
 
53
    pa_shared_set(c, name, pconn);
 
54
 
 
55
    return pconn;
 
56
}
 
57
 
 
58
pa_dbus_connection* pa_dbus_bus_get(pa_core *c, DBusBusType type, DBusError *error) {
 
59
 
 
60
    static const char *const prop_name[] = {
 
61
        [DBUS_BUS_SESSION] = "dbus-connection-session",
 
62
        [DBUS_BUS_SYSTEM] = "dbus-connection-system",
 
63
        [DBUS_BUS_STARTER] = "dbus-connection-starter"
 
64
    };
 
65
    pa_dbus_wrap_connection *conn;
 
66
    pa_dbus_connection *pconn;
 
67
 
 
68
    pa_assert(type == DBUS_BUS_SYSTEM || type == DBUS_BUS_SESSION || type == DBUS_BUS_STARTER);
 
69
 
 
70
    if ((pconn = pa_shared_get(c, prop_name[type])))
 
71
        return pa_dbus_connection_ref(pconn);
 
72
 
 
73
    if (!(conn = pa_dbus_wrap_connection_new(c->mainloop, type, error)))
 
74
        return NULL;
 
75
 
 
76
    return dbus_connection_new(c, conn, prop_name[type]);
 
77
}
 
78
 
 
79
DBusConnection* pa_dbus_connection_get(pa_dbus_connection *c){
 
80
    pa_assert(c);
 
81
    pa_assert(PA_REFCNT_VALUE(c) > 0);
 
82
    pa_assert(c->connection);
 
83
 
 
84
    return pa_dbus_wrap_connection_get(c->connection);
 
85
}
 
86
 
 
87
void pa_dbus_connection_unref(pa_dbus_connection *c) {
 
88
    pa_assert(c);
 
89
    pa_assert(PA_REFCNT_VALUE(c) > 0);
 
90
 
 
91
    if (PA_REFCNT_DEC(c) > 0)
 
92
        return;
 
93
 
 
94
    pa_dbus_wrap_connection_free(c->connection);
 
95
 
 
96
    pa_shared_remove(c->core, c->property_name);
 
97
    pa_xfree(c);
 
98
}
 
99
 
 
100
pa_dbus_connection* pa_dbus_connection_ref(pa_dbus_connection *c) {
 
101
    pa_assert(c);
 
102
    pa_assert(PA_REFCNT_VALUE(c) > 0);
 
103
 
 
104
    PA_REFCNT_INC(c);
 
105
 
 
106
    return c;
 
107
}