mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-06 00:40:34 +00:00
stream: improve fixup of dataType
Also handle choice flag types. Do some more error checking.
This commit is contained in:
parent
941620b733
commit
2963d6e725
|
@ -181,6 +181,32 @@ static int get_port_param_index(uint32_t id)
|
|||
}
|
||||
}
|
||||
|
||||
static void fix_datatype(const struct spa_pod *param)
|
||||
{
|
||||
const struct spa_pod_prop *pod_param;
|
||||
const struct spa_pod *vals;
|
||||
uint32_t dataType, n_vals, choice;
|
||||
|
||||
pod_param = spa_pod_find_prop(param, NULL, SPA_PARAM_BUFFERS_dataType);
|
||||
if (pod_param == NULL)
|
||||
return;
|
||||
|
||||
vals = spa_pod_get_values(&pod_param->value, &n_vals, &choice);
|
||||
if (n_vals == 0)
|
||||
return;
|
||||
|
||||
if (spa_pod_get_int(&vals[0], (int32_t*)&dataType) < 0)
|
||||
return;
|
||||
|
||||
pw_log_debug(NAME" dataType: %u", dataType);
|
||||
if (dataType & (1u << SPA_DATA_MemPtr)) {
|
||||
SPA_POD_VALUE(struct spa_pod_int, &vals[0]) =
|
||||
dataType | mappable_dataTypes;
|
||||
pw_log_debug(NAME" Change dataType: %u -> %u", dataType,
|
||||
SPA_POD_VALUE(struct spa_pod_int, &vals[0]));
|
||||
}
|
||||
}
|
||||
|
||||
static struct param *add_param(struct stream *impl,
|
||||
uint32_t id, uint32_t flags, const struct spa_pod *param)
|
||||
{
|
||||
|
@ -198,27 +224,10 @@ static struct param *add_param(struct stream *impl,
|
|||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
if (id == SPA_PARAM_Buffers && SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_MAP_BUFFERS) &&
|
||||
impl->direction == SPA_DIRECTION_INPUT)
|
||||
{
|
||||
const struct spa_pod_prop *pod_param;
|
||||
uint32_t dataType = 0;
|
||||
|
||||
pod_param = spa_pod_find_prop(param, NULL, SPA_PARAM_BUFFERS_dataType);
|
||||
if (pod_param != NULL)
|
||||
{
|
||||
spa_pod_get_int(&pod_param->value, (int32_t*)&dataType);
|
||||
pw_log_debug(NAME" dataType: %d", dataType);
|
||||
if ((dataType & (1<<SPA_DATA_MemPtr)) > 0)
|
||||
{
|
||||
pw_log_debug(NAME" Change dataType");
|
||||
struct spa_pod_int *int_pod = (struct spa_pod_int*)&pod_param->value;
|
||||
dataType = dataType | mappable_dataTypes;
|
||||
pw_log_debug(NAME" dataType: %d", dataType);
|
||||
int_pod->value = dataType;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (id == SPA_PARAM_Buffers &&
|
||||
SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_MAP_BUFFERS) &&
|
||||
impl->direction == SPA_DIRECTION_INPUT)
|
||||
fix_datatype(param);
|
||||
|
||||
p->id = id;
|
||||
p->flags = flags;
|
||||
|
|
Loading…
Reference in a new issue