2004-07-16 19:56:36 +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-14 14:58:54 +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-07-16 19:56:36 +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-07-16 19:56:36 +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-14 14:58:54 +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-07-16 19:56:36 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
2004-07-16 19:16:42 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <limits.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <poll.h>
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2009-11-20 21:25:33 +01:00
|
|
|
#ifdef HAVE_SYS_FILIO_H
|
|
|
|
|
#include <sys/filio.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/xmalloc.h>
|
2006-05-17 16:34:18 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/core-error.h>
|
|
|
|
|
#include <pulsecore/sink.h>
|
|
|
|
|
#include <pulsecore/module.h>
|
|
|
|
|
#include <pulsecore/core-util.h>
|
|
|
|
|
#include <pulsecore/modargs.h>
|
|
|
|
|
#include <pulsecore/log.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <pulsecore/thread.h>
|
|
|
|
|
#include <pulsecore/thread-mq.h>
|
|
|
|
|
#include <pulsecore/rtpoll.h>
|
2006-02-16 19:19:58 +00:00
|
|
|
|
2004-10-30 01:55:16 +00:00
|
|
|
#include "module-pipe-sink-symdef.h"
|
2004-07-11 16:59:22 +00:00
|
|
|
|
2007-11-09 18:25:40 +00:00
|
|
|
PA_MODULE_AUTHOR("Lennart Poettering");
|
|
|
|
|
PA_MODULE_DESCRIPTION("UNIX pipe sink");
|
|
|
|
|
PA_MODULE_VERSION(PACKAGE_VERSION);
|
|
|
|
|
PA_MODULE_LOAD_ONCE(FALSE);
|
2006-04-26 15:40:14 +00:00
|
|
|
PA_MODULE_USAGE(
|
|
|
|
|
"sink_name=<name for the sink> "
|
2009-05-28 02:39:22 +02:00
|
|
|
"sink_properties=<properties for the sink> "
|
2006-04-26 15:40:14 +00:00
|
|
|
"file=<path of the FIFO> "
|
|
|
|
|
"format=<sample format> "
|
|
|
|
|
"rate=<sample rate>"
|
2009-05-28 02:39:22 +02:00
|
|
|
"channels=<number of channels> "
|
2007-11-09 18:25:40 +00:00
|
|
|
"channel_map=<channel map>");
|
2004-09-11 23:17:38 +00:00
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
#define DEFAULT_FILE_NAME "fifo_output"
|
2004-07-11 16:59:22 +00:00
|
|
|
#define DEFAULT_SINK_NAME "fifo_output"
|
2004-06-08 23:54:24 +00:00
|
|
|
|
|
|
|
|
struct userdata {
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_core *core;
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_module *module;
|
|
|
|
|
pa_sink *sink;
|
2004-07-11 16:59:22 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_thread *thread;
|
|
|
|
|
pa_thread_mq thread_mq;
|
|
|
|
|
pa_rtpoll *rtpoll;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
char *filename;
|
|
|
|
|
int fd;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_memchunk memchunk;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_rtpoll_item *rtpoll_item;
|
2008-05-15 23:34:41 +00:00
|
|
|
|
|
|
|
|
int write_type;
|
2004-06-08 23:54:24 +00:00
|
|
|
};
|
|
|
|
|
|
2004-07-11 16:59:22 +00:00
|
|
|
static const char* const valid_modargs[] = {
|
2009-05-28 02:39:22 +02:00
|
|
|
"sink_name",
|
|
|
|
|
"sink_properties",
|
2004-07-11 16:59:22 +00:00
|
|
|
"file",
|
|
|
|
|
"format",
|
2009-05-28 02:39:22 +02:00
|
|
|
"rate",
|
2004-09-20 17:19:35 +00:00
|
|
|
"channels",
|
2006-04-26 15:40:14 +00:00
|
|
|
"channel_map",
|
2004-07-11 16:59:22 +00:00
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
|
|
|
|
struct userdata *u = PA_SINK(o)->userdata;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
switch (code) {
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
case PA_SINK_MESSAGE_GET_LATENCY: {
|
|
|
|
|
size_t n = 0;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2008-12-21 13:33:32 +01:00
|
|
|
#ifdef FIONREAD
|
2009-11-20 21:24:46 +01:00
|
|
|
int l;
|
|
|
|
|
|
2008-12-21 13:33:32 +01:00
|
|
|
if (ioctl(u->fd, FIONREAD, &l) >= 0 && l > 0)
|
2007-10-28 19:13:50 +00:00
|
|
|
n = (size_t) l;
|
|
|
|
|
#endif
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
n += u->memchunk.length;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
*((pa_usec_t*) data) = pa_bytes_to_usec(n, &u->sink->sample_spec);
|
2008-05-15 23:34:41 +00:00
|
|
|
return 0;
|
2007-10-28 19:13:50 +00:00
|
|
|
}
|
2004-06-08 23:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
return pa_sink_process_msg(o, code, data, offset, chunk);
|
2004-06-08 23:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
static int process_render(struct userdata *u) {
|
|
|
|
|
pa_assert(u);
|
|
|
|
|
|
|
|
|
|
if (u->memchunk.length <= 0)
|
2009-08-01 01:59:58 +02:00
|
|
|
pa_sink_render(u->sink, pa_pipe_buf(u->fd), &u->memchunk);
|
2008-05-15 23:34:41 +00:00
|
|
|
|
|
|
|
|
pa_assert(u->memchunk.length > 0);
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
|
ssize_t l;
|
|
|
|
|
void *p;
|
|
|
|
|
|
|
|
|
|
p = pa_memblock_acquire(u->memchunk.memblock);
|
|
|
|
|
l = pa_write(u->fd, (uint8_t*) p + u->memchunk.index, u->memchunk.length, &u->write_type);
|
|
|
|
|
pa_memblock_release(u->memchunk.memblock);
|
|
|
|
|
|
|
|
|
|
pa_assert(l != 0);
|
|
|
|
|
|
|
|
|
|
if (l < 0) {
|
|
|
|
|
|
|
|
|
|
if (errno == EINTR)
|
|
|
|
|
continue;
|
2009-02-02 01:53:11 +01:00
|
|
|
else if (errno == EAGAIN)
|
|
|
|
|
return 0;
|
|
|
|
|
else {
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2008-08-19 22:39:54 +02:00
|
|
|
u->memchunk.index += (size_t) l;
|
|
|
|
|
u->memchunk.length -= (size_t) l;
|
2008-05-15 23:34:41 +00:00
|
|
|
|
|
|
|
|
if (u->memchunk.length <= 0) {
|
|
|
|
|
pa_memblock_unref(u->memchunk.memblock);
|
|
|
|
|
pa_memchunk_reset(&u->memchunk);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
static void thread_func(void *userdata) {
|
|
|
|
|
struct userdata *u = userdata;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(u);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log_debug("Thread starting up");
|
2004-11-14 02:36:35 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_thread_mq_install(&u->thread_mq);
|
2004-11-14 02:36:35 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
for (;;) {
|
|
|
|
|
struct pollfd *pollfd;
|
|
|
|
|
int ret;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
|
|
|
|
|
|
|
|
|
|
/* Render some data and write it to the fifo */
|
2008-06-27 21:58:39 +02:00
|
|
|
if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
|
2007-10-28 19:13:50 +00:00
|
|
|
|
2008-06-27 21:58:39 +02:00
|
|
|
if (u->sink->thread_info.rewind_requested)
|
|
|
|
|
pa_sink_process_rewind(u->sink, 0);
|
2007-10-28 19:13:50 +00:00
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
if (pollfd->revents) {
|
|
|
|
|
if (process_render(u) < 0)
|
2007-10-28 19:13:50 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
pollfd->revents = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Hmm, nothing to do. Let's sleep */
|
2008-08-19 22:39:54 +02:00
|
|
|
pollfd->events = (short) (u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0);
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
|
goto finish;
|
|
|
|
|
|
|
|
|
|
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
|
|
|
|
|
|
|
|
|
|
if (pollfd->revents & ~POLLOUT) {
|
|
|
|
|
pa_log("FIFO shutdown.");
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fail:
|
|
|
|
|
/* If this was no regular exit from the loop we have to continue
|
|
|
|
|
* processing messages until we received PA_MESSAGE_SHUTDOWN */
|
|
|
|
|
pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
|
|
|
|
|
pa_asyncmsgq_wait_for(u->thread_mq.inq, PA_MESSAGE_SHUTDOWN);
|
|
|
|
|
|
|
|
|
|
finish:
|
|
|
|
|
pa_log_debug("Thread shutting down");
|
2004-06-08 23:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
int pa__init(pa_module*m) {
|
|
|
|
|
struct userdata *u;
|
2004-06-08 23:54:24 +00:00
|
|
|
struct stat st;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_sample_spec ss;
|
2006-04-26 15:40:14 +00:00
|
|
|
pa_channel_map map;
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_modargs *ma;
|
|
|
|
|
struct pollfd *pollfd;
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_sink_new_data data;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(m);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-07-11 16:59:22 +00:00
|
|
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log("Failed to parse module arguments.");
|
2004-07-11 16:59:22 +00:00
|
|
|
goto fail;
|
|
|
|
|
}
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
ss = m->core->default_sample_spec;
|
2009-02-21 16:32:42 +01:00
|
|
|
map = m->core->default_channel_map;
|
2006-05-16 23:47:38 +00:00
|
|
|
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log("Invalid sample format specification or channel map");
|
2004-07-11 16:59:22 +00:00
|
|
|
goto fail;
|
|
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
u = pa_xnew0(struct userdata, 1);
|
|
|
|
|
u->core = m->core;
|
|
|
|
|
u->module = m;
|
|
|
|
|
m->userdata = u;
|
|
|
|
|
pa_memchunk_reset(&u->memchunk);
|
|
|
|
|
u->rtpoll = pa_rtpoll_new();
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
|
|
|
|
|
u->write_type = 0;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
u->filename = pa_runtime_path(pa_modargs_get_value(ma, "file", DEFAULT_FILE_NAME));
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
mkfifo(u->filename, 0666);
|
2009-10-30 03:32:38 +01:00
|
|
|
if ((u->fd = pa_open_cloexec(u->filename, O_RDWR, 0)) < 0) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log("open('%s'): %s", u->filename, pa_cstrerror(errno));
|
2004-06-08 23:54:24 +00:00
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_make_fd_nonblock(u->fd);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if (fstat(u->fd, &st) < 0) {
|
|
|
|
|
pa_log("fstat('%s'): %s", u->filename, pa_cstrerror(errno));
|
2004-06-08 23:54:24 +00:00
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!S_ISFIFO(st.st_mode)) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log("'%s' is not a FIFO.", u->filename);
|
2004-06-08 23:54:24 +00:00
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_sink_new_data_init(&data);
|
|
|
|
|
data.driver = __FILE__;
|
|
|
|
|
data.module = m;
|
|
|
|
|
pa_sink_new_data_set_name(&data, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME));
|
|
|
|
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->filename);
|
|
|
|
|
pa_proplist_setf(data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Unix FIFO sink %s", u->filename);
|
|
|
|
|
pa_sink_new_data_set_sample_spec(&data, &ss);
|
|
|
|
|
pa_sink_new_data_set_channel_map(&data, &map);
|
|
|
|
|
|
2009-05-28 02:39:22 +02:00
|
|
|
if (pa_modargs_get_proplist(ma, "sink_properties", data.proplist, PA_UPDATE_REPLACE) < 0) {
|
|
|
|
|
pa_log("Invalid properties");
|
|
|
|
|
pa_sink_new_data_done(&data);
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
u->sink = pa_sink_new(m->core, &data, PA_SINK_LATENCY);
|
|
|
|
|
pa_sink_new_data_done(&data);
|
|
|
|
|
|
|
|
|
|
if (!u->sink) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log("Failed to create sink.");
|
2004-07-11 16:59:22 +00:00
|
|
|
goto fail;
|
|
|
|
|
}
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
u->sink->parent.process_msg = sink_process_msg;
|
2004-06-15 17:05:03 +00:00
|
|
|
u->sink->userdata = u;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
|
|
|
|
|
pa_sink_set_rtpoll(u->sink, u->rtpoll);
|
2009-08-01 01:59:58 +02:00
|
|
|
pa_sink_set_max_request(u->sink, pa_pipe_buf(u->fd));
|
|
|
|
|
pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(pa_pipe_buf(u->fd), &u->sink->sample_spec));
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
|
|
|
|
|
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
|
|
|
|
|
pollfd->fd = u->fd;
|
|
|
|
|
pollfd->events = pollfd->revents = 0;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2010-05-03 13:28:15 +02:00
|
|
|
if (!(u->thread = pa_thread_new("pipe-sink", thread_func, u))) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log("Failed to create thread.");
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_sink_put(u->sink);
|
2004-08-04 16:39:30 +00:00
|
|
|
|
2004-07-11 16:59:22 +00:00
|
|
|
pa_modargs_free(ma);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
fail:
|
2004-07-11 16:59:22 +00:00
|
|
|
if (ma)
|
|
|
|
|
pa_modargs_free(ma);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa__done(m);
|
2004-07-11 16:59:22 +00:00
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-15 20:49:12 +01:00
|
|
|
int pa__get_n_used(pa_module *m) {
|
|
|
|
|
struct userdata *u;
|
|
|
|
|
|
|
|
|
|
pa_assert(m);
|
|
|
|
|
pa_assert_se(u = m->userdata);
|
|
|
|
|
|
|
|
|
|
return pa_sink_linked_by(u->sink);
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
void pa__done(pa_module*m) {
|
2004-06-08 23:54:24 +00:00
|
|
|
struct userdata *u;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_assert(m);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-11 16:59:22 +00:00
|
|
|
if (!(u = m->userdata))
|
|
|
|
|
return;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if (u->sink)
|
|
|
|
|
pa_sink_unlink(u->sink);
|
|
|
|
|
|
|
|
|
|
if (u->thread) {
|
|
|
|
|
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
|
|
|
|
|
pa_thread_free(u->thread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pa_thread_mq_done(&u->thread_mq);
|
|
|
|
|
|
|
|
|
|
if (u->sink)
|
|
|
|
|
pa_sink_unref(u->sink);
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
if (u->memchunk.memblock)
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_memblock_unref(u->memchunk.memblock);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if (u->rtpoll_item)
|
|
|
|
|
pa_rtpoll_item_free(u->rtpoll_item);
|
|
|
|
|
|
|
|
|
|
if (u->rtpoll)
|
|
|
|
|
pa_rtpoll_free(u->rtpoll);
|
|
|
|
|
|
|
|
|
|
if (u->filename) {
|
|
|
|
|
unlink(u->filename);
|
|
|
|
|
pa_xfree(u->filename);
|
|
|
|
|
}
|
2004-06-14 22:47:12 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if (u->fd >= 0)
|
|
|
|
|
pa_assert_se(pa_close(u->fd) == 0);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-08-04 16:39:30 +00:00
|
|
|
pa_xfree(u);
|
2004-06-08 23:54:24 +00:00
|
|
|
}
|