mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04: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
|
|
@ -363,12 +363,11 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
|
@ -376,8 +375,6 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
|
|
@ -393,7 +390,6 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -902,22 +898,16 @@ static const SpaInterfaceInfo alsa_source_interfaces[] =
|
|||
static SpaResult
|
||||
alsa_source_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);
|
||||
|
||||
if (index < 0 || index >= SPA_N_ELEMENTS (alsa_source_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &alsa_source_interfaces[index];
|
||||
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue