2004-11-21 18:15:33 +00:00
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-02-13 15:35:19 +00:00
|
|
|
Copyright 2004-2006 Lennart Poettering
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2004-11-21 18:15:33 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2009-03-03 20:23:02 +00:00
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
2004-11-21 18:15:33 +00:00
|
|
|
or (at your option) any later version.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2004-11-21 18:15:33 +00:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-21 18:15:33 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2006-06-19 21:53:48 +00:00
|
|
|
along with PulseAudio; if not, write to the Free Software
|
2004-11-21 18:15:33 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <sys/un.h>
|
2012-05-01 23:17:22 +02:00
|
|
|
#include <getopt.h>
|
2008-08-06 18:54:13 +02:00
|
|
|
#include <locale.h>
|
2004-11-21 18:15:33 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/util.h>
|
2008-05-15 23:34:41 +00:00
|
|
|
#include <pulse/xmalloc.h>
|
2006-05-18 07:04:41 +00:00
|
|
|
|
2011-08-10 10:30:15 +02:00
|
|
|
#include <pulsecore/i18n.h>
|
2009-11-23 00:12:18 +01:00
|
|
|
#include <pulsecore/poll.h>
|
2009-05-26 00:05:28 +02:00
|
|
|
#include <pulsecore/macro.h>
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/core-util.h>
|
|
|
|
|
#include <pulsecore/log.h>
|
|
|
|
|
#include <pulsecore/pid.h>
|
2004-11-21 18:15:33 +00:00
|
|
|
|
2012-05-01 23:17:22 +02:00
|
|
|
static void help(const char *argv0) {
|
|
|
|
|
printf("%s %s\n", argv0, "exit");
|
|
|
|
|
printf("%s %s\n", argv0, "help");
|
|
|
|
|
printf("%s %s\n", argv0, "list-(modules|sinks|sources|clients|cards|samples)");
|
|
|
|
|
printf("%s %s\n", argv0, "list-(sink-inputs|source-outputs)");
|
|
|
|
|
printf("%s %s\n", argv0, "stat");
|
|
|
|
|
printf("%s %s\n", argv0, "info");
|
|
|
|
|
printf("%s %s %s\n", argv0, "load-module", _("NAME [ARGS ...]"));
|
2012-05-30 14:27:26 +02:00
|
|
|
printf("%s %s %s\n", argv0, "unload-module", _("NAME|#N"));
|
2012-05-01 23:17:22 +02:00
|
|
|
printf("%s %s %s\n", argv0, "describe-module", _("NAME"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-(sink|source)-volume", _("NAME|#N VOLUME"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-(sink-input|source-output)-volume", _("#N VOLUME"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-(sink|source)-mute", _("NAME|#N 1|0"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-(sink-input|source-output)-mute", _("#N 1|0"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "update-(sink|source)-proplist", _("NAME|#N KEY=VALUE"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "update-(sink-input|source-output)-proplist", _("#N KEY=VALUE"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-default(sink|source)", _("NAME|#N"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "kill-(client|sink-input|source-output)", _("#N"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "play-sample", _("NAME SINK|#N"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "remove-sample", _("NAME"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "load-sample", _("NAME FILENAME"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "load-sample-lazy", _("NAME FILENAME"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "load-sample-dir-lazy", _("PATHNAME"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "play-file", _("FILENAME SINK|#N"));
|
|
|
|
|
printf("%s %s\n", argv0, "dump");
|
|
|
|
|
printf("%s %s %s\n", argv0, "move-(sink-input|source-output)", _("#N SINK|SOURCE"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "suspend-(sink|source)", _("NAME|#N 1|0"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "suspend", _("1|0"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-card-profile", _("CARD PROFILE"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-(sink|source)-port", _("NAME|#N PORT"));
|
2012-06-22 20:55:55 +02:00
|
|
|
printf("%s %s %s\n", argv0, "set-port-latency-offset", _("CARD-NAME|CARD-#N PORT OFFSET"));
|
2012-06-23 19:15:14 +08:00
|
|
|
printf("%s %s %s\n", argv0, "set-log-target", _("TARGET"));
|
2012-05-01 23:17:22 +02:00
|
|
|
printf("%s %s %s\n", argv0, "set-log-level", _("NUMERIC LEVEL"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-log-meta", _("1|0"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-log-time", _("1|0"));
|
|
|
|
|
printf("%s %s %s\n", argv0, "set-log-backtrace", _("FRAMES"));
|
|
|
|
|
|
|
|
|
|
printf(_("\n"
|
|
|
|
|
" -h, --help Show this help\n"
|
|
|
|
|
" --version Show version\n"
|
|
|
|
|
"When no command is given pacdm starts in the interactive mode\n" ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
ARG_VERSION = 256
|
|
|
|
|
};
|
|
|
|
|
|
2008-08-09 16:20:29 +02:00
|
|
|
int main(int argc, char*argv[]) {
|
2011-03-02 12:41:26 +01:00
|
|
|
pid_t pid;
|
2004-11-21 18:15:33 +00:00
|
|
|
int fd = -1;
|
|
|
|
|
int ret = 1, i;
|
|
|
|
|
struct sockaddr_un sa;
|
2011-11-14 12:07:12 +01:00
|
|
|
char *ibuf = NULL;
|
|
|
|
|
char *obuf = NULL;
|
2012-02-12 23:14:20 +05:30
|
|
|
size_t buf_size, ibuf_size, ibuf_index, ibuf_length, obuf_size, obuf_index, obuf_length;
|
2008-05-15 23:34:41 +00:00
|
|
|
char *cli;
|
2009-02-04 21:22:18 +01:00
|
|
|
pa_bool_t ibuf_eof, obuf_eof, ibuf_closed, obuf_closed;
|
2010-02-18 03:28:56 +01:00
|
|
|
struct pollfd pollfd[3];
|
|
|
|
|
struct pollfd *watch_socket, *watch_stdin, *watch_stdout;
|
|
|
|
|
|
2010-02-18 02:32:35 +01:00
|
|
|
int stdin_type = 0, stdout_type = 0, fd_type = 0;
|
2004-11-21 18:15:33 +00:00
|
|
|
|
2012-05-01 23:17:22 +02:00
|
|
|
char *bn = NULL;
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
static const struct option long_options[] = {
|
|
|
|
|
{"version", 0, NULL, ARG_VERSION},
|
|
|
|
|
{"help", 0, NULL, 'h'},
|
|
|
|
|
{NULL, 0, NULL, 0}
|
|
|
|
|
};
|
|
|
|
|
|
2008-08-06 18:54:13 +02:00
|
|
|
setlocale(LC_ALL, "");
|
2011-12-09 21:00:11 +05:30
|
|
|
#ifdef ENABLE_NLS
|
2008-08-06 18:54:13 +02:00
|
|
|
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
|
2011-12-09 21:00:11 +05:30
|
|
|
#endif
|
2008-08-06 18:54:13 +02:00
|
|
|
|
2012-05-01 23:17:22 +02:00
|
|
|
bn = pa_path_get_filename(argv[0]);
|
|
|
|
|
|
|
|
|
|
while ((c = getopt_long(argc, argv, "h", long_options, NULL)) != -1) {
|
|
|
|
|
switch (c) {
|
|
|
|
|
case 'h' :
|
|
|
|
|
help(bn);
|
|
|
|
|
ret = 0;
|
|
|
|
|
goto quit;
|
|
|
|
|
case ARG_VERSION:
|
|
|
|
|
printf(_("pacmd %s\n"
|
|
|
|
|
"Compiled with libpulse %s\n"
|
|
|
|
|
"Linked with libpulse %s\n"),
|
|
|
|
|
PACKAGE_VERSION,
|
|
|
|
|
pa_get_headers_version(),
|
|
|
|
|
pa_get_library_version());
|
|
|
|
|
ret = 0;
|
|
|
|
|
goto quit;
|
|
|
|
|
default:
|
|
|
|
|
goto quit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 01:30:40 +00:00
|
|
|
if (pa_pid_file_check_running(&pid, "pulseaudio") < 0) {
|
2009-05-26 00:05:28 +02:00
|
|
|
pa_log(_("No PulseAudio daemon running, or not running as session daemon."));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
2009-10-30 03:32:38 +01:00
|
|
|
if ((fd = pa_socket_cloexec(PF_UNIX, SOCK_STREAM, 0)) < 0) {
|
2008-08-06 18:54:13 +02:00
|
|
|
pa_log(_("socket(PF_UNIX, SOCK_STREAM, 0): %s"), strerror(errno));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
2009-05-26 00:05:28 +02:00
|
|
|
pa_zero(sa);
|
2004-11-21 18:15:33 +00:00
|
|
|
sa.sun_family = AF_UNIX;
|
2008-05-15 23:34:41 +00:00
|
|
|
|
2008-05-21 22:43:22 +00:00
|
|
|
if (!(cli = pa_runtime_path("cli")))
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2008-05-21 22:43:22 +00:00
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strlcpy(sa.sun_path, cli, sizeof(sa.sun_path));
|
|
|
|
|
pa_xfree(cli);
|
2004-11-21 18:15:33 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
|
int r;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-21 18:15:33 +00:00
|
|
|
if ((r = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 && (errno != ECONNREFUSED && errno != ENOENT)) {
|
2008-08-06 18:54:13 +02:00
|
|
|
pa_log(_("connect(): %s"), strerror(errno));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2012-05-01 23:17:22 +02:00
|
|
|
|
2004-11-21 18:15:33 +00:00
|
|
|
if (r >= 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2007-11-21 01:30:40 +00:00
|
|
|
if (pa_pid_file_kill(SIGUSR2, NULL, "pulseaudio") < 0) {
|
2008-08-06 18:54:13 +02:00
|
|
|
pa_log(_("Failed to kill PulseAudio daemon."));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
2007-11-13 19:21:15 +00:00
|
|
|
pa_msleep(300);
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i >= 5) {
|
2008-08-06 18:54:13 +02:00
|
|
|
pa_log(_("Daemon not responding."));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-12 23:14:20 +05:30
|
|
|
buf_size = pa_pipe_buf(fd);
|
|
|
|
|
ibuf_size = PA_MIN(buf_size, pa_pipe_buf(STDIN_FILENO));
|
2011-11-14 12:07:12 +01:00
|
|
|
ibuf = pa_xmalloc(ibuf_size);
|
2012-02-12 23:14:20 +05:30
|
|
|
obuf_size = PA_MIN(buf_size, pa_pipe_buf(STDOUT_FILENO));
|
2011-11-14 12:07:12 +01:00
|
|
|
obuf = pa_xmalloc(obuf_size);
|
2004-11-21 18:15:33 +00:00
|
|
|
ibuf_index = ibuf_length = obuf_index = obuf_length = 0;
|
2009-02-04 21:22:18 +01:00
|
|
|
ibuf_eof = obuf_eof = ibuf_closed = obuf_closed = FALSE;
|
2004-11-21 18:15:33 +00:00
|
|
|
|
2009-02-04 21:22:18 +01:00
|
|
|
if (argc > 1) {
|
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
|
size_t k;
|
2004-11-21 18:15:33 +00:00
|
|
|
|
2011-11-14 12:07:12 +01:00
|
|
|
k = PA_MIN(ibuf_size - ibuf_length, strlen(argv[i]));
|
2009-08-14 04:12:36 +02:00
|
|
|
memcpy(ibuf + ibuf_length, argv[i], k);
|
2009-02-04 21:22:18 +01:00
|
|
|
ibuf_length += k;
|
2004-11-21 18:15:33 +00:00
|
|
|
|
2011-11-14 12:07:12 +01:00
|
|
|
if (ibuf_length < ibuf_size) {
|
2009-02-04 21:22:18 +01:00
|
|
|
ibuf[ibuf_length] = i < argc-1 ? ' ' : '\n';
|
|
|
|
|
ibuf_length++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ibuf_eof = TRUE;
|
|
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2009-08-12 21:42:02 +02:00
|
|
|
for (;;) {
|
2010-02-18 03:28:56 +01:00
|
|
|
struct pollfd *p;
|
|
|
|
|
|
2009-02-04 21:22:18 +01:00
|
|
|
if (ibuf_eof &&
|
|
|
|
|
obuf_eof &&
|
|
|
|
|
ibuf_length <= 0 &&
|
|
|
|
|
obuf_length <= 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (ibuf_length <= 0 && ibuf_eof && !ibuf_closed) {
|
|
|
|
|
shutdown(fd, SHUT_WR);
|
|
|
|
|
ibuf_closed = TRUE;
|
|
|
|
|
}
|
2009-02-04 21:22:18 +01:00
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (obuf_length <= 0 && obuf_eof && !obuf_closed) {
|
|
|
|
|
shutdown(fd, SHUT_RD);
|
|
|
|
|
obuf_closed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pa_zero(pollfd);
|
|
|
|
|
|
|
|
|
|
p = pollfd;
|
2009-02-04 21:22:18 +01:00
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (ibuf_length > 0 || (!obuf_eof && obuf_length <= 0)) {
|
|
|
|
|
watch_socket = p++;
|
|
|
|
|
watch_socket->fd = fd;
|
|
|
|
|
watch_socket->events =
|
|
|
|
|
(ibuf_length > 0 ? POLLOUT : 0) |
|
|
|
|
|
(!obuf_eof && obuf_length <= 0 ? POLLIN : 0);
|
|
|
|
|
} else
|
|
|
|
|
watch_socket = NULL;
|
2009-02-04 21:22:18 +01:00
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (!ibuf_eof && ibuf_length <= 0) {
|
|
|
|
|
watch_stdin = p++;
|
|
|
|
|
watch_stdin->fd = STDIN_FILENO;
|
|
|
|
|
watch_stdin->events = POLLIN;
|
|
|
|
|
} else
|
|
|
|
|
watch_stdin = NULL;
|
|
|
|
|
|
|
|
|
|
if (obuf_length > 0) {
|
|
|
|
|
watch_stdout = p++;
|
|
|
|
|
watch_stdout->fd = STDOUT_FILENO;
|
|
|
|
|
watch_stdout->events = POLLOUT;
|
|
|
|
|
} else
|
|
|
|
|
watch_stdout = NULL;
|
|
|
|
|
|
|
|
|
|
if (pa_poll(pollfd, p-pollfd, -1) < 0) {
|
2009-08-12 21:42:02 +02:00
|
|
|
|
|
|
|
|
if (errno == EINTR)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
pa_log(_("poll(): %s"), strerror(errno));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (watch_stdin) {
|
|
|
|
|
if (watch_stdin->revents & POLLIN) {
|
|
|
|
|
ssize_t r;
|
|
|
|
|
pa_assert(ibuf_length <= 0);
|
|
|
|
|
|
2011-11-14 12:07:12 +01:00
|
|
|
if ((r = pa_read(STDIN_FILENO, ibuf, ibuf_size, &stdin_type)) <= 0) {
|
2010-02-18 03:28:56 +01:00
|
|
|
if (r < 0) {
|
|
|
|
|
pa_log(_("read(): %s"), strerror(errno));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2010-02-18 03:28:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ibuf_eof = TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
ibuf_length = (size_t) r;
|
|
|
|
|
ibuf_index = 0;
|
2009-02-04 21:22:18 +01:00
|
|
|
}
|
2010-02-18 03:28:56 +01:00
|
|
|
} else if (watch_stdin->revents & POLLHUP)
|
2009-02-04 21:22:18 +01:00
|
|
|
ibuf_eof = TRUE;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (watch_socket) {
|
|
|
|
|
if (watch_socket->revents & POLLIN) {
|
|
|
|
|
ssize_t r;
|
|
|
|
|
pa_assert(obuf_length <= 0);
|
|
|
|
|
|
2011-11-14 12:07:12 +01:00
|
|
|
if ((r = pa_read(fd, obuf, obuf_size, &fd_type)) <= 0) {
|
2010-02-18 03:28:56 +01:00
|
|
|
if (r < 0) {
|
|
|
|
|
pa_log(_("read(): %s"), strerror(errno));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2010-02-18 03:28:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obuf_eof = TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
obuf_length = (size_t) r;
|
|
|
|
|
obuf_index = 0;
|
2009-02-04 21:22:18 +01:00
|
|
|
}
|
2010-02-18 03:28:56 +01:00
|
|
|
} else if (watch_socket->revents & POLLHUP)
|
2009-02-04 21:22:18 +01:00
|
|
|
obuf_eof = TRUE;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (watch_stdout) {
|
|
|
|
|
if (watch_stdout->revents & POLLHUP) {
|
|
|
|
|
obuf_eof = TRUE;
|
|
|
|
|
obuf_length = 0;
|
|
|
|
|
} else if (watch_stdout->revents & POLLOUT) {
|
|
|
|
|
ssize_t r;
|
|
|
|
|
pa_assert(obuf_length > 0);
|
2004-11-21 18:15:33 +00:00
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if ((r = pa_write(STDOUT_FILENO, obuf + obuf_index, obuf_length, &stdout_type)) < 0) {
|
|
|
|
|
pa_log(_("write(): %s"), strerror(errno));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2010-02-18 03:28:56 +01:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
obuf_length -= (size_t) r;
|
|
|
|
|
obuf_index += obuf_index;
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if (watch_socket) {
|
|
|
|
|
if (watch_socket->revents & POLLHUP) {
|
|
|
|
|
ibuf_eof = TRUE;
|
|
|
|
|
ibuf_length = 0;
|
|
|
|
|
} if (watch_socket->revents & POLLOUT) {
|
|
|
|
|
ssize_t r;
|
|
|
|
|
pa_assert(ibuf_length > 0);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2010-02-18 03:28:56 +01:00
|
|
|
if ((r = pa_write(fd, ibuf + ibuf_index, ibuf_length, &fd_type)) < 0) {
|
|
|
|
|
pa_log(_("write(): %s"), strerror(errno));
|
2012-05-01 23:17:22 +02:00
|
|
|
goto quit;
|
2010-02-18 03:28:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ibuf_length -= (size_t) r;
|
|
|
|
|
ibuf_index += obuf_index;
|
|
|
|
|
}
|
2009-02-04 21:22:18 +01:00
|
|
|
}
|
2004-11-21 18:15:33 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-21 18:15:33 +00:00
|
|
|
ret = 0;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2012-05-01 23:17:22 +02:00
|
|
|
quit:
|
2004-11-21 18:15:33 +00:00
|
|
|
if (fd >= 0)
|
2009-02-04 21:22:18 +01:00
|
|
|
pa_close(fd);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2011-11-14 12:07:12 +01:00
|
|
|
pa_xfree(obuf);
|
|
|
|
|
pa_xfree(ibuf);
|
|
|
|
|
|
2004-11-21 18:15:33 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|