mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
stream: move some code around
So that we don't have to call public API internally. We might want to add some checks there later that don't need to happen when called internally.
This commit is contained in:
parent
f2be2923e6
commit
a6497839bb
2 changed files with 72 additions and 61 deletions
|
|
@ -1356,6 +1356,41 @@ const char *pw_filter_state_as_string(enum pw_filter_state state)
|
|||
return "invalid-state";
|
||||
}
|
||||
|
||||
static int filter_disconnect(struct filter *impl)
|
||||
{
|
||||
struct pw_filter *filter = &impl->this;
|
||||
pw_log_debug("%p: disconnect", impl);
|
||||
|
||||
if (impl->disconnecting)
|
||||
return -EBUSY;
|
||||
|
||||
impl->disconnecting = true;
|
||||
|
||||
if (filter->proxy) {
|
||||
pw_proxy_destroy(filter->proxy);
|
||||
filter->proxy = NULL;
|
||||
}
|
||||
if (impl->disconnect_core) {
|
||||
impl->disconnect_core = false;
|
||||
spa_hook_remove(&filter->core_listener);
|
||||
spa_list_remove(&filter->link);
|
||||
pw_core_disconnect(filter->core);
|
||||
filter->core = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_port(struct filter *impl, struct port *port)
|
||||
{
|
||||
spa_list_remove(&port->link);
|
||||
spa_node_emit_port_info(&impl->hooks, port->direction, port->id, NULL);
|
||||
pw_map_remove(&impl->ports[port->direction], port->id);
|
||||
clear_buffers(port);
|
||||
clear_params(impl, port, SPA_ID_INVALID);
|
||||
pw_properties_free(port->props);
|
||||
free(port);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void pw_filter_destroy(struct pw_filter *filter)
|
||||
{
|
||||
|
|
@ -1367,10 +1402,10 @@ void pw_filter_destroy(struct pw_filter *filter)
|
|||
pw_filter_emit_destroy(filter);
|
||||
|
||||
if (!impl->disconnecting)
|
||||
pw_filter_disconnect(filter);
|
||||
filter_disconnect(impl);
|
||||
|
||||
spa_list_consume(p, &impl->port_list, link)
|
||||
pw_filter_remove_port(p->user_data);
|
||||
free_port(impl, p);
|
||||
|
||||
if (filter->core) {
|
||||
spa_hook_remove(&filter->core_listener);
|
||||
|
|
@ -1591,26 +1626,7 @@ SPA_EXPORT
|
|||
int pw_filter_disconnect(struct pw_filter *filter)
|
||||
{
|
||||
struct filter *impl = SPA_CONTAINER_OF(filter, struct filter, this);
|
||||
|
||||
pw_log_debug("%p: disconnect", filter);
|
||||
|
||||
if (impl->disconnecting)
|
||||
return -EBUSY;
|
||||
|
||||
impl->disconnecting = true;
|
||||
|
||||
if (filter->proxy) {
|
||||
pw_proxy_destroy(filter->proxy);
|
||||
filter->proxy = NULL;
|
||||
}
|
||||
if (impl->disconnect_core) {
|
||||
impl->disconnect_core = false;
|
||||
spa_hook_remove(&filter->core_listener);
|
||||
spa_list_remove(&filter->link);
|
||||
pw_core_disconnect(filter->core);
|
||||
filter->core = NULL;
|
||||
}
|
||||
return 0;
|
||||
return filter_disconnect(impl);
|
||||
}
|
||||
|
||||
static void add_port_params(struct filter *impl, struct port *port)
|
||||
|
|
@ -1748,17 +1764,6 @@ error_cleanup:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static inline void free_port(struct filter *impl, struct port *port)
|
||||
{
|
||||
spa_list_remove(&port->link);
|
||||
spa_node_emit_port_info(&impl->hooks, port->direction, port->id, NULL);
|
||||
pw_map_remove(&impl->ports[port->direction], port->id);
|
||||
clear_buffers(port);
|
||||
clear_params(impl, port, SPA_ID_INVALID);
|
||||
pw_properties_free(port->props);
|
||||
free(port);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_filter_remove_port(void *port_data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1609,6 +1609,38 @@ const char *pw_stream_state_as_string(enum pw_stream_state state)
|
|||
return "invalid-state";
|
||||
}
|
||||
|
||||
static int stream_disconnect(struct stream *impl)
|
||||
{
|
||||
struct pw_stream *stream = &impl->this;
|
||||
|
||||
pw_log_debug("%p: disconnect", stream);
|
||||
|
||||
if (impl->disconnecting)
|
||||
return -EBUSY;
|
||||
|
||||
impl->disconnecting = true;
|
||||
|
||||
if (impl->node)
|
||||
pw_impl_node_set_active(impl->node, false);
|
||||
|
||||
if (stream->proxy) {
|
||||
pw_proxy_destroy(stream->proxy);
|
||||
stream->proxy = NULL;
|
||||
}
|
||||
|
||||
if (impl->node)
|
||||
pw_impl_node_destroy(impl->node);
|
||||
|
||||
if (impl->disconnect_core) {
|
||||
impl->disconnect_core = false;
|
||||
spa_hook_remove(&stream->core_listener);
|
||||
spa_list_remove(&stream->link);
|
||||
pw_core_disconnect(stream->core);
|
||||
stream->core = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void pw_stream_destroy(struct pw_stream *stream)
|
||||
{
|
||||
|
|
@ -1620,7 +1652,7 @@ void pw_stream_destroy(struct pw_stream *stream)
|
|||
pw_stream_emit_destroy(stream);
|
||||
|
||||
if (!impl->disconnecting)
|
||||
pw_stream_disconnect(stream);
|
||||
stream_disconnect(impl);
|
||||
|
||||
if (stream->core) {
|
||||
spa_hook_remove(&stream->core_listener);
|
||||
|
|
@ -2043,33 +2075,7 @@ SPA_EXPORT
|
|||
int pw_stream_disconnect(struct pw_stream *stream)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
|
||||
pw_log_debug("%p: disconnect", stream);
|
||||
|
||||
if (impl->disconnecting)
|
||||
return -EBUSY;
|
||||
|
||||
impl->disconnecting = true;
|
||||
|
||||
if (impl->node)
|
||||
pw_impl_node_set_active(impl->node, false);
|
||||
|
||||
if (stream->proxy) {
|
||||
pw_proxy_destroy(stream->proxy);
|
||||
stream->proxy = NULL;
|
||||
}
|
||||
|
||||
if (impl->node)
|
||||
pw_impl_node_destroy(impl->node);
|
||||
|
||||
if (impl->disconnect_core) {
|
||||
impl->disconnect_core = false;
|
||||
spa_hook_remove(&stream->core_listener);
|
||||
spa_list_remove(&stream->link);
|
||||
pw_core_disconnect(stream->core);
|
||||
stream->core = NULL;
|
||||
}
|
||||
return 0;
|
||||
return stream_disconnect(impl);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue