mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
remove soft volume from pa_sink_input_new_info since it should be handled internally and automatically by the sink input
This commit is contained in:
parent
b2c923e727
commit
d802a76963
7 changed files with 63 additions and 72 deletions
|
|
@ -80,16 +80,16 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *core, pa_sink_i
|
|||
|
||||
pa_log_debug("Positioning event sound '%s' at %0.2f.", pa_strnull(pa_proplist_gets(data->proplist, PA_PROP_EVENT_ID)), f);
|
||||
|
||||
if (!data->virtual_volume_is_set) {
|
||||
pa_cvolume_reset(&data->virtual_volume, data->sample_spec.channels);
|
||||
data->virtual_volume_is_set = TRUE;
|
||||
data->virtual_volume_is_absolute = FALSE;
|
||||
if (!data->volume_is_set) {
|
||||
pa_cvolume_reset(&data->volume, data->sample_spec.channels);
|
||||
data->volume_is_set = TRUE;
|
||||
data->volume_is_absolute = FALSE;
|
||||
}
|
||||
|
||||
pa_cvolume_set_balance(&data->virtual_volume, &data->channel_map, f*2.0-1.0);
|
||||
pa_cvolume_set_balance(&data->volume, &data->channel_map, f*2.0-1.0);
|
||||
data->save_volume = FALSE;
|
||||
|
||||
pa_log_debug("Final volume %s.", pa_cvolume_snprint(t, sizeof(t), &data->virtual_volume));
|
||||
pa_log_debug("Final volume %s.", pa_cvolume_snprint(t, sizeof(t), &data->volume));
|
||||
|
||||
return PA_HOOK_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -396,32 +396,33 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
|
|||
|
||||
if (u->restore_volume) {
|
||||
|
||||
if (!new_data->virtual_volume_is_set) {
|
||||
if (!new_data->volume_is_set) {
|
||||
pa_cvolume v;
|
||||
pa_cvolume_init(&v);
|
||||
|
||||
if (new_data->sink->flags & PA_SINK_FLAT_VOLUME) {
|
||||
|
||||
/* We don't check for e->device_valid here because
|
||||
that bit marks whether it is a good choice for
|
||||
restoring, not just if the data is filled in. */
|
||||
if (e->absolute_volume_valid &&
|
||||
e->device_valid &&
|
||||
pa_streq(new_data->sink->name, e->device)) {
|
||||
(e->device[0] == 0 || pa_streq(new_data->sink->name, e->device))) {
|
||||
|
||||
v = e->absolute_volume;
|
||||
new_data->virtual_volume_is_absolute = TRUE;
|
||||
new_data->volume_is_absolute = TRUE;
|
||||
} else if (e->relative_volume_valid) {
|
||||
|
||||
v = e->relative_volume;
|
||||
new_data->virtual_volume_is_absolute = FALSE;
|
||||
new_data->volume_is_absolute = FALSE;
|
||||
}
|
||||
|
||||
} else if (e->relative_volume_valid) {
|
||||
v = e->relative_volume;
|
||||
new_data->virtual_volume_is_absolute = FALSE;
|
||||
new_data->volume_is_absolute = FALSE;
|
||||
}
|
||||
|
||||
if (v.channels > 0) {
|
||||
pa_log_info("Restoring volume for sink input %s.", name);
|
||||
pa_sink_input_new_data_set_virtual_volume(new_data, pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map));
|
||||
pa_sink_input_new_data_set_volume(new_data, pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map));
|
||||
new_data->save_volume = TRUE;
|
||||
}
|
||||
} else
|
||||
|
|
@ -531,11 +532,10 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
|
|||
if (si->sink->flags & PA_SINK_FLAT_VOLUME) {
|
||||
|
||||
if (e->absolute_volume_valid &&
|
||||
e->device_valid &&
|
||||
pa_streq(e->device, si->sink->name))
|
||||
(e->device[0] == 0 || pa_streq(e->device, si->sink->name)))
|
||||
v = e->absolute_volume;
|
||||
else if (e->relative_volume_valid) {
|
||||
pa_cvolume t = si->sink->virtual_volume;
|
||||
pa_cvolume t = *pa_sink_get_volume(si->sink, FALSE);
|
||||
pa_sw_cvolume_multiply(&v, &e->relative_volume, pa_cvolume_remap(&t, &si->sink->channel_map, &e->channel_map));
|
||||
}
|
||||
} else if (e->relative_volume_valid)
|
||||
|
|
@ -663,10 +663,11 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
|
||||
if ((e = read_entry(u, name))) {
|
||||
pa_cvolume r;
|
||||
pa_channel_map cm;
|
||||
|
||||
pa_tagstruct_puts(reply, name);
|
||||
pa_tagstruct_put_channel_map(reply, &e->channel_map);
|
||||
pa_tagstruct_put_cvolume(reply, e->relative_volume_valid ? &e->relative_volume : pa_cvolume_init(&r));
|
||||
pa_tagstruct_put_channel_map(reply, (e->relative_volume_valid || e->absolute_volume_valid) ? &e->channel_map : pa_channel_map_init(&cm));
|
||||
pa_tagstruct_put_cvolume(reply, e->absolute_volume_valid ? &e->absolute_volume : (e->relative_volume_valid ? &e->relative_volume : pa_cvolume_init(&r)));
|
||||
pa_tagstruct_puts(reply, e->device_valid ? e->device : NULL);
|
||||
pa_tagstruct_put_boolean(reply, e->muted_valid ? e->muted : FALSE);
|
||||
|
||||
|
|
@ -709,18 +710,21 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
|
||||
if (pa_tagstruct_gets(t, &name) < 0 ||
|
||||
pa_tagstruct_get_channel_map(t, &entry.channel_map) ||
|
||||
pa_tagstruct_get_cvolume(t, &entry.relative_volume) < 0 ||
|
||||
pa_tagstruct_get_cvolume(t, &entry.absolute_volume) < 0 ||
|
||||
pa_tagstruct_gets(t, &device) < 0 ||
|
||||
pa_tagstruct_get_boolean(t, &muted) < 0)
|
||||
goto fail;
|
||||
|
||||
entry.absolute_volume_valid = FALSE;
|
||||
entry.relative_volume_valid = entry.relative_volume.channels > 0;
|
||||
|
||||
if (entry.relative_volume_valid &&
|
||||
entry.channel_map.channels != entry.relative_volume.channels)
|
||||
if (!name || !*name)
|
||||
goto fail;
|
||||
|
||||
entry.relative_volume = entry.absolute_volume;
|
||||
entry.absolute_volume_valid = entry.relative_volume_valid = entry.relative_volume.channels > 0;
|
||||
|
||||
if (entry.relative_volume_valid)
|
||||
if (!pa_cvolume_compatible_with_channel_map(&entry.relative_volume, &entry.channel_map))
|
||||
goto fail;
|
||||
|
||||
entry.muted = muted;
|
||||
entry.muted_valid = TRUE;
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ pa_sink_input* pa_memblockq_sink_input_new(
|
|||
data.driver = __FILE__;
|
||||
pa_sink_input_new_data_set_sample_spec(&data, ss);
|
||||
pa_sink_input_new_data_set_channel_map(&data, map);
|
||||
pa_sink_input_new_data_set_virtual_volume(&data, volume);
|
||||
pa_sink_input_new_data_set_volume(&data, volume);
|
||||
pa_proplist_update(data.proplist, PA_UPDATE_REPLACE, p);
|
||||
|
||||
pa_sink_input_new(&u->sink_input, sink->core, &data, 0);
|
||||
|
|
|
|||
|
|
@ -1018,7 +1018,7 @@ static playback_stream* playback_stream_new(
|
|||
pa_sink_input_new_data_set_sample_spec(&data, ss);
|
||||
pa_sink_input_new_data_set_channel_map(&data, map);
|
||||
if (volume)
|
||||
pa_sink_input_new_data_set_virtual_volume(&data, volume);
|
||||
pa_sink_input_new_data_set_volume(&data, volume);
|
||||
if (muted_set)
|
||||
pa_sink_input_new_data_set_muted(&data, muted);
|
||||
data.sync_base = ssync ? ssync->sink_input : NULL;
|
||||
|
|
|
|||
|
|
@ -72,18 +72,11 @@ void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const
|
|||
data->channel_map = *map;
|
||||
}
|
||||
|
||||
void pa_sink_input_new_data_set_soft_volume(pa_sink_input_new_data *data, const pa_cvolume *volume) {
|
||||
void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume) {
|
||||
pa_assert(data);
|
||||
|
||||
if ((data->soft_volume_is_set = !!volume))
|
||||
data->soft_volume = *volume;
|
||||
}
|
||||
|
||||
void pa_sink_input_new_data_set_virtual_volume(pa_sink_input_new_data *data, const pa_cvolume *volume) {
|
||||
pa_assert(data);
|
||||
|
||||
if ((data->virtual_volume_is_set = !!volume))
|
||||
data->virtual_volume = *volume;
|
||||
if ((data->volume_is_set = !!volume))
|
||||
data->volume = *volume;
|
||||
}
|
||||
|
||||
void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute) {
|
||||
|
|
@ -169,35 +162,20 @@ int pa_sink_input_new(
|
|||
pa_return_val_if_fail(pa_channel_map_valid(&data->channel_map), -PA_ERR_INVALID);
|
||||
pa_return_val_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec), -PA_ERR_INVALID);
|
||||
|
||||
if (!data->virtual_volume_is_set) {
|
||||
if (!data->volume_is_set) {
|
||||
|
||||
if (data->sink->flags & PA_SINK_FLAT_VOLUME) {
|
||||
data->virtual_volume = data->sink->virtual_volume;
|
||||
pa_cvolume_remap(&data->virtual_volume, &data->sink->channel_map, &data->channel_map);
|
||||
data->volume = *pa_sink_get_volume(data->sink, FALSE);
|
||||
pa_cvolume_remap(&data->volume, &data->sink->channel_map, &data->channel_map);
|
||||
} else
|
||||
pa_cvolume_reset(&data->virtual_volume, data->sample_spec.channels);
|
||||
pa_cvolume_reset(&data->volume, data->sample_spec.channels);
|
||||
|
||||
data->save_volume = FALSE;
|
||||
|
||||
} else if (!data->virtual_volume_is_absolute) {
|
||||
|
||||
/* When the 'absolute' bool is set then we'll treat the volume
|
||||
* as relative to the sink volume even in flat volume mode */
|
||||
if (data->sink->flags & PA_SINK_FLAT_VOLUME) {
|
||||
pa_cvolume t = data->sink->virtual_volume;
|
||||
pa_cvolume_remap(&t, &data->sink->channel_map, &data->channel_map);
|
||||
pa_sw_cvolume_multiply(&data->virtual_volume, &data->virtual_volume, &t);
|
||||
}
|
||||
}
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_valid(&data->virtual_volume), -PA_ERR_INVALID);
|
||||
pa_return_val_if_fail(pa_cvolume_compatible(&data->virtual_volume, &data->sample_spec), -PA_ERR_INVALID);
|
||||
|
||||
if (!data->soft_volume_is_set)
|
||||
data->soft_volume = data->virtual_volume;
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_valid(&data->soft_volume), -PA_ERR_INVALID);
|
||||
pa_return_val_if_fail(pa_cvolume_compatible(&data->soft_volume, &data->sample_spec), -PA_ERR_INVALID);
|
||||
pa_return_val_if_fail(pa_cvolume_valid(&data->volume), -PA_ERR_INVALID);
|
||||
pa_return_val_if_fail(pa_cvolume_compatible(&data->volume, &data->sample_spec), -PA_ERR_INVALID);
|
||||
|
||||
if (!data->muted_is_set)
|
||||
data->muted = FALSE;
|
||||
|
|
@ -219,8 +197,7 @@ int pa_sink_input_new(
|
|||
pa_assert(pa_channel_map_valid(&data->channel_map));
|
||||
|
||||
/* Due to the fixing of the sample spec the volume might not match anymore */
|
||||
pa_cvolume_remap(&data->soft_volume, &original_cm, &data->channel_map);
|
||||
pa_cvolume_remap(&data->virtual_volume, &original_cm, &data->channel_map);
|
||||
pa_cvolume_remap(&data->volume, &original_cm, &data->channel_map);
|
||||
|
||||
if (data->resample_method == PA_RESAMPLER_INVALID)
|
||||
data->resample_method = core->resample_method;
|
||||
|
|
@ -271,8 +248,18 @@ int pa_sink_input_new(
|
|||
i->sample_spec = data->sample_spec;
|
||||
i->channel_map = data->channel_map;
|
||||
|
||||
i->virtual_volume = data->virtual_volume;
|
||||
i->soft_volume = data->soft_volume;
|
||||
if ((i->sink->flags & PA_SINK_FLAT_VOLUME) && !data->volume_is_absolute) {
|
||||
/* When the 'absolute' bool is not set then we'll treat the volume
|
||||
* as relative to the sink volume even in flat volume mode */
|
||||
|
||||
pa_cvolume t = *pa_sink_get_volume(data->sink, FALSE);
|
||||
pa_cvolume_remap(&t, &data->sink->channel_map, &data->channel_map);
|
||||
|
||||
pa_sw_cvolume_multiply(&i->virtual_volume, &data->volume, &t);
|
||||
} else
|
||||
i->virtual_volume = data->volume;
|
||||
|
||||
pa_cvolume_init(&i->soft_volume);
|
||||
i->save_volume = data->save_volume;
|
||||
i->save_sink = data->save_sink;
|
||||
i->save_muted = data->save_muted;
|
||||
|
|
@ -502,9 +489,6 @@ void pa_sink_input_put(pa_sink_input *i) {
|
|||
pa_assert(i->process_rewind);
|
||||
pa_assert(i->kill);
|
||||
|
||||
i->thread_info.soft_volume = i->soft_volume;
|
||||
i->thread_info.muted = i->muted;
|
||||
|
||||
state = i->flags & PA_SINK_INPUT_START_CORKED ? PA_SINK_INPUT_CORKED : PA_SINK_INPUT_RUNNING;
|
||||
|
||||
update_n_corked(i, state);
|
||||
|
|
@ -515,7 +499,11 @@ void pa_sink_input_put(pa_sink_input *i) {
|
|||
pa_cvolume new_volume;
|
||||
pa_sink_update_flat_volume(i->sink, &new_volume);
|
||||
pa_sink_set_volume(i->sink, &new_volume, FALSE, FALSE);
|
||||
}
|
||||
} else
|
||||
i->soft_volume = i->virtual_volume;
|
||||
|
||||
i->thread_info.soft_volume = i->soft_volume;
|
||||
i->thread_info.muted = i->muted;
|
||||
|
||||
pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i->sink), PA_SINK_MESSAGE_ADD_INPUT, i, 0, NULL) == 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -233,16 +233,16 @@ typedef struct pa_sink_input_new_data {
|
|||
pa_sample_spec sample_spec;
|
||||
pa_channel_map channel_map;
|
||||
|
||||
pa_cvolume virtual_volume, soft_volume;
|
||||
pa_cvolume volume;
|
||||
pa_bool_t muted:1;
|
||||
|
||||
pa_bool_t sample_spec_is_set:1;
|
||||
pa_bool_t channel_map_is_set:1;
|
||||
|
||||
pa_bool_t virtual_volume_is_set:1, soft_volume_is_set:1;
|
||||
pa_bool_t volume_is_set:1;
|
||||
pa_bool_t muted_is_set:1;
|
||||
|
||||
pa_bool_t virtual_volume_is_absolute:1;
|
||||
pa_bool_t volume_is_absolute:1;
|
||||
|
||||
pa_bool_t save_sink:1, save_volume:1, save_muted:1;
|
||||
} pa_sink_input_new_data;
|
||||
|
|
@ -250,8 +250,7 @@ typedef struct pa_sink_input_new_data {
|
|||
pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data);
|
||||
void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const pa_sample_spec *spec);
|
||||
void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map);
|
||||
void pa_sink_input_new_data_set_soft_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
|
||||
void pa_sink_input_new_data_set_virtual_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
|
||||
void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
|
||||
void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute);
|
||||
void pa_sink_input_new_data_done(pa_sink_input_new_data *data);
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ int pa_play_file(
|
|||
data.sink = sink;
|
||||
data.driver = __FILE__;
|
||||
pa_sink_input_new_data_set_sample_spec(&data, &ss);
|
||||
pa_sink_input_new_data_set_virtual_volume(&data, volume);
|
||||
pa_sink_input_new_data_set_volume(&data, volume);
|
||||
pa_proplist_sets(data.proplist, PA_PROP_MEDIA_NAME, pa_path_get_filename(fname));
|
||||
pa_proplist_sets(data.proplist, PA_PROP_MEDIA_FILENAME, fname);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue