stream: fix datatyp on copied object
First copy the object and then modify it to avoid changing the user provided param.
This commit is contained in:
parent
016d15e598
commit
00a82017a2
|
@ -197,10 +197,10 @@ static int get_port_param_index(uint32_t id)
|
|||
}
|
||||
}
|
||||
|
||||
static void fix_datatype(const struct spa_pod *param)
|
||||
static void fix_datatype(struct spa_pod *param)
|
||||
{
|
||||
const struct spa_pod_prop *pod_param;
|
||||
const struct spa_pod *vals;
|
||||
struct spa_pod *vals;
|
||||
uint32_t dataType, n_vals, choice;
|
||||
|
||||
pod_param = spa_pod_find_prop(param, NULL, SPA_PARAM_BUFFERS_dataType);
|
||||
|
@ -240,11 +240,6 @@ static struct param *add_param(struct filter *impl, struct port *port,
|
|||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
if (id == SPA_PARAM_Buffers && port != NULL &&
|
||||
SPA_FLAG_IS_SET(port->flags, PW_FILTER_PORT_FLAG_MAP_BUFFERS) &&
|
||||
port->direction == SPA_DIRECTION_INPUT)
|
||||
fix_datatype(param);
|
||||
|
||||
if (id == SPA_PARAM_ProcessLatency && port == NULL)
|
||||
spa_process_latency_parse(param, &impl->process_latency);
|
||||
|
||||
|
@ -254,6 +249,11 @@ static struct param *add_param(struct filter *impl, struct port *port,
|
|||
memcpy(p->param, param, SPA_POD_SIZE(param));
|
||||
SPA_POD_OBJECT_ID(p->param) = id;
|
||||
|
||||
if (id == SPA_PARAM_Buffers && port != NULL &&
|
||||
SPA_FLAG_IS_SET(port->flags, PW_FILTER_PORT_FLAG_MAP_BUFFERS) &&
|
||||
port->direction == SPA_DIRECTION_INPUT)
|
||||
fix_datatype(p->param);
|
||||
|
||||
pw_log_debug("%p: port %p param id %d (%s)", impl, p, id,
|
||||
spa_debug_type_find_name(spa_type_param, id));
|
||||
|
||||
|
|
|
@ -199,10 +199,10 @@ static int get_port_param_index(uint32_t id)
|
|||
}
|
||||
}
|
||||
|
||||
static void fix_datatype(const struct spa_pod *param)
|
||||
static void fix_datatype(struct spa_pod *param)
|
||||
{
|
||||
const struct spa_pod_prop *pod_param;
|
||||
const struct spa_pod *vals;
|
||||
struct spa_pod *vals;
|
||||
uint32_t dataType, n_vals, choice;
|
||||
|
||||
pod_param = spa_pod_find_prop(param, NULL, SPA_PARAM_BUFFERS_dataType);
|
||||
|
@ -242,17 +242,17 @@ 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)
|
||||
fix_datatype(param);
|
||||
|
||||
p->id = id;
|
||||
p->flags = flags;
|
||||
p->param = SPA_PTROFF(p, sizeof(struct param), struct spa_pod);
|
||||
memcpy(p->param, param, SPA_POD_SIZE(param));
|
||||
SPA_POD_OBJECT_ID(p->param) = id;
|
||||
|
||||
if (id == SPA_PARAM_Buffers &&
|
||||
SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_MAP_BUFFERS) &&
|
||||
impl->direction == SPA_DIRECTION_INPUT)
|
||||
fix_datatype(p->param);
|
||||
|
||||
spa_list_append(&impl->param_list, &p->link);
|
||||
|
||||
if ((idx = get_param_index(id)) != -1) {
|
||||
|
|
|
@ -469,9 +469,7 @@ int pw_stream_set_error(struct pw_stream *stream, /**< a \ref pw_stream */
|
|||
/** Update the param exposed on the stream. */
|
||||
int
|
||||
pw_stream_update_params(struct pw_stream *stream, /**< a \ref pw_stream */
|
||||
const struct spa_pod **params, /**< an array of params. The params should
|
||||
* ideally contain parameters for doing
|
||||
* buffer allocation. */
|
||||
const struct spa_pod **params, /**< an array of params. */
|
||||
uint32_t n_params /**< number of elements in \a params */);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue