~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/utils/pacmd.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: pacmd.c 2067 2007-11-21 01:30:40Z lennart $ */
2
 
 
3
1
/***
4
2
  This file is part of PulseAudio.
5
3
 
33
31
#include <errno.h>
34
32
#include <string.h>
35
33
#include <sys/un.h>
 
34
#include <locale.h>
36
35
 
37
36
#include <pulse/error.h>
38
37
#include <pulse/util.h>
 
38
#include <pulse/xmalloc.h>
 
39
#include <pulse/i18n.h>
39
40
 
40
41
#include <pulsecore/core-util.h>
41
42
#include <pulsecore/log.h>
42
43
#include <pulsecore/pid.h>
43
44
 
44
 
int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
 
45
int main(int argc, char*argv[]) {
45
46
    pid_t pid ;
46
47
    int fd = -1;
47
48
    int ret = 1, i;
49
50
    char ibuf[256], obuf[256];
50
51
    size_t ibuf_index, ibuf_length, obuf_index, obuf_length;
51
52
    fd_set ifds, ofds;
 
53
    char *cli;
 
54
 
 
55
    setlocale(LC_ALL, "");
 
56
    bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
52
57
 
53
58
    if (pa_pid_file_check_running(&pid, "pulseaudio") < 0) {
54
 
        pa_log("no PulseAudio daemon running");
 
59
        pa_log("No PulseAudio daemon running");
55
60
        goto fail;
56
61
    }
57
62
 
58
63
    if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
59
 
        pa_log("socket(PF_UNIX, SOCK_STREAM, 0): %s", strerror(errno));
 
64
        pa_log(_("socket(PF_UNIX, SOCK_STREAM, 0): %s"), strerror(errno));
60
65
        goto fail;
61
66
    }
62
67
 
63
68
    memset(&sa, 0, sizeof(sa));
64
69
    sa.sun_family = AF_UNIX;
65
 
    pa_runtime_path("cli", sa.sun_path, sizeof(sa.sun_path));
 
70
 
 
71
    if (!(cli = pa_runtime_path("cli")))
 
72
        goto fail;
 
73
 
 
74
    pa_strlcpy(sa.sun_path, cli, sizeof(sa.sun_path));
 
75
    pa_xfree(cli);
66
76
 
67
77
    for (i = 0; i < 5; i++) {
68
78
        int r;
69
79
 
70
80
        if ((r = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 && (errno != ECONNREFUSED && errno != ENOENT)) {
71
 
            pa_log("connect(): %s", strerror(errno));
 
81
            pa_log(_("connect(): %s"), strerror(errno));
72
82
            goto fail;
73
83
        }
74
84
 
76
86
            break;
77
87
 
78
88
        if (pa_pid_file_kill(SIGUSR2, NULL, "pulseaudio") < 0) {
79
 
            pa_log("failed to kill PulseAudio daemon.");
 
89
            pa_log(_("Failed to kill PulseAudio daemon."));
80
90
            goto fail;
81
91
        }
82
92
 
84
94
    }
85
95
 
86
96
    if (i >= 5) {
87
 
        pa_log("daemon not responding.");
 
97
        pa_log(_("Daemon not responding."));
88
98
        goto fail;
89
99
    }
90
100
 
99
109
 
100
110
    for (;;) {
101
111
        if (select(FD_SETSIZE, &ifds, &ofds, NULL, NULL) < 0) {
102
 
            pa_log("select(): %s", strerror(errno));
 
112
            pa_log(_("select(): %s"), strerror(errno));
103
113
            goto fail;
104
114
        }
105
115
 
111
121
                if (r == 0)
112
122
                    break;
113
123
 
114
 
                pa_log("read(): %s", strerror(errno));
 
124
                pa_log(_("read(): %s"), strerror(errno));
115
125
                goto fail;
116
126
            }
117
127
 
127
137
                if (r == 0)
128
138
                    break;
129
139
 
130
 
                pa_log("read(): %s", strerror(errno));
 
140
                pa_log(_("read(): %s"), strerror(errno));
131
141
                goto fail;
132
142
            }
133
143
 
140
150
            assert(obuf_length);
141
151
 
142
152
            if ((r = write(1, obuf + obuf_index, obuf_length)) < 0) {
143
 
                pa_log("write(): %s", strerror(errno));
 
153
                pa_log(_("write(): %s"), strerror(errno));
144
154
                goto fail;
145
155
            }
146
156
 
154
164
            assert(ibuf_length);
155
165
 
156
166
            if ((r = write(fd, ibuf + ibuf_index, ibuf_length)) < 0) {
157
 
                pa_log("write(): %s", strerror(errno));
 
167
                pa_log(_("write(): %s"), strerror(errno));
158
168
                goto fail;
159
169
            }
160
170
 
177
187
            FD_SET(fd, &ofds);
178
188
    }
179
189
 
180
 
 
181
190
    ret = 0;
182
191
 
183
192
fail: