diff options
author | Samo Pogačnik <samo_pogacnik@t-2.net> | 2018-01-18 16:15:18 +0100 |
---|---|---|
committer | Georg Chini <georg@chini.tk> | 2018-01-18 16:18:25 +0100 |
commit | 2563cd65bc4a9c60518383133ea06761c08e724b (patch) | |
tree | 1df582f72b2c27f12ddb42634a1c18e6a158d0bb /src | |
parent | fb8f978676f45da13f246f56a4d39de060ef3761 (diff) | |
download | pulseaudio-2563cd65bc4a9c60518383133ea06761c08e724b.tar.gz |
pipe-sink: use existing fifo
Allow usage of an already existing fifo (named pipe) within the
pipe-sink module. Also, the used fifo is going to be removed upon
module unload only if the fifo is created by the same module.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/module-pipe-sink.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c index fe2af70e8..a2074c1f2 100644 --- a/src/modules/module-pipe-sink.c +++ b/src/modules/module-pipe-sink.c @@ -78,6 +78,7 @@ struct userdata { char *filename; int fd; + bool do_unlink_fifo; size_t buffer_size; size_t bytes_dropped; bool fifo_error; @@ -450,11 +451,16 @@ int pa__init(pa_module *m) { u->write_type = 0; u->filename = pa_runtime_path(pa_modargs_get_value(ma, "file", DEFAULT_FILE_NAME)); + u->do_unlink_fifo = false; if (mkfifo(u->filename, 0666) < 0) { - pa_log("mkfifo('%s'): %s", u->filename, pa_cstrerror(errno)); - goto fail; - } + if (errno != EEXIST) { + pa_log("mkfifo('%s'): %s", u->filename, pa_cstrerror(errno)); + goto fail; + } + } else + u->do_unlink_fifo = true; + if ((u->fd = pa_open_cloexec(u->filename, O_RDWR, 0)) < 0) { pa_log("open('%s'): %s", u->filename, pa_cstrerror(errno)); goto fail; @@ -584,7 +590,8 @@ void pa__done(pa_module *m) { pa_rtpoll_free(u->rtpoll); if (u->filename) { - unlink(u->filename); + if (u->do_unlink_fifo) + unlink(u->filename); pa_xfree(u->filename); } |