return buf;
}
+static int connect_audiod(const char *sname, char *args)
+{
+ int fd = -1, ret;
+
+ ret = connect_local_socket(sname);
+ if (ret < 0)
+ goto fail;
+ fd = ret;
+ ret = send_cred_buffer(fd, args);
+ if (ret < 0)
+ goto fail;
+ return fd;
+fail:
+ PARA_ERROR_LOG("could not connect %s\n", sname);
+ if (fd >= 0)
+ close(fd);
+ return ret;
+}
+
#ifdef HAVE_READLINE
#include "list.h"
#include "sched.h"
args = concat_args(conf.inputs_num, conf.inputs);
free_argv(conf.inputs);
conf.inputs_num = 0; /* required for audioc_cmdline_parser_free() */
- ret = connect_local_socket(socket_name);
+ ret = connect_audiod(socket_name, args);
if (ret < 0)
goto out;
at->fd = ret;
ret = mark_fd_nonblocking(at->fd);
- if (ret < 0)
- goto close;
- ret = send_cred_buffer(at->fd, args);
if (ret < 0)
goto close;
free(args);
interactive_session();
args = concat_args(conf.inputs_num, conf.inputs);
- ret = connect_local_socket(socket_name);
+ ret = connect_audiod(socket_name, args);
free(socket_name);
- if (ret < 0) {
- PARA_EMERG_LOG("failed to connect to local socket\n");
+ if (ret < 0)
goto out;
- }
fd = ret;
- ret = send_cred_buffer(fd, args);
+ ret = mark_fd_blocking(STDOUT_FILENO);
if (ret < 0)
goto out;
bufsize = conf.bufsize_arg;
buf = para_malloc(bufsize);
- ret = mark_fd_blocking(STDOUT_FILENO);
- if (ret < 0)
- goto out;
do {
size_t n = ret = recv_bin_buffer(fd, buf, bufsize);
if (ret <= 0)