2004-09-21 19:40:55 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
/***
|
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
|
2004-09-21 19:40:55 +00:00
|
|
|
by the Free Software Foundation; either version 2 of the License,
|
|
|
|
|
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-09-21 19:40:55 +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-09-21 19:40:55 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/core-error.h>
|
|
|
|
|
#include <pulsecore/module.h>
|
|
|
|
|
#include <pulsecore/modargs.h>
|
|
|
|
|
#include <pulsecore/core-util.h>
|
|
|
|
|
#include <pulsecore/log.h>
|
2006-02-16 19:19:58 +00:00
|
|
|
|
2004-10-30 01:55:16 +00:00
|
|
|
#include "module-esound-compat-spawnfd-symdef.h"
|
2004-09-21 19:40:55 +00:00
|
|
|
|
|
|
|
|
PA_MODULE_AUTHOR("Lennart Poettering")
|
|
|
|
|
PA_MODULE_DESCRIPTION("ESOUND compatibility module: -spawnfd emulation")
|
|
|
|
|
PA_MODULE_USAGE("fd=<file descriptor>")
|
|
|
|
|
PA_MODULE_VERSION(PACKAGE_VERSION)
|
|
|
|
|
|
|
|
|
|
static const char* const valid_modargs[] = {
|
|
|
|
|
"fd",
|
|
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
int pa__init(pa_module*m) {
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_modargs *ma = NULL;
|
2004-09-21 19:40:55 +00:00
|
|
|
int ret = -1, fd = -1;
|
|
|
|
|
char x = 1;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_assert(m);
|
2004-09-21 19:40:55 +00:00
|
|
|
|
|
|
|
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs)) ||
|
|
|
|
|
pa_modargs_get_value_s32(ma, "fd", &fd) < 0 ||
|
|
|
|
|
fd < 0) {
|
2007-10-28 19:13:50 +00:00
|
|
|
|
2006-08-18 21:38:40 +00:00
|
|
|
pa_log("Failed to parse module arguments");
|
2004-09-21 19:40:55 +00:00
|
|
|
goto finish;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-14 22:42:01 +00:00
|
|
|
if (pa_loop_write(fd, &x, sizeof(x), NULL) != sizeof(x))
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log_warn("write(%u, 1, 1) failed: %s", fd, pa_cstrerror(errno));
|
2004-09-21 19:40:55 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert_se(pa_close(fd) == 0);
|
2004-09-21 19:40:55 +00:00
|
|
|
|
|
|
|
|
pa_module_unload_request(m);
|
|
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
|
|
finish:
|
|
|
|
|
if (ma)
|
|
|
|
|
pa_modargs_free(ma);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|