remote: always close the fd in connect_fd

Not closing the fd causes leaks in existing apps. It's probably better
to always close it and let apps deal with that by using dup or similar.

Make gst sink and source dup the fd before connect_fd().

Fixes #181
This commit is contained in:
Wim Taymans 2019-09-10 11:05:38 +02:00
parent ddd2a97f7e
commit c9855763c3
4 changed files with 5 additions and 4 deletions

View file

@ -41,6 +41,7 @@
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
#include "gstpipewireformat.h"
@ -738,7 +739,7 @@ gst_pipewire_sink_open (GstPipeWireSink * pwsink)
if (pwsink->fd == -1)
pw_remote_connect (pwsink->remote);
else
pw_remote_connect_fd (pwsink->remote, pwsink->fd);
pw_remote_connect_fd (pwsink->remote, dup(pwsink->fd));
while (TRUE) {
enum pw_remote_state state = pw_remote_get_state (pwsink->remote, &error);

View file

@ -984,7 +984,7 @@ gst_pipewire_src_open (GstPipeWireSrc * pwsrc)
if (pwsrc->fd == -1)
pw_remote_connect (pwsrc->remote);
else
pw_remote_connect_fd (pwsrc->remote, pwsrc->fd);
pw_remote_connect_fd (pwsrc->remote, dup(pwsrc->fd));
while (TRUE) {
enum pw_remote_state state = pw_remote_get_state(pwsrc->remote, &error);