mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -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:
|
* pinos_context_connect:
|
||||||
* @context: a #PinosContext
|
* @context: a #PinosContext
|
||||||
* @flags: #PinosContextFlags
|
|
||||||
*
|
*
|
||||||
* Connect to the daemon with @flags
|
* Connect to the daemon
|
||||||
*
|
*
|
||||||
* Returns: %TRUE on success.
|
* Returns: %TRUE on success.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
pinos_context_connect (PinosContext *context)
|
pinos_context_connect (PinosContext *context)
|
||||||
{
|
{
|
||||||
PinosContextImpl *impl = SPA_CONTAINER_OF (context, PinosContextImpl, this);
|
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
socklen_t size;
|
socklen_t size;
|
||||||
const char *runtime_dir, *name = NULL;
|
const char *runtime_dir, *name = NULL;
|
||||||
int name_size, fd;
|
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) {
|
if ((runtime_dir = getenv ("XDG_RUNTIME_DIR")) == NULL) {
|
||||||
context_set_state (context,
|
context_set_state (context,
|
||||||
|
|
@ -628,6 +622,32 @@ pinos_context_connect (PinosContext *context)
|
||||||
goto error_close;
|
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);
|
impl->connection = pinos_connection_new (fd);
|
||||||
if (impl->connection == NULL)
|
if (impl->connection == NULL)
|
||||||
goto error_close;
|
goto error_close;
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,8 @@ SpaResult pinos_context_send_message (PinosContext *contex
|
||||||
bool flush);
|
bool flush);
|
||||||
|
|
||||||
bool pinos_context_connect (PinosContext *context);
|
bool pinos_context_connect (PinosContext *context);
|
||||||
|
bool pinos_context_connect_fd (PinosContext *context,
|
||||||
|
int fd);
|
||||||
bool pinos_context_disconnect (PinosContext *context);
|
bool pinos_context_disconnect (PinosContext *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue