mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Rework formats
Use a POD for the format body. This allows us to more easily build and copy the formats. Remove obsolete code to make video and audio formats. Use SpaVideo/AudioInfo to keep track of formats. Make functions to parse the format into the structures. Update plugins
This commit is contained in:
parent
7fc73953cd
commit
16b62de53a
34 changed files with 1096 additions and 1579 deletions
|
|
@ -367,6 +367,9 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
{
|
||||
SpaALSASource *this;
|
||||
SpaResult res;
|
||||
SpaFormat *fmt;
|
||||
uint8_t buffer[256];
|
||||
SpaPODBuilder b = { buffer, sizeof (buffer), };
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -378,23 +381,42 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
SPA_MEDIA_SUBTYPE_RAW,
|
||||
&this->query_format);
|
||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
||||
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
||||
SPA_PROP_ID_AUDIO_FORMAT, SPA_POD_TYPE_INT,
|
||||
SPA_AUDIO_FORMAT_S16,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_ENUM, 2,
|
||||
SPA_AUDIO_FORMAT_S16,
|
||||
SPA_AUDIO_FORMAT_S32,
|
||||
SPA_PROP_ID_AUDIO_RATE, SPA_POD_TYPE_INT,
|
||||
44100,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
1, INT32_MAX,
|
||||
SPA_PROP_ID_AUDIO_CHANNELS, SPA_POD_TYPE_INT,
|
||||
2,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
1, INT32_MAX,
|
||||
0), SpaFormat);
|
||||
break;
|
||||
case 1:
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
SPA_MEDIA_SUBTYPE_AAC,
|
||||
&this->query_format);
|
||||
break;
|
||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
||||
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_AAC,
|
||||
0), SpaFormat);
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
if ((res = spa_format_audio_filter (&this->query_format, filter)) != SPA_RESULT_OK)
|
||||
b.data = this->format_buffer;
|
||||
b.size = sizeof (this->format_buffer);
|
||||
b.offset = 0;
|
||||
|
||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
*format = &this->query_format.format;
|
||||
*format = SPA_MEMBER (this->format_buffer, 0, SpaFormat);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -502,7 +524,7 @@ spa_alsa_source_node_port_get_format (SpaNode *node,
|
|||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*format = &this->current_format.format;
|
||||
*format = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue