gst: only pop and adjust choice when we pushed something

This commit is contained in:
Wim Taymans 2020-05-20 13:53:23 +02:00
parent eb93f259e0
commit 78aaf6c0bc

View file

@ -379,10 +379,12 @@ handle_video_fields (ConvertData *d)
if (idx != GST_VIDEO_FORMAT_UNKNOWN && idx < (int)SPA_N_ELEMENTS (video_format_map))
spa_pod_builder_id (&d->b, video_format_map[idx]);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
value = gst_structure_get_value (d->cs, "width");
value2 = gst_structure_get_value (d->cs, "height");
if (value || value2) {
@ -395,10 +397,12 @@ handle_video_fields (ConvertData *d)
spa_pod_builder_rectangle (&d->b, v.width, v.height);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
value = gst_structure_get_value (d->cs, "framerate");
if (value) {
@ -411,10 +415,12 @@ handle_video_fields (ConvertData *d)
spa_pod_builder_fraction (&d->b, v.num, v.denom);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
value = gst_structure_get_value (d->cs, "max-framerate");
if (value) {
@ -427,10 +433,12 @@ handle_video_fields (ConvertData *d)
spa_pod_builder_fraction (&d->b, v.num, v.denom);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
return TRUE;
}
@ -456,10 +464,12 @@ handle_audio_fields (ConvertData *d)
if (idx < (int)SPA_N_ELEMENTS (audio_format_map))
spa_pod_builder_id (&d->b, audio_format_map[idx]);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
#if 0
value = gst_structure_get_value (d->cs, "layout");
@ -482,10 +492,12 @@ handle_audio_fields (ConvertData *d)
spa_pod_builder_id (&d->b, layout);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
#endif
value = gst_structure_get_value (d->cs, "rate");
if (value) {
@ -498,10 +510,12 @@ handle_audio_fields (ConvertData *d)
spa_pod_builder_int (&d->b, v);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
value = gst_structure_get_value (d->cs, "channels");
if (value) {
int v;
@ -513,10 +527,12 @@ handle_audio_fields (ConvertData *d)
spa_pod_builder_int (&d->b, v);
}
if (i > 0) {
choice = spa_pod_builder_pop(&d->b, &f);
if (i <= 1)
if (i == 1)
choice->body.type = SPA_CHOICE_None;
}
}
return TRUE;
}