mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
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:
parent
633c27824f
commit
9a202272f2
4 changed files with 5 additions and 4 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "gstpipewireformat.h"
|
||||
|
|
@ -735,7 +736,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);
|
||||
|
|
|
|||
|
|
@ -1002,7 +1002,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);
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ int pw_remote_connect_fd(struct pw_remote *remote, int fd)
|
|||
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_CONNECTING, NULL);
|
||||
|
||||
if ((res = pw_protocol_client_connect_fd(remote->conn, fd, false)) < 0) {
|
||||
if ((res = pw_protocol_client_connect_fd(remote->conn, fd, true)) < 0) {
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_ERROR,
|
||||
"connect_fd failed %s", spa_strerror(res));
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ void pw_remote_add_listener(struct pw_remote *remote,
|
|||
int pw_remote_connect(struct pw_remote *remote);
|
||||
|
||||
/** Connect to a remote PipeWire on the given socket \memberof pw_remote
|
||||
* \param fd the connected socket to use, the socket will not be closed
|
||||
* \param fd the connected socket to use, the socket will be closed
|
||||
* automatically on disconnect or error.
|
||||
* \return 0 on success, < 0 on error */
|
||||
int pw_remote_connect_fd(struct pw_remote *remote, int fd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue