si-linkables: do not fully reset when the underlying proxy is destroyed
Reset back to the session item's "configured" state instead of clearing the si properties completely. This allows the "session-item-removed" event to be dispatched with all the original properties of the node intact, for constraint matching purposes. Fixes #588
This commit is contained in:
@@ -75,13 +75,30 @@ si_audio_adapter_set_ports_state (WpSiAudioAdapter *self, WpSiAdapterPortsState
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_adapter_soft_reset (WpSiAudioAdapter *self)
|
||||
{
|
||||
/* deactivate first */
|
||||
wp_object_deactivate (WP_OBJECT (self), WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
|
||||
/* reset back to the initial "configured" state */
|
||||
if (self->format_task) {
|
||||
g_task_return_new_error (self->format_task, WP_DOMAIN_LIBRARY,
|
||||
WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"item deactivated before format was set");
|
||||
g_clear_object (&self->format_task);
|
||||
}
|
||||
g_clear_pointer (&self->format, wp_spa_pod_unref);
|
||||
self->mode[0] = '\0';
|
||||
si_audio_adapter_set_ports_state (self, WP_SI_ADAPTER_PORTS_STATE_NONE);
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_adapter_reset (WpSessionItem * item)
|
||||
{
|
||||
WpSiAudioAdapter *self = WP_SI_AUDIO_ADAPTER (item);
|
||||
|
||||
/* deactivate first */
|
||||
wp_object_deactivate (WP_OBJECT (self), WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
si_audio_adapter_soft_reset (self);
|
||||
|
||||
/* reset */
|
||||
g_clear_object (&self->node);
|
||||
@@ -97,15 +114,6 @@ si_audio_adapter_reset (WpSessionItem * item)
|
||||
self->have_encoded = FALSE;
|
||||
self->encoded_only = FALSE;
|
||||
spa_memzero (&self->raw_format, sizeof(struct spa_audio_info_raw));
|
||||
if (self->format_task) {
|
||||
g_task_return_new_error (self->format_task, WP_DOMAIN_LIBRARY,
|
||||
WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"item deactivated before format set");
|
||||
g_clear_object (&self->format_task);
|
||||
}
|
||||
g_clear_pointer (&self->format, wp_spa_pod_unref);
|
||||
self->mode[0] = '\0';
|
||||
si_audio_adapter_set_ports_state (self, WP_SI_ADAPTER_PORTS_STATE_NONE);
|
||||
|
||||
WP_SESSION_ITEM_CLASS (si_audio_adapter_parent_class)->reset (item);
|
||||
}
|
||||
@@ -227,7 +235,7 @@ on_proxy_destroyed (WpNode * proxy, WpSiAudioAdapter * self)
|
||||
{
|
||||
if (self->node == proxy) {
|
||||
wp_object_abort_activation (WP_OBJECT (self), "proxy destroyed");
|
||||
si_audio_adapter_reset (WP_SESSION_ITEM (self));
|
||||
si_audio_adapter_soft_reset (self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,13 +34,18 @@ si_node_init (WpSiNode * self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
si_node_soft_reset (WpSiNode * self)
|
||||
{
|
||||
wp_object_deactivate (WP_OBJECT (self), WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
}
|
||||
|
||||
static void
|
||||
si_node_reset (WpSessionItem * item)
|
||||
{
|
||||
WpSiNode *self = WP_SI_NODE (item);
|
||||
|
||||
/* deactivate first */
|
||||
wp_object_deactivate (WP_OBJECT (self), WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
si_node_soft_reset (self);
|
||||
|
||||
/* reset */
|
||||
g_clear_object (&self->node);
|
||||
@@ -53,7 +58,7 @@ on_proxy_destroyed (WpNode * proxy, WpSiNode * self)
|
||||
{
|
||||
if (self->node == proxy) {
|
||||
wp_object_abort_activation (WP_OBJECT (self), "proxy destroyed");
|
||||
si_node_reset (WP_SESSION_ITEM (self));
|
||||
si_node_soft_reset (self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -385,8 +385,8 @@ get_ports_and_create_links (WpSiStandardLink *self, WpTransition *transition)
|
||||
si_in = WP_SI_LINKABLE (g_weak_ref_get (&self->in_item));
|
||||
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_out)) ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_in))) {
|
||||
!wp_object_test_active_features (WP_OBJECT (si_out), WP_SESSION_ITEM_FEATURE_ACTIVE) ||
|
||||
!wp_object_test_active_features (WP_OBJECT (si_in), WP_SESSION_ITEM_FEATURE_ACTIVE)) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
@@ -492,8 +492,8 @@ on_main_adapter_ready (GObject *obj, GAsyncResult * res, gpointer p)
|
||||
main = g_object_get_data (G_OBJECT (transition), "adapter_main");
|
||||
other = g_object_get_data (G_OBJECT (transition), "adapter_other");
|
||||
|
||||
if (!wp_session_item_is_configured (WP_SESSION_ITEM (main->si)) ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (other->si))) {
|
||||
if (!wp_object_test_active_features (WP_OBJECT (main->si), WP_SESSION_ITEM_FEATURE_ACTIVE) ||
|
||||
!wp_object_test_active_features (WP_OBJECT (other->si), WP_SESSION_ITEM_FEATURE_ACTIVE)) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
@@ -526,8 +526,8 @@ configure_and_link_adapters (WpSiStandardLink *self, WpTransition *transition)
|
||||
const gchar *str = NULL;
|
||||
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_out)) ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_in))) {
|
||||
!wp_object_test_active_features (WP_OBJECT (si_out), WP_SESSION_ITEM_FEATURE_ACTIVE) ||
|
||||
!wp_object_test_active_features (WP_OBJECT (si_in), WP_SESSION_ITEM_FEATURE_ACTIVE)) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
@@ -623,8 +623,8 @@ si_standard_link_do_link (WpSiStandardLink *self, WpTransition *transition)
|
||||
g_autoptr (WpSessionItem) si_in = g_weak_ref_get (&self->in_item);
|
||||
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (si_out) ||
|
||||
!wp_session_item_is_configured (si_in)) {
|
||||
!wp_object_test_active_features ((WP_OBJECT (si_out)), WP_SESSION_ITEM_FEATURE_ACTIVE) ||
|
||||
!wp_object_test_active_features ((WP_OBJECT (si_in)), WP_SESSION_ITEM_FEATURE_ACTIVE)) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
@@ -677,8 +677,8 @@ si_standard_link_enable_active (WpSessionItem *si, WpTransition *transition)
|
||||
si_out = g_weak_ref_get (&self->out_item);
|
||||
si_in = g_weak_ref_get (&self->in_item);
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (si_out) ||
|
||||
!wp_session_item_is_configured (si_in)) {
|
||||
!wp_object_test_active_features ((WP_OBJECT (si_out)), WP_SESSION_ITEM_FEATURE_ACTIVE) ||
|
||||
!wp_object_test_active_features ((WP_OBJECT (si_in)), WP_SESSION_ITEM_FEATURE_ACTIVE)) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
|
Reference in New Issue
Block a user