}
pa_cvolume_ramp_int* pa_cvolume_ramp_convert(const pa_cvolume_ramp *src, pa_cvolume_ramp_int *dst, int sample_rate) {
- int i;
+
+ int i, j, channels, remaining_channels;
float temp;
- for (i = 0; i < dst->channels; i++) {
+ if (dst->channels < src->channels) {
+ channels = dst->channels;
+ remaining_channels = 0;
+ }
+ else {
+ channels = src->channels;
+ remaining_channels = dst->channels;
+ }
+
+ for (i = 0; i < channels; i++) {
dst->ramps[i].type = src->ramps[i].type;
/* ms to samples */
dst->ramps[i].length = src->ramps[i].length * sample_rate / 1000;
dst->ramps[i].end = temp * temp * temp;
}
+ j = i;
+
+ for (i--; j < remaining_channels; j++) {
+ dst->ramps[j].type = dst->ramps[i].type;
+ dst->ramps[j].length = dst->ramps[i].length;
+ dst->ramps[j].left = dst->ramps[i].left;
+ dst->ramps[j].start = dst->ramps[i].start;
+ dst->ramps[j].target = dst->ramps[i].target;
+ dst->ramps[j].end = dst->ramps[i].end;
+ }
+
return dst;
}
i->userdata = NULL;
if (data->flags & PA_SINK_INPUT_START_RAMP_MUTED)
- pa_cvolume_ramp_int_init(&i->ramp, PA_VOLUME_MUTED, data->sample_spec.channels);
+ pa_cvolume_ramp_int_init(&i->ramp, PA_VOLUME_MUTED, data->sink->sample_spec.channels);
else
- pa_cvolume_ramp_int_init(&i->ramp, PA_VOLUME_NORM, data->sample_spec.channels);
+ pa_cvolume_ramp_int_init(&i->ramp, PA_VOLUME_NORM, data->sink->sample_spec.channels);
i->thread_info.state = i->state;
i->thread_info.attached = false;
return 0;
case PA_SINK_INPUT_MESSAGE_SET_VOLUME_RAMP:
- if (!pa_cvolume_ramp_equal(&i->thread_info.ramp, &i->ramp)) {
- /* we have ongoing ramp where we take current start values */
- pa_cvolume_ramp_start_from(&i->thread_info.ramp, &i->ramp);
- i->thread_info.ramp = i->ramp;
- pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
- }
+ /* we have ongoing ramp where we take current start values */
+ pa_cvolume_ramp_start_from(&i->thread_info.ramp, &i->ramp);
+ i->thread_info.ramp = i->ramp;
+ pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
return 0;
case PA_SINK_INPUT_MESSAGE_SET_SOFT_MUTE:
return 0;
case PA_SINK_MESSAGE_SET_VOLUME_RAMP:
- if (!pa_cvolume_ramp_equal(&s->thread_info.ramp, &s->ramp)) {
- /* if we have ongoing ramp where we take current start values */
- pa_cvolume_ramp_start_from(&s->thread_info.ramp, &s->ramp);
- s->thread_info.ramp = s->ramp;
- pa_sink_request_rewind(s, (size_t) -1);
- }
+ /* if we have ongoing ramp where we take current start values */
+ pa_cvolume_ramp_start_from(&s->thread_info.ramp, &s->ramp);
+ s->thread_info.ramp = s->ramp;
+ pa_sink_request_rewind(s, (size_t) -1);
return 0;
case PA_SINK_MESSAGE_GET_VOLUME: