format: make helper functions to create formats

Use helper functions to create a fully specified format.
This commit is contained in:
Wim Taymans 2018-08-29 15:53:26 +02:00
parent 80de83f38a
commit 514528f2c7
24 changed files with 158 additions and 430 deletions

View file

@ -206,14 +206,13 @@ static int negotiate_formats(struct data *data)
uint8_t buffer[4096];
spa_pod_builder_init(&b, buffer, sizeof(buffer));
format = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Format, 0,
"I", SPA_MEDIA_TYPE_audio,
"I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_S16,
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_INTERLEAVED,
":", SPA_FORMAT_AUDIO_rate, "i", 44100,
":", SPA_FORMAT_AUDIO_channels, "i", 2);
format = spa_format_audio_raw_build(&b, 0,
&SPA_AUDIO_INFO_RAW_INIT(
.format = SPA_AUDIO_FORMAT_S16,
.layout = SPA_AUDIO_LAYOUT_INTERLEAVED,
.rate = 44100,
.channels = 2 ));
if ((res = spa_node_port_set_param(data->conv,
SPA_DIRECTION_INPUT, 0,
@ -235,15 +234,12 @@ static int negotiate_formats(struct data *data)
spa_pod_builder_init(&b, buffer, sizeof(buffer));
format = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Format, 0,
"I", SPA_MEDIA_TYPE_audio,
"I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32,
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED,
":", SPA_FORMAT_AUDIO_rate, "i", 44100,
":", SPA_FORMAT_AUDIO_channels, "i", 2);
format = spa_format_audio_raw_build(&b, 0,
&SPA_AUDIO_INFO_RAW_INIT(
.format = SPA_AUDIO_FORMAT_F32,
.layout = SPA_AUDIO_LAYOUT_NON_INTERLEAVED,
.rate = 44100,
.channels = 2 ));
if ((res = spa_node_port_set_param(data->conv,
SPA_DIRECTION_OUTPUT, 0,