[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-test1-5-gf6ffd2d
Lennart Poettering
gitmailer-noreply at 0pointer.de
Wed Feb 4 16:23:01 PST 2009
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from 3fc12330627488ab7632d501e3976769275cf709 (commit)
- Log -----------------------------------------------------------------
f6ffd2d... make module-position-event-sounds use volume factor
de86c6e... add a 'volume factor' that is implicitly multiplied into the volume of a sink input without being visible to the outside
-----------------------------------------------------------------------
Summary of changes:
src/modules/module-position-event-sounds.c | 15 +++++----------
src/pulsecore/sink-input.c | 27 ++++++++++++++++++++++-----
src/pulsecore/sink-input.h | 7 ++++---
src/pulsecore/sink.c | 1 +
4 files changed, 32 insertions(+), 18 deletions(-)
-----------------------------------------------------------------------
commit de86c6e3ade17c3b29fd57afb47efb3a88a423d4
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 5 01:22:05 2009 +0100
add a 'volume factor' that is implicitly multiplied into the volume of a sink input without being visible to the outside
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index df42cae..37d40eb 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -79,6 +79,18 @@ void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cv
data->volume = *volume;
}
+void pa_sink_input_new_data_apply_volume_factor(pa_sink_input_new_data *data, const pa_cvolume *volume_factor) {
+ pa_assert(data);
+ pa_assert(volume_factor);
+
+ if (data->volume_factor_is_set)
+ pa_sw_cvolume_multiply(&data->volume_factor, &data->volume_factor, volume_factor);
+ else {
+ data->volume_factor_is_set = TRUE;
+ data->volume_factor = *volume_factor;
+ }
+}
+
void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute) {
pa_assert(data);
@@ -171,12 +183,17 @@ int pa_sink_input_new(
pa_cvolume_reset(&data->volume, data->sample_spec.channels);
data->save_volume = FALSE;
-
}
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->volume_factor_is_set)
+ pa_cvolume_reset(&data->volume_factor, data->sample_spec.channels);
+
+ pa_return_val_if_fail(pa_cvolume_valid(&data->volume_factor), -PA_ERR_INVALID);
+ pa_return_val_if_fail(pa_cvolume_compatible(&data->volume_factor, &data->sample_spec), -PA_ERR_INVALID);
+
if (!data->muted_is_set)
data->muted = FALSE;
@@ -259,6 +276,7 @@ int pa_sink_input_new(
} else
i->virtual_volume = data->volume;
+ i->volume_factor = data->volume_factor;
pa_cvolume_init(&i->soft_volume);
i->save_volume = data->save_volume;
i->save_sink = data->save_sink;
@@ -500,7 +518,7 @@ void pa_sink_input_put(pa_sink_input *i) {
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;
+ pa_sw_cvolume_multiply(&i->soft_volume, &i->virtual_volume, &i->volume_factor);
i->thread_info.soft_volume = i->soft_volume;
i->thread_info.muted = i->muted;
@@ -874,8 +892,7 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, pa_boo
/* OK, we are in normal volume mode. The volume only affects
* ourselves */
-
- i->soft_volume = *volume;
+ pa_sw_cvolume_multiply(&i->soft_volume, volume, &i->volume_factor);
/* Hooks have the ability to play games with i->soft_volume */
pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_SET_VOLUME], i);
@@ -1066,7 +1083,7 @@ int pa_sink_input_start_move(pa_sink_input *i) {
/* Make the absolute volume relative */
i->virtual_volume = i->soft_volume;
- pa_cvolume_reset(&i->soft_volume, i->sample_spec.channels);
+ i->soft_volume = i->volume_factor;
/* We might need to update the sink's volume if we are in flat
* volume mode. */
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index f6c5aa1..889ee84 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -91,7 +91,7 @@ struct pa_sink_input {
pa_sink_input *sync_prev, *sync_next;
- pa_cvolume virtual_volume, soft_volume;
+ pa_cvolume virtual_volume, soft_volume, volume_factor;
pa_bool_t muted:1;
/* if TRUE then the source we are connected to and/or the volume
@@ -233,13 +233,13 @@ typedef struct pa_sink_input_new_data {
pa_sample_spec sample_spec;
pa_channel_map channel_map;
- pa_cvolume volume;
+ pa_cvolume volume, volume_factor;
pa_bool_t muted:1;
pa_bool_t sample_spec_is_set:1;
pa_bool_t channel_map_is_set:1;
- pa_bool_t volume_is_set:1;
+ pa_bool_t volume_is_set:1, volume_factor_is_set:1;
pa_bool_t muted_is_set:1;
pa_bool_t volume_is_absolute:1;
@@ -251,6 +251,7 @@ 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_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
+void pa_sink_input_new_data_apply_volume_factor(pa_sink_input_new_data *data, const pa_cvolume *volume_factor);
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);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 0c297ec..5772587 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -990,6 +990,7 @@ void pa_sink_update_flat_volume(pa_sink *s, pa_cvolume *new_volume) {
remapped_new_volume = *new_volume;
pa_cvolume_remap(&remapped_new_volume, &s->channel_map, &i->channel_map);
pa_sw_cvolume_divide(&i->soft_volume, &i->virtual_volume, &remapped_new_volume);
+ pa_sw_cvolume_multiply(&i->soft_volume, &i->soft_volume, &i->volume_factor);
/* Hooks have the ability to play games with i->soft_volume */
pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_INPUT_SET_VOLUME], i);
commit f6ffd2dd5a019e6ea5b2cbd1d19c3a4417043e59
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 5 01:22:57 2009 +0100
make module-position-event-sounds use volume factor
diff --git a/src/modules/module-position-event-sounds.c b/src/modules/module-position-event-sounds.c
index e17cbe8..6252eba 100644
--- a/src/modules/module-position-event-sounds.c
+++ b/src/modules/module-position-event-sounds.c
@@ -54,7 +54,6 @@ static const char* const valid_modargs[] = {
};
struct userdata {
- pa_core *core;
pa_hook_slot *sink_input_fixate_hook_slot;
};
@@ -62,6 +61,7 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *core, pa_sink_i
const char *hpos;
double f;
char t[PA_CVOLUME_SNPRINT_MAX];
+ pa_cvolume v;
pa_assert(data);
@@ -80,16 +80,12 @@ 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->volume_is_set) {
- pa_cvolume_reset(&data->volume, data->sample_spec.channels);
- data->volume_is_set = TRUE;
- data->volume_is_absolute = FALSE;
- }
+ pa_cvolume_reset(&v, data->sample_spec.channels);
+ pa_cvolume_set_balance(&v, &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 factor %s.", pa_cvolume_snprint(t, sizeof(t), &v));
- pa_log_debug("Final volume %s.", pa_cvolume_snprint(t, sizeof(t), &data->volume));
+ pa_sink_input_new_data_apply_volume_factor(data, &v);
return PA_HOOK_OK;
}
@@ -106,7 +102,6 @@ int pa__init(pa_module*m) {
}
m->userdata = u = pa_xnew(struct userdata, 1);
- u->core = m->core;
u->sink_input_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_fixate_hook_callback, u);
pa_modargs_free(ma);
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list