mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Use int counters for iterating items
Use counters instead of void* to iterate items. This simplifies some things and makes it easier to do over the wire. Add format description to NodeInfo and use this to add format descriptions to pinos devices. Small fixes to fix leaks and crashes.
This commit is contained in:
		
							parent
							
								
									8b84d8fde6
								
							
						
					
					
						commit
						b38ecafe81
					
				
					 38 changed files with 363 additions and 330 deletions
				
			
		| 
						 | 
				
			
			@ -311,13 +311,12 @@ spa_audiomixer_node_port_enum_formats (SpaNode         *node,
 | 
			
		|||
                                       uint32_t         port_id,
 | 
			
		||||
                                       SpaFormat      **format,
 | 
			
		||||
                                       const SpaFormat *filter,
 | 
			
		||||
                                       void           **state)
 | 
			
		||||
                                       unsigned int     index)
 | 
			
		||||
{
 | 
			
		||||
  SpaAudioMixer *this;
 | 
			
		||||
  SpaAudioMixerPort *port;
 | 
			
		||||
  int index;
 | 
			
		||||
 | 
			
		||||
  if (node == NULL || format == NULL || state == NULL)
 | 
			
		||||
  if (node == NULL || format == NULL)
 | 
			
		||||
    return SPA_RESULT_INVALID_ARGUMENTS;
 | 
			
		||||
 | 
			
		||||
  this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
 | 
			
		||||
| 
						 | 
				
			
			@ -327,8 +326,6 @@ spa_audiomixer_node_port_enum_formats (SpaNode         *node,
 | 
			
		|||
 | 
			
		||||
  port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[0];
 | 
			
		||||
 | 
			
		||||
  index = (*state == NULL ? 0 : *(int*)state);
 | 
			
		||||
 | 
			
		||||
  switch (index) {
 | 
			
		||||
    case 0:
 | 
			
		||||
      spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
 | 
			
		||||
| 
						 | 
				
			
			@ -339,7 +336,6 @@ spa_audiomixer_node_port_enum_formats (SpaNode         *node,
 | 
			
		|||
      return SPA_RESULT_ENUM_END;
 | 
			
		||||
  }
 | 
			
		||||
  *format = &port->format[0].format;
 | 
			
		||||
  *(int*)state = ++index;
 | 
			
		||||
 | 
			
		||||
  return SPA_RESULT_OK;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -781,15 +777,11 @@ static const SpaInterfaceInfo audiomixer_interfaces[] =
 | 
			
		|||
static SpaResult
 | 
			
		||||
audiomixer_enum_interface_info (const SpaHandleFactory  *factory,
 | 
			
		||||
                                const SpaInterfaceInfo **info,
 | 
			
		||||
                                void                   **state)
 | 
			
		||||
                                unsigned int             index)
 | 
			
		||||
{
 | 
			
		||||
  int index;
 | 
			
		||||
 | 
			
		||||
  if (factory == NULL || info == NULL || state == NULL)
 | 
			
		||||
  if (factory == NULL || info == NULL)
 | 
			
		||||
    return SPA_RESULT_INVALID_ARGUMENTS;
 | 
			
		||||
 | 
			
		||||
  index = (*state == NULL ? 0 : *(int*)state);
 | 
			
		||||
 | 
			
		||||
  switch (index) {
 | 
			
		||||
    case 0:
 | 
			
		||||
      *info = &audiomixer_interfaces[index];
 | 
			
		||||
| 
						 | 
				
			
			@ -797,7 +789,6 @@ audiomixer_enum_interface_info (const SpaHandleFactory  *factory,
 | 
			
		|||
    default:
 | 
			
		||||
      return SPA_RESULT_ENUM_END;
 | 
			
		||||
  }
 | 
			
		||||
  *(int*)state = ++index;
 | 
			
		||||
  return SPA_RESULT_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,15 +24,11 @@ extern const SpaHandleFactory spa_audiomixer_factory;
 | 
			
		|||
 | 
			
		||||
SpaResult
 | 
			
		||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
 | 
			
		||||
                         void                   **state)
 | 
			
		||||
                         unsigned int             index)
 | 
			
		||||
{
 | 
			
		||||
  int index;
 | 
			
		||||
 | 
			
		||||
  if (factory == NULL || state == NULL)
 | 
			
		||||
  if (factory == NULL)
 | 
			
		||||
    return SPA_RESULT_INVALID_ARGUMENTS;
 | 
			
		||||
 | 
			
		||||
  index = (*state == NULL ? 0 : *(int*)state);
 | 
			
		||||
 | 
			
		||||
  switch (index) {
 | 
			
		||||
    case 0:
 | 
			
		||||
      *factory = &spa_audiomixer_factory;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,6 +36,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
 | 
			
		|||
    default:
 | 
			
		||||
      return SPA_RESULT_ENUM_END;
 | 
			
		||||
  }
 | 
			
		||||
  *(int*)state = ++index;
 | 
			
		||||
  return SPA_RESULT_OK;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue