mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
stream: expose pw_stream_set_param()
Add a new pw_stream_set_param() method to configure a param on the adapter. This can be used to override the volume param for the adapter, for example.
This commit is contained in:
parent
bf1b3bb157
commit
680f12e437
2 changed files with 33 additions and 11 deletions
|
|
@ -156,7 +156,7 @@ struct stream {
|
|||
unsigned int driving:1;
|
||||
unsigned int using_trigger:1;
|
||||
unsigned int trigger:1;
|
||||
int in_set_control;
|
||||
int in_set_param;
|
||||
};
|
||||
|
||||
static int get_param_index(uint32_t id)
|
||||
|
|
@ -566,7 +566,7 @@ static int impl_set_param(void *object, uint32_t id, uint32_t flags, const struc
|
|||
if (id != SPA_PARAM_Props)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (impl->in_set_control == 0)
|
||||
if (impl->in_set_param == 0)
|
||||
pw_stream_emit_param_changed(stream, id, param);
|
||||
|
||||
return 0;
|
||||
|
|
@ -2138,6 +2138,27 @@ int pw_stream_update_params(struct pw_stream *stream,
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline int stream_set_param(struct stream *impl, uint32_t id, const struct spa_pod *param)
|
||||
{
|
||||
int res = 0;
|
||||
impl->in_set_param++;
|
||||
res = pw_impl_node_set_param(impl->node, id, 0, param);
|
||||
impl->in_set_param--;
|
||||
return res;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_stream_set_param(struct pw_stream *stream, uint32_t id, const struct spa_pod *param)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
ensure_loop(impl->context->main_loop, return -EIO);
|
||||
|
||||
if (impl->node == NULL)
|
||||
return -EIO;
|
||||
|
||||
return stream_set_param(impl, id, param);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_stream_set_control(struct pw_stream *stream, uint32_t id, uint32_t n_values, float *values, ...)
|
||||
{
|
||||
|
|
@ -2194,9 +2215,7 @@ int pw_stream_set_control(struct pw_stream *stream, uint32_t id, uint32_t n_valu
|
|||
|
||||
va_end(varargs);
|
||||
|
||||
impl->in_set_control++;
|
||||
pw_impl_node_set_param(impl->node, SPA_PARAM_Props, 0, pod);
|
||||
impl->in_set_control--;
|
||||
stream_set_param(impl, SPA_PARAM_Props, pod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -447,12 +447,7 @@ int pw_stream_set_error(struct pw_stream *stream, /**< a \ref pw_stream */
|
|||
const char *error, /**< an error message */
|
||||
...) SPA_PRINTF_FUNC(3, 4);
|
||||
|
||||
/** Complete the negotiation process with result code \a res
|
||||
*
|
||||
* This function should be called after notification of the format.
|
||||
|
||||
* When \a res indicates success, \a params contain the parameters for the
|
||||
* allocation state. */
|
||||
/** 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
|
||||
|
|
@ -460,6 +455,14 @@ pw_stream_update_params(struct pw_stream *stream, /**< a \ref pw_stream */
|
|||
* buffer allocation. */
|
||||
uint32_t n_params /**< number of elements in \a params */);
|
||||
|
||||
/**
|
||||
* Set a parameter on the stream. This is like pw_stream_set_control() but with
|
||||
* a complete spa_pod param. It can also be called from the param_changed event handler
|
||||
* to intercept and modify the param for the adapter. Since 0.3.70 */
|
||||
int pw_stream_set_param(struct pw_stream *stream, /**< a \ref pw_stream */
|
||||
uint32_t id, /**< the id of the param */
|
||||
const struct spa_pod *param /**< the params to set */);
|
||||
|
||||
/** Get control values */
|
||||
const struct pw_stream_control *pw_stream_get_control(struct pw_stream *stream, uint32_t id);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue