~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulsecore/props.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-11-04 15:46:00 UTC
  • mfrom: (1.2.1 upstream) (1.1.6 lenny)
  • Revision ID: james.westby@ubuntu.com-20081104154600-hlzknpcazaam0nxm
Tags: 0.9.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Don't build against, and create jack package. Jack is not in main.
  - Remove --disable-per-user-esound-socket from configure flags, as we still
    want per user esound sockets.
  - Remove stop links from rc0 and rc6.
  - Change default resample algorithm and bubffer size.
  - Add alsa configuration files to route alsa applications via pulseaudio.
  - Move libasound2-plugins from Recommends to Depends.
* debian/pulseaudio.preinst: When upgrading from intrepid, remove
  /etc/X11/Xsession.d/70pulseaudio, as this was used to minimize a race
  condition when starting GNOME in intrepid. This race should not exist in
  jaunty once libcanberra is built to use pulseaudio as a backend.
* Do not spawn a pulseaudio server if clients fail to find a running server.
* Remove explicit version dependency for libspeex-dev to allow the package
  to be built for now.
* Regenerate autotools files to work with Ubuntu's newer libtool/libltdl.
* debian/control: libpulsecore5 -> libpulsecore8 to match the library
  soname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: props.c 1971 2007-10-28 19:13:50Z lennart $ */
2
 
 
3
 
/***
4
 
  This file is part of PulseAudio.
5
 
 
6
 
  Copyright 2004-2006 Lennart Poettering
7
 
 
8
 
  PulseAudio is free software; you can redistribute it and/or modify
9
 
  it under the terms of the GNU Lesser General Public License as published
10
 
  by the Free Software Foundation; either version 2 of the License,
11
 
  or (at your option) any later version.
12
 
 
13
 
  PulseAudio is distributed in the hope that it will be useful, but
14
 
  WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
 
  General Public License for more details.
17
 
 
18
 
  You should have received a copy of the GNU Lesser General Public License
19
 
  along with PulseAudio; if not, write to the Free Software
20
 
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21
 
  USA.
22
 
***/
23
 
 
24
 
#ifdef HAVE_CONFIG_H
25
 
#include <config.h>
26
 
#endif
27
 
 
28
 
#include <pulse/xmalloc.h>
29
 
#include <pulsecore/log.h>
30
 
#include <pulsecore/macro.h>
31
 
 
32
 
#include "props.h"
33
 
 
34
 
typedef struct pa_property {
35
 
    char *name;  /* Points to memory allocated by the property subsystem */
36
 
    void *data;  /* Points to memory maintained by the caller */
37
 
} pa_property;
38
 
 
39
 
/* Allocate a new property object */
40
 
static pa_property* property_new(const char *name, void *data) {
41
 
    pa_property* p;
42
 
 
43
 
    pa_assert(name);
44
 
    pa_assert(data);
45
 
 
46
 
    p = pa_xnew(pa_property, 1);
47
 
    p->name = pa_xstrdup(name);
48
 
    p->data = data;
49
 
 
50
 
    return p;
51
 
}
52
 
 
53
 
/* Free a property object */
54
 
static void property_free(pa_property *p) {
55
 
    pa_assert(p);
56
 
 
57
 
    pa_xfree(p->name);
58
 
    pa_xfree(p);
59
 
}
60
 
 
61
 
void* pa_property_get(pa_core *c, const char *name) {
62
 
    pa_property *p;
63
 
 
64
 
    pa_assert(c);
65
 
    pa_assert(name);
66
 
    pa_assert(c->properties);
67
 
 
68
 
    if (!(p = pa_hashmap_get(c->properties, name)))
69
 
        return NULL;
70
 
 
71
 
    return p->data;
72
 
}
73
 
 
74
 
int pa_property_set(pa_core *c, const char *name, void *data) {
75
 
    pa_property *p;
76
 
 
77
 
    pa_assert(c);
78
 
    pa_assert(name);
79
 
    pa_assert(data);
80
 
    pa_assert(c->properties);
81
 
 
82
 
    if (pa_hashmap_get(c->properties, name))
83
 
        return -1;
84
 
 
85
 
    p = property_new(name, data);
86
 
    pa_hashmap_put(c->properties, p->name, p);
87
 
    return 0;
88
 
}
89
 
 
90
 
int pa_property_remove(pa_core *c, const char *name) {
91
 
    pa_property *p;
92
 
 
93
 
    pa_assert(c);
94
 
    pa_assert(name);
95
 
    pa_assert(c->properties);
96
 
 
97
 
    if (!(p = pa_hashmap_remove(c->properties, name)))
98
 
        return -1;
99
 
 
100
 
    property_free(p);
101
 
    return 0;
102
 
}
103
 
 
104
 
void pa_property_init(pa_core *c) {
105
 
    pa_assert(c);
106
 
 
107
 
    c->properties = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
108
 
}
109
 
 
110
 
void pa_property_cleanup(pa_core *c) {
111
 
    pa_assert(c);
112
 
 
113
 
    if (!c->properties)
114
 
        return;
115
 
 
116
 
    pa_assert(!pa_hashmap_size(c->properties));
117
 
 
118
 
    pa_hashmap_free(c->properties, NULL, NULL);
119
 
    c->properties = NULL;
120
 
 
121
 
}
122
 
 
123
 
void pa_property_dump(pa_core *c, pa_strbuf *s) {
124
 
    void *state = NULL;
125
 
    pa_property *p;
126
 
 
127
 
    pa_assert(c);
128
 
    pa_assert(s);
129
 
 
130
 
    while ((p = pa_hashmap_iterate(c->properties, &state, NULL)))
131
 
        pa_strbuf_printf(s, "[%s] -> [%p]\n", p->name, p->data);
132
 
}
133
 
 
134
 
int pa_property_replace(pa_core *c, const char *name, void *data) {
135
 
    pa_assert(c);
136
 
    pa_assert(name);
137
 
 
138
 
    pa_property_remove(c, name);
139
 
    return pa_property_set(c, name, data);
140
 
}