mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Fix renegotiation
When we are idle and are asked to negotiate, suspend first so that we can do full negotiation again instead of using the old format. Stability fixes.
This commit is contained in:
		
							parent
							
								
									fd54471249
								
							
						
					
					
						commit
						1370fafd5b
					
				
					 10 changed files with 52 additions and 24 deletions
				
			
		| 
						 | 
					@ -240,6 +240,21 @@ no_mem:
 | 
				
			||||||
  return NULL;
 | 
					  return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					unhandle_socket (PinosStream *stream)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (impl->rtsocket_source) {
 | 
				
			||||||
 | 
					    pinos_loop_destroy_source (stream->context->loop, impl->rtsocket_source);
 | 
				
			||||||
 | 
					    impl->rtsocket_source = NULL;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (impl->timeout_source) {
 | 
				
			||||||
 | 
					    pinos_loop_destroy_source (stream->context->loop, impl->timeout_source);
 | 
				
			||||||
 | 
					    impl->timeout_source = NULL;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
pinos_stream_destroy (PinosStream *stream)
 | 
					pinos_stream_destroy (PinosStream *stream)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -249,6 +264,8 @@ pinos_stream_destroy (PinosStream *stream)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_signal_emit (&stream->destroy_signal, stream);
 | 
					  pinos_signal_emit (&stream->destroy_signal, stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unhandle_socket (stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_list_remove (&stream->link);
 | 
					  spa_list_remove (&stream->link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (impl->node_proxy)
 | 
					  if (impl->node_proxy)
 | 
				
			||||||
| 
						 | 
					@ -518,21 +535,6 @@ handle_rtnode_event (PinosStream  *stream,
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					 | 
				
			||||||
unhandle_socket (PinosStream *stream)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (impl->rtsocket_source) {
 | 
					 | 
				
			||||||
    pinos_loop_destroy_source (stream->context->loop, impl->rtsocket_source);
 | 
					 | 
				
			||||||
    impl->rtsocket_source = NULL;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if (impl->timeout_source) {
 | 
					 | 
				
			||||||
    pinos_loop_destroy_source (stream->context->loop, impl->timeout_source);
 | 
					 | 
				
			||||||
    impl->timeout_source = NULL;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_rtsocket_condition (SpaSource    *source,
 | 
					on_rtsocket_condition (SpaSource    *source,
 | 
				
			||||||
                       int           fd,
 | 
					                       int           fd,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -189,11 +189,16 @@ pinos_thread_main_loop_stop (PinosThreadMainLoop *loop)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosThreadMainLoopImpl *impl = SPA_CONTAINER_OF (loop, PinosThreadMainLoopImpl, this);
 | 
					  PinosThreadMainLoopImpl *impl = SPA_CONTAINER_OF (loop, PinosThreadMainLoopImpl, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  pinos_log_debug ("thread-mainloop: %p stopping", impl);
 | 
				
			||||||
  if (impl->running) {
 | 
					  if (impl->running) {
 | 
				
			||||||
 | 
					    pinos_log_debug ("thread-mainloop: %p signal", impl);
 | 
				
			||||||
    pinos_loop_signal_event (loop->loop, impl->event);
 | 
					    pinos_loop_signal_event (loop->loop, impl->event);
 | 
				
			||||||
 | 
					    pinos_log_debug ("thread-mainloop: %p join", impl);
 | 
				
			||||||
    pthread_join (impl->thread, NULL);
 | 
					    pthread_join (impl->thread, NULL);
 | 
				
			||||||
 | 
					    pinos_log_debug ("thread-mainloop: %p joined", impl);
 | 
				
			||||||
    impl->running = false;
 | 
					    impl->running = false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  pinos_log_debug ("thread-mainloop: %p stopped", impl);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,10 +86,11 @@ add_item (PinosSpaMonitor *this, SpaMonitorItem *item)
 | 
				
			||||||
  if (item->info) {
 | 
					  if (item->info) {
 | 
				
			||||||
    unsigned int i;
 | 
					    unsigned int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (i = 0; i < item->info->n_items; i++)
 | 
					    for (i = 0; i < item->info->n_items; i++) {
 | 
				
			||||||
      pinos_properties_set (props,
 | 
					      pinos_properties_set (props,
 | 
				
			||||||
                            item->info->items[i].key,
 | 
					                            item->info->items[i].key,
 | 
				
			||||||
                            item->info->items[i].value);
 | 
					                            item->info->items[i].value);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_properties_set (props, "media.class", item->klass);
 | 
					  pinos_properties_set (props, "media.class", item->klass);
 | 
				
			||||||
| 
						 | 
					@ -97,7 +98,7 @@ add_item (PinosSpaMonitor *this, SpaMonitorItem *item)
 | 
				
			||||||
  mitem = calloc (1, sizeof (PinosSpaMonitorItem));
 | 
					  mitem = calloc (1, sizeof (PinosSpaMonitorItem));
 | 
				
			||||||
  mitem->id = strdup (item->id);
 | 
					  mitem->id = strdup (item->id);
 | 
				
			||||||
  mitem->node = pinos_node_new (impl->core,
 | 
					  mitem->node = pinos_node_new (impl->core,
 | 
				
			||||||
                                item->factory->name,
 | 
					                                item->name,
 | 
				
			||||||
                                node_iface,
 | 
					                                node_iface,
 | 
				
			||||||
                                clock_iface,
 | 
					                                clock_iface,
 | 
				
			||||||
                                props);
 | 
					                                props);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1172,6 +1172,8 @@ on_node_free (PinosListener *listener,
 | 
				
			||||||
  pinos_log_debug ("client-node %p: free", &impl->this);
 | 
					  pinos_log_debug ("client-node %p: free", &impl->this);
 | 
				
			||||||
  proxy_clear (&impl->proxy);
 | 
					  proxy_clear (&impl->proxy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  pinos_signal_remove (&impl->node_free);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (impl->data_fd != -1)
 | 
					  if (impl->data_fd != -1)
 | 
				
			||||||
    close (impl->data_fd);
 | 
					    close (impl->data_fd);
 | 
				
			||||||
  free (impl);
 | 
					  free (impl);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -134,7 +134,7 @@ pinos_client_new (PinosCore       *core,
 | 
				
			||||||
  pinos_signal_init (&this->resource_added);
 | 
					  pinos_signal_init (&this->resource_added);
 | 
				
			||||||
  pinos_signal_init (&this->resource_removed);
 | 
					  pinos_signal_init (&this->resource_removed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_map_init (&this->objects, 64);
 | 
					  pinos_map_init (&this->objects, 0);
 | 
				
			||||||
  pinos_signal_init (&this->destroy_signal);
 | 
					  pinos_signal_init (&this->destroy_signal);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_list_insert (core->client_list.prev, &this->link);
 | 
					  spa_list_insert (core->client_list.prev, &this->link);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -192,10 +192,11 @@ pinos_data_loop_stop (PinosDataLoop *loop)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosDataLoopImpl *impl = SPA_CONTAINER_OF (loop, PinosDataLoopImpl, this);
 | 
					  PinosDataLoopImpl *impl = SPA_CONTAINER_OF (loop, PinosDataLoopImpl, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_loop_signal_event (impl->this.loop, impl->event);
 | 
					  if (impl->running) {
 | 
				
			||||||
 | 
					    pinos_loop_signal_event (impl->this.loop, impl->event);
 | 
				
			||||||
  pthread_join (impl->thread, NULL);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pthread_join (impl->thread, NULL);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					  return SPA_RESULT_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,6 +86,11 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_link_update_state (this, PINOS_LINK_STATE_NEGOTIATING, NULL);
 | 
					  pinos_link_update_state (this, PINOS_LINK_STATE_NEGOTIATING, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (out_state > SPA_NODE_STATE_READY && this->output->node->state == PINOS_NODE_STATE_IDLE) {
 | 
				
			||||||
 | 
					    pinos_node_set_state (this->output->node, PINOS_NODE_STATE_SUSPENDED);
 | 
				
			||||||
 | 
					    out_state = SPA_NODE_STATE_CONFIGURE;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* both ports need a format */
 | 
					  /* both ports need a format */
 | 
				
			||||||
  if (in_state == SPA_NODE_STATE_CONFIGURE && out_state == SPA_NODE_STATE_CONFIGURE) {
 | 
					  if (in_state == SPA_NODE_STATE_CONFIGURE && out_state == SPA_NODE_STATE_CONFIGURE) {
 | 
				
			||||||
    pinos_log_debug ("link %p: doing negotiate format", this);
 | 
					    pinos_log_debug ("link %p: doing negotiate format", this);
 | 
				
			||||||
| 
						 | 
					@ -715,7 +720,6 @@ on_output_port_destroy (PinosListener *listener,
 | 
				
			||||||
  PinosLinkImpl *impl = SPA_CONTAINER_OF (listener, PinosLinkImpl, output_port_destroy);
 | 
					  PinosLinkImpl *impl = SPA_CONTAINER_OF (listener, PinosLinkImpl, output_port_destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  on_port_destroy (&impl->this, port);
 | 
					  on_port_destroy (&impl->this, port);
 | 
				
			||||||
  pinos_signal_remove (listener);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool
 | 
					bool
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,6 +80,12 @@ pinos_main_loop_destroy (PinosMainLoop *loop)
 | 
				
			||||||
  free (impl);
 | 
					  free (impl);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * pinos_main_loop_quit:
 | 
				
			||||||
 | 
					 * @loop: a #PinosMainLoop
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Stop the running @loop.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
pinos_main_loop_quit (PinosMainLoop *loop)
 | 
					pinos_main_loop_quit (PinosMainLoop *loop)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -88,6 +94,13 @@ pinos_main_loop_quit (PinosMainLoop *loop)
 | 
				
			||||||
  impl->running = false;
 | 
					  impl->running = false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * pinos_main_loop_run:
 | 
				
			||||||
 | 
					 * @loop: a #PinosMainLoop
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Start running @loop. This function blocks until pinos_main_loop_quit()
 | 
				
			||||||
 | 
					 * has been called.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
pinos_main_loop_run (PinosMainLoop *loop)
 | 
					pinos_main_loop_run (PinosMainLoop *loop)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ pinos_resource_destroy (PinosResource *resource)
 | 
				
			||||||
  pinos_log_debug ("resource %p: destroy %u", resource, resource->id);
 | 
					  pinos_log_debug ("resource %p: destroy %u", resource, resource->id);
 | 
				
			||||||
  pinos_signal_emit (&resource->destroy_signal, resource);
 | 
					  pinos_signal_emit (&resource->destroy_signal, resource);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_map_remove (&client->objects, resource->id);
 | 
					  pinos_map_insert_at (&client->objects, resource->id, NULL);
 | 
				
			||||||
  pinos_signal_emit (&client->resource_removed, client, resource);
 | 
					  pinos_signal_emit (&client->resource_removed, client, resource);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (resource->destroy)
 | 
					  if (resource->destroy)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -333,7 +333,6 @@ spa_alsa_monitor_enum_items (SpaMonitor       *monitor,
 | 
				
			||||||
  if ((res = alsa_udev_open (this)) < 0)
 | 
					  if ((res = alsa_udev_open (this)) < 0)
 | 
				
			||||||
    return res;
 | 
					    return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
again:
 | 
					 | 
				
			||||||
  if (index == 0 || this->index > index) {
 | 
					  if (index == 0 || this->index > index) {
 | 
				
			||||||
    if (this->enumerate)
 | 
					    if (this->enumerate)
 | 
				
			||||||
      udev_enumerate_unref (this->enumerate);
 | 
					      udev_enumerate_unref (this->enumerate);
 | 
				
			||||||
| 
						 | 
					@ -349,6 +348,7 @@ again:
 | 
				
			||||||
    this->devices = udev_list_entry_get_next (this->devices);
 | 
					    this->devices = udev_list_entry_get_next (this->devices);
 | 
				
			||||||
    this->index++;
 | 
					    this->index++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					again:
 | 
				
			||||||
  if (this->devices == NULL) {
 | 
					  if (this->devices == NULL) {
 | 
				
			||||||
    fill_item (this, &this->uitem, NULL);
 | 
					    fill_item (this, &this->uitem, NULL);
 | 
				
			||||||
    return SPA_RESULT_ENUM_END;
 | 
					    return SPA_RESULT_ENUM_END;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue