34
32
#include <string.h>
35
33
#include <sys/un.h>
37
36
#include <pulse/error.h>
38
37
#include <pulse/util.h>
38
#include <pulse/xmalloc.h>
39
#include <pulse/i18n.h>
40
41
#include <pulsecore/core-util.h>
41
42
#include <pulsecore/log.h>
42
43
#include <pulsecore/pid.h>
44
int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) {
45
int main(int argc, char*argv[]) {
49
50
char ibuf[256], obuf[256];
50
51
size_t ibuf_index, ibuf_length, obuf_index, obuf_length;
55
setlocale(LC_ALL, "");
56
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
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");
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));
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));
71
if (!(cli = pa_runtime_path("cli")))
74
pa_strlcpy(sa.sun_path, cli, sizeof(sa.sun_path));
67
77
for (i = 0; i < 5; i++) {
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));
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));
140
150
assert(obuf_length);
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));
154
164
assert(ibuf_length);
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));