~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulsecore/namereg.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: namereg.c 1981 2007-10-29 20:01:49Z lennart $ */
2
 
 
3
1
/***
4
2
  This file is part of PulseAudio.
5
3
 
47
45
    void *data;
48
46
};
49
47
 
50
 
static int is_valid_char(char c) {
 
48
static pa_bool_t is_valid_char(char c) {
51
49
    return
52
50
        (c >= 'a' && c <= 'z') ||
53
51
        (c >= 'A' && c <= 'Z') ||
54
52
        (c >= '0' && c <= '9') ||
55
53
        c == '.' ||
 
54
        c == '-' ||
56
55
        c == '_';
57
56
}
58
57
 
72
71
    return TRUE;
73
72
}
74
73
 
75
 
static char* cleanup_name(const char *name) {
 
74
char* pa_namereg_make_valid_name(const char *name) {
76
75
    const char *a;
77
76
    char *b, *n;
78
77
 
79
78
    if (*name == 0)
80
79
        return NULL;
81
80
 
82
 
    n = pa_xnew(char, strlen(name)+1);
 
81
    n = pa_xmalloc(strlen(name)+1);
83
82
 
84
83
    for (a = name, b = n; *a && (a-name < PA_NAME_MAX); a++, b++)
85
 
        *b = is_valid_char(*a) ? *a : '_';
 
84
        *b = (char) (is_valid_char(*a) ? *a : '_');
86
85
 
87
86
    *b = 0;
88
87
 
99
98
    pa_hashmap_free(c->namereg, NULL, NULL);
100
99
}
101
100
 
102
 
const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, int fail) {
 
101
const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, pa_bool_t fail) {
103
102
    struct namereg_entry *e;
104
103
    char *n = NULL;
105
104
 
111
110
        return NULL;
112
111
 
113
112
    if ((type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE) &&
114
 
        !pa_namereg_is_valid_name(name) ) {
 
113
        !pa_namereg_is_valid_name(name)) {
115
114
 
116
115
        if (fail)
117
116
            return NULL;
118
117
 
119
 
        if (!(name = n = cleanup_name(name)))
 
118
        if (!(name = n = pa_namereg_make_valid_name(name)))
120
119
            return NULL;
121
120
    }
122
121
 
138
137
            return NULL;
139
138
        }
140
139
 
141
 
        k = pa_xnew(char, l+4);
 
140
        k = pa_xmalloc(l+4);
142
141
 
143
142
        for (i = 2; i <= 99; i++) {
144
143
            pa_snprintf(k, l+4, "%s.%u", name, i);
179
178
    pa_xfree(e);
180
179
}
181
180
 
182
 
void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type, int autoload) {
 
181
void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type, pa_bool_t autoload) {
183
182
    struct namereg_entry *e;
184
183
    uint32_t idx;
185
184
    pa_assert(c);