mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
context: connect to a specified socket
Support in the context API for connecting to a Pinos instance listening at a specified socket - not only to the one pointed out by the environment variables XDG_RUNTIME_DIR and PINOS_CORE.
This commit is contained in:
parent
dac9755765
commit
c433df9d32
2 changed files with 29 additions and 7 deletions
|
|
@ -574,24 +574,18 @@ pinos_context_destroy (PinosContext *context)
|
|||
/**
|
||||
* pinos_context_connect:
|
||||
* @context: a #PinosContext
|
||||
* @flags: #PinosContextFlags
|
||||
*
|
||||
* Connect to the daemon with @flags
|
||||
* Connect to the daemon
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
bool
|
||||
pinos_context_connect (PinosContext *context)
|
||||
{
|
||||
PinosContextImpl *impl = SPA_CONTAINER_OF (context, PinosContextImpl, this);
|
||||
struct sockaddr_un addr;
|
||||
socklen_t size;
|
||||
const char *runtime_dir, *name = NULL;
|
||||
int name_size, fd;
|
||||
PinosMessageClientUpdate cu;
|
||||
PinosMessageGetRegistry grm;
|
||||
|
||||
context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING, NULL);
|
||||
|
||||
if ((runtime_dir = getenv ("XDG_RUNTIME_DIR")) == NULL) {
|
||||
context_set_state (context,
|
||||
|
|
@ -628,6 +622,32 @@ pinos_context_connect (PinosContext *context)
|
|||
goto error_close;
|
||||
}
|
||||
|
||||
return pinos_context_connect_fd (context, fd);
|
||||
|
||||
error_close:
|
||||
close (fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_context_connect_fd:
|
||||
* @context: a #PinosContext
|
||||
* @fd: FD of a connected Pinos socket
|
||||
*
|
||||
* Connect to a daemon. @fd should already be connected to a Pinos socket.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
bool
|
||||
pinos_context_connect_fd (PinosContext *context,
|
||||
int fd)
|
||||
{
|
||||
PinosContextImpl *impl = SPA_CONTAINER_OF (context, PinosContextImpl, this);
|
||||
PinosMessageClientUpdate cu;
|
||||
PinosMessageGetRegistry grm;
|
||||
|
||||
context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING, NULL);
|
||||
|
||||
impl->connection = pinos_connection_new (fd);
|
||||
if (impl->connection == NULL)
|
||||
goto error_close;
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ SpaResult pinos_context_send_message (PinosContext *contex
|
|||
bool flush);
|
||||
|
||||
bool pinos_context_connect (PinosContext *context);
|
||||
bool pinos_context_connect_fd (PinosContext *context,
|
||||
int fd);
|
||||
bool pinos_context_disconnect (PinosContext *context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue