mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
audioconvert: add a invalid value for scale
The invalid value here is zero, this will help avoid inadvertant parameter updates and brings this on par with rest of the volume ramp parameters
This commit is contained in:
parent
b61bf8a27d
commit
dcec2e785e
4 changed files with 16 additions and 14 deletions
|
|
@ -262,6 +262,7 @@ enum spa_audio_channel {
|
|||
};
|
||||
|
||||
enum spa_audio_volume_ramp_scale {
|
||||
SPA_AUDIO_VOLUME_RAMP_INVALID,
|
||||
SPA_AUDIO_VOLUME_RAMP_LINEAR,
|
||||
SPA_AUDIO_VOLUME_RAMP_CUBIC,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ static const struct spa_type_info spa_type_props[] = {
|
|||
{ SPA_PROP_volumeRampStepSamples, SPA_TYPE_Int, SPA_TYPE_INFO_PROPS_BASE "volumeRampStepSamples", NULL },
|
||||
{ SPA_PROP_volumeRampTime, SPA_TYPE_Int, SPA_TYPE_INFO_PROPS_BASE "volumeRampTime", NULL },
|
||||
{ SPA_PROP_volumeRampStepTime, SPA_TYPE_Int, SPA_TYPE_INFO_PROPS_BASE "volumeRampStepTime", NULL },
|
||||
{ SPA_PROP_volumeRampScale, SPA_TYPE_Id, SPA_TYPE_INFO_PROPS_BASE "volumeRampScale", NULL },
|
||||
{ SPA_PROP_mute, SPA_TYPE_Bool, SPA_TYPE_INFO_PROPS_BASE "mute", NULL },
|
||||
{ SPA_PROP_patternType, SPA_TYPE_Id, SPA_TYPE_INFO_PROPS_BASE "patternType", NULL },
|
||||
{ SPA_PROP_ditherType, SPA_TYPE_Id, SPA_TYPE_INFO_PROPS_BASE "ditherType", NULL },
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@ enum spa_prop {
|
|||
SPA_PROP_waveType,
|
||||
SPA_PROP_frequency,
|
||||
SPA_PROP_volume, /**< a volume (Float), 0.0 silence, 1.0 normal */
|
||||
SPA_PROP_volumeRampSamples, /**< Samples to ramp the volume over */
|
||||
SPA_PROP_volumeRampStepSamples, /**< Step or incremental Samples to ramp the volume over */
|
||||
SPA_PROP_volumeRampTime, /**< Time in millisec to ramp the volume over */
|
||||
SPA_PROP_volumeRampStepTime, /**< Step or incremental Time in nano seconds to ramp the */
|
||||
SPA_PROP_volumeRampScale, /**< the scale or graph to used to ramp the volume */
|
||||
SPA_PROP_mute, /**< mute (Bool) */
|
||||
SPA_PROP_patternType,
|
||||
SPA_PROP_ditherType,
|
||||
|
|
@ -95,6 +90,11 @@ enum spa_prop {
|
|||
SPA_PROP_exposure,
|
||||
SPA_PROP_gain,
|
||||
SPA_PROP_sharpness,
|
||||
SPA_PROP_volumeRampSamples, /**< Samples to ramp the volume over */
|
||||
SPA_PROP_volumeRampStepSamples, /**< Step or incremental Samples to ramp the volume over */
|
||||
SPA_PROP_volumeRampTime, /**< Time in millisec to ramp the volume over */
|
||||
SPA_PROP_volumeRampStepTime, /**< Step or incremental Time in nano seconds to ramp the */
|
||||
SPA_PROP_volumeRampScale, /**< the scale or graph to used to ramp the volume */
|
||||
|
||||
SPA_PROP_START_Other = 0x80000, /**< other properties */
|
||||
SPA_PROP_params, /**< simple control params
|
||||
|
|
|
|||
|
|
@ -904,7 +904,7 @@ static unsigned int get_ramp_step_samples(struct impl *this)
|
|||
static double get_volume_at_scale(struct impl *this, double value)
|
||||
{
|
||||
struct volume_ramp_params *vrp = &this->props.vrp;
|
||||
if (vrp->scale == SPA_AUDIO_VOLUME_RAMP_LINEAR)
|
||||
if (vrp->scale == SPA_AUDIO_VOLUME_RAMP_LINEAR || vrp->scale == SPA_AUDIO_VOLUME_RAMP_INVALID)
|
||||
return value;
|
||||
else if (vrp->scale == SPA_AUDIO_VOLUME_RAMP_CUBIC)
|
||||
return (value * value * value);
|
||||
|
|
@ -926,10 +926,10 @@ static struct spa_pod *generate_ramp_up_seq(struct impl *this)
|
|||
spa_pod_dynamic_builder_init(&b, NULL, 0, 4096);
|
||||
|
||||
spa_pod_builder_push_sequence(&b.b, &f[0], 0);
|
||||
spa_log_info(this->log, "generating ramp up sequence from %f to %f with a step value %f at scale %d",
|
||||
p->prev_volume,p->volume, volume_step, p->scale);
|
||||
spa_log_info(this->log, "generating ramp up sequence from %f to %f with a"
|
||||
" step value %f at scale %d", p->prev_volume, p->volume, volume_step, p->vrp.scale);
|
||||
do {
|
||||
spa_log_info(this->log, "volume accum %f", get_volume_at_scale(this, volume_accum));
|
||||
// spa_log_debug(this->log, "volume accum %f", get_volume_at_scale(this, volume_accum));
|
||||
spa_pod_builder_control(&b.b, volume_offs, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_add_object(&b.b,
|
||||
SPA_TYPE_OBJECT_Props, 0,
|
||||
|
|
@ -955,10 +955,10 @@ static struct spa_pod *generate_ramp_down_seq(struct impl *this)
|
|||
spa_pod_dynamic_builder_init(&b, NULL, 0, 4096);
|
||||
|
||||
spa_pod_builder_push_sequence(&b.b, &f[0], 0);
|
||||
spa_log_info(this->log, "generating ramp down sequence from %f to %f with a step value %f at scale %d",
|
||||
p->prev_volume, p->volume, volume_step, p->vrp.scale);
|
||||
spa_log_info(this->log, "generating ramp down sequence from %f to %f with a"
|
||||
" step value %f at scale %d", p->prev_volume, p->volume, volume_step, p->vrp.scale);
|
||||
do {
|
||||
spa_log_info(this->log, "volume accum %f", get_volume_at_scale(this, volume_accum));
|
||||
// spa_log_debug(this->log, "volume accum %f", get_volume_at_scale(this, volume_accum));
|
||||
spa_pod_builder_control(&b.b, volume_offs, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_add_object(&b.b,
|
||||
SPA_TYPE_OBJECT_Props, 0,
|
||||
|
|
@ -1069,7 +1069,7 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
|||
return -EAGAIN;
|
||||
}
|
||||
|
||||
if (spa_pod_get_id(&prop->value, &id) == 0) {
|
||||
if (spa_pod_get_id(&prop->value, &id) == 0 && id) {
|
||||
vrp->scale = id;
|
||||
spa_log_info(this->log, "%p volume ramp scale %d", this, id);
|
||||
}
|
||||
|
|
@ -1451,7 +1451,7 @@ static void set_volume(struct impl *this)
|
|||
float volumes[SPA_AUDIO_MAX_CHANNELS];
|
||||
struct dir *dir = &this->dir[this->direction];
|
||||
|
||||
spa_log_info(this->log, "%p set volume %f have_format:%d", this, this->props.volume, dir->have_format);
|
||||
spa_log_debug(this->log, "%p set volume %f have_format:%d", this, this->props.volume, dir->have_format);
|
||||
|
||||
if (dir->have_format)
|
||||
remap_volumes(this, &dir->format);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue