mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
pipewiresrc: improve remote connection errors
This commit is contained in:
parent
a003d1a39f
commit
629f824b91
5 changed files with 27 additions and 24 deletions
|
|
@ -895,6 +895,9 @@ gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
|||
if (pwsrc->flushing)
|
||||
goto streaming_stopped;
|
||||
|
||||
if (pwsrc->stream == NULL)
|
||||
goto streaming_error;
|
||||
|
||||
state = pwsrc->stream->state;
|
||||
if (state == PW_STREAM_STATE_ERROR)
|
||||
goto streaming_error;
|
||||
|
|
|
|||
|
|
@ -44,14 +44,6 @@ static struct pw_node *create_node(struct pw_node_factory *factory,
|
|||
{
|
||||
struct pw_client_node *node;
|
||||
|
||||
if (properties == NULL)
|
||||
properties = pw_properties_new(NULL, NULL);
|
||||
if (properties == NULL)
|
||||
goto no_mem;
|
||||
|
||||
pw_properties_setf(properties,
|
||||
"pipewire.owner.client", "%d", resource->client->global->id);
|
||||
|
||||
node = pw_client_node_new(resource, name, properties);
|
||||
if (node == NULL)
|
||||
goto no_mem;
|
||||
|
|
|
|||
|
|
@ -428,8 +428,10 @@ on_remote_data(struct spa_loop_utils *utils,
|
|||
|
||||
if (mask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
||||
pw_log_error("protocol-native %p: got connection error", impl);
|
||||
pw_remote_destroy(this);
|
||||
return;
|
||||
pw_loop_destroy_source(this->core->main_loop, impl->source);
|
||||
impl->source = NULL;
|
||||
pw_remote_update_state(this, PW_REMOTE_STATE_ERROR, "connection error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mask & SPA_IO_IN) {
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ const char *pw_remote_state_as_string(enum pw_remote_state state)
|
|||
return "invalid-state";
|
||||
}
|
||||
|
||||
static void
|
||||
remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...)
|
||||
void
|
||||
pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...)
|
||||
{
|
||||
if (remote->state != state) {
|
||||
if (remote->error)
|
||||
|
|
@ -101,7 +101,7 @@ static void core_event_done(void *object, uint32_t seq)
|
|||
|
||||
pw_log_debug("core event done %d", seq);
|
||||
if (seq == 0)
|
||||
remote_update_state(this, PW_REMOTE_STATE_CONNECTED, NULL);
|
||||
pw_remote_update_state(this, PW_REMOTE_STATE_CONNECTED, NULL);
|
||||
|
||||
pw_signal_emit(&this->sync_reply, this, seq);
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ static void core_event_error(void *object, uint32_t id, int res, const char *err
|
|||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct pw_remote *this = proxy->object;
|
||||
remote_update_state(this, PW_REMOTE_STATE_ERROR, error);
|
||||
pw_remote_update_state(this, PW_REMOTE_STATE_ERROR, error);
|
||||
}
|
||||
|
||||
static void core_event_remove_id(void *object, uint32_t id)
|
||||
|
|
@ -211,6 +211,7 @@ struct pw_remote *pw_remote_new(struct pw_core *core,
|
|||
void pw_remote_destroy(struct pw_remote *remote)
|
||||
{
|
||||
struct remote *impl = SPA_CONTAINER_OF(remote, struct remote, this);
|
||||
struct pw_stream *stream, *s2;
|
||||
|
||||
pw_log_debug("remote %p: destroy", remote);
|
||||
pw_signal_emit(&remote->destroy_signal, remote);
|
||||
|
|
@ -218,6 +219,9 @@ void pw_remote_destroy(struct pw_remote *remote)
|
|||
if (remote->state != PW_REMOTE_STATE_UNCONNECTED)
|
||||
pw_remote_disconnect(remote);
|
||||
|
||||
spa_list_for_each_safe(stream, s2, &remote->stream_list, link)
|
||||
pw_stream_destroy(stream);
|
||||
|
||||
pw_protocol_connection_destroy (remote->conn);
|
||||
|
||||
spa_list_remove(&remote->link);
|
||||
|
|
@ -243,7 +247,7 @@ static int do_connect(struct pw_remote *remote)
|
|||
|
||||
no_proxy:
|
||||
pw_protocol_connection_disconnect (remote->conn);
|
||||
remote_update_state(remote, PW_REMOTE_STATE_ERROR, "can't connect: no memory");
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_ERROR, "can't connect: no memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -251,10 +255,10 @@ int pw_remote_connect(struct pw_remote *remote)
|
|||
{
|
||||
int res;
|
||||
|
||||
remote_update_state(remote, PW_REMOTE_STATE_CONNECTING, NULL);
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_CONNECTING, NULL);
|
||||
|
||||
if ((res = pw_protocol_connection_connect (remote->conn)) < 0) {
|
||||
remote_update_state(remote, PW_REMOTE_STATE_ERROR, "connect failed");
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_ERROR, "connect failed");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -265,10 +269,10 @@ int pw_remote_connect_fd(struct pw_remote *remote, int fd)
|
|||
{
|
||||
int res;
|
||||
|
||||
remote_update_state(remote, PW_REMOTE_STATE_CONNECTING, NULL);
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_CONNECTING, NULL);
|
||||
|
||||
if ((res = pw_protocol_connection_connect_fd (remote->conn, fd)) < 0) {
|
||||
remote_update_state(remote, PW_REMOTE_STATE_ERROR, "connect_fd failed");
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_ERROR, "connect_fd failed");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -281,14 +285,13 @@ void pw_remote_disconnect(struct pw_remote *remote)
|
|||
struct pw_stream *stream, *s2;
|
||||
|
||||
pw_log_debug("remote %p: disconnect", remote);
|
||||
pw_protocol_connection_disconnect (remote->conn);
|
||||
|
||||
spa_list_for_each_safe(stream, s2, &remote->stream_list, link)
|
||||
pw_stream_destroy(stream);
|
||||
pw_stream_disconnect(stream);
|
||||
|
||||
pw_protocol_connection_disconnect (remote->conn);
|
||||
|
||||
spa_list_for_each_safe(proxy, t2, &remote->proxy_list, link)
|
||||
pw_proxy_destroy(proxy);
|
||||
|
||||
remote->core_proxy = NULL;
|
||||
|
||||
pw_map_clear(&remote->objects);
|
||||
|
|
@ -300,5 +303,5 @@ void pw_remote_disconnect(struct pw_remote *remote)
|
|||
remote->info = NULL;
|
||||
}
|
||||
|
||||
remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL);
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ int pw_remote_connect_fd(struct pw_remote *remote, int fd);
|
|||
/** Disconnect from the remote PipeWire. \memberof pw_remote */
|
||||
void pw_remote_disconnect(struct pw_remote *remote);
|
||||
|
||||
/** Update the state of the remote, mostly used by protocols */
|
||||
void pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue