[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-498-gd802a76
Lennart Poettering
gitmailer-noreply at 0pointer.de
Wed Feb 4 09:34:17 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 f6ec971e887e68ba74fb7132dcedddc9b6f2b2db (commit)
- Log -----------------------------------------------------------------
d802a76... remove soft volume from pa_sink_input_new_info since it should be handled internally and automatically by the sink input
b2c923e... properly handle failing stream creation
786398d... fix a validity check
1db6478... version all entries in the database
4cf82c7... merge in properties earlier to make identification of streams from hooks easier
-----------------------------------------------------------------------
Summary of changes:
src/modules/module-card-restore.c | 13 ++++-
src/modules/module-device-restore.c | 15 +++++-
src/modules/module-position-event-sounds.c | 12 ++--
src/modules/module-stream-restore.c | 73 ++++++++++++++++-----------
src/pulsecore/play-memblockq.c | 2 +-
src/pulsecore/protocol-native.c | 10 ++--
src/pulsecore/sink-input.c | 72 +++++++++++----------------
src/pulsecore/sink-input.h | 9 ++--
src/pulsecore/sound-file-stream.c | 2 +-
src/pulsecore/source-output.c | 6 +-
10 files changed, 116 insertions(+), 98 deletions(-)
-----------------------------------------------------------------------
commit 4cf82c74a1401dc5fa678b1367daa71242536d4b
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 4 18:28:52 2009 +0100
merge in properties earlier to make identification of streams from hooks easier
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index fc87d5d..71642bb 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -136,6 +136,9 @@ int pa_sink_input_new(
pa_assert(core);
pa_assert(data);
+ if (data->client)
+ pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->client->proplist);
+
if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], data)) < 0)
return r;
@@ -224,9 +227,6 @@ int pa_sink_input_new(
pa_return_val_if_fail(data->resample_method < PA_RESAMPLER_MAX, -PA_ERR_INVALID);
- if (data->client)
- pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->client->proplist);
-
if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], data)) < 0)
return r;
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index c5cb16d..63d56d5 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -110,6 +110,9 @@ int pa_source_output_new(
pa_assert(core);
pa_assert(data);
+ if (data->client)
+ pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->client->proplist);
+
if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], data)) < 0)
return r;
@@ -159,9 +162,6 @@ int pa_source_output_new(
pa_return_val_if_fail(data->resample_method < PA_RESAMPLER_MAX, -PA_ERR_INVALID);
- if (data->client)
- pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->client->proplist);
-
if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE], data)) < 0)
return r;
commit 1db64781bf514e6bb04685d428ecb6347af23ce9
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 4 18:31:24 2009 +0100
version all entries in the database
diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 02e973c..4dffd36 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -68,7 +68,10 @@ struct userdata {
GDBM_FILE gdbm_file;
};
-struct entry {
+#define ENTRY_VERSION 1
+
+struct entry PA_GCC_PACKED {
+ uint8_t version;
char profile[PA_NAME_MAX];
};
@@ -104,12 +107,17 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
goto fail;
if (data.dsize != sizeof(struct entry)) {
- pa_log_warn("Database contains entry for card %s of wrong size %lu != %lu", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
+ pa_log_debug("Database contains entry for card %s of wrong size %lu != %lu. Probably due to upgrade, ignoring.", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
goto fail;
}
e = (struct entry*) data.dptr;
+ if (e->version != ENTRY_VERSION) {
+ pa_log_debug("Version of database entry for card %s doesn't match our version. Probably due to upgrade, ignoring.", name);
+ goto fail;
+ }
+
if (!memchr(e->profile, 0, sizeof(e->profile))) {
pa_log_warn("Database contains entry for card %s with missing NUL byte in profile name", name);
goto fail;
@@ -148,6 +156,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
return;
memset(&entry, 0, sizeof(entry));
+ entry.version = ENTRY_VERSION;
if (!(card = pa_idxset_get_by_index(c->cards, idx)))
return;
diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
index 8e0cf92..7c56c24 100644
--- a/src/modules/module-device-restore.c
+++ b/src/modules/module-device-restore.c
@@ -79,10 +79,13 @@ struct userdata {
pa_bool_t restore_muted:1;
};
-struct entry {
+#define ENTRY_VERSION 1
+
+struct entry PA_GCC_PACKED {
+ uint8_t version;
+ pa_bool_t muted:1;
pa_channel_map channel_map;
pa_cvolume volume;
- pa_bool_t muted:1;
};
static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) {
@@ -117,12 +120,17 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
goto fail;
if (data.dsize != sizeof(struct entry)) {
- pa_log_warn("Database contains entry for device %s of wrong size %lu != %lu", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
+ pa_log_debug("Database contains entry for device %s of wrong size %lu != %lu. Probably due to upgrade, ignoring.", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
goto fail;
}
e = (struct entry*) data.dptr;
+ if (e->version != ENTRY_VERSION) {
+ pa_log_debug("Version of database entry for device %s doesn't match our version. Probably due to upgrade, ignoring.", name);
+ goto fail;
+ }
+
if (!(pa_cvolume_valid(&e->volume))) {
pa_log_warn("Invalid volume stored in database for device %s", name);
goto fail;
@@ -173,6 +181,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
return;
memset(&entry, 0, sizeof(entry));
+ entry.version = ENTRY_VERSION;
if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK) {
pa_sink *sink;
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 0c9bd4f..1444192 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -90,16 +90,18 @@ struct userdata {
pa_idxset *subscribed;
};
-struct entry {
+#define ENTRY_VERSION 1
+
+struct entry PA_GCC_PACKED {
+ uint8_t version;
+ pa_bool_t muted_valid:1, relative_volume_valid:1, absolute_volume_valid:1, device_valid:1;
+ pa_bool_t muted:1;
pa_channel_map channel_map;
- char device[PA_NAME_MAX];
pa_cvolume relative_volume;
pa_cvolume absolute_volume;
- pa_bool_t muted:1;
- pa_bool_t device_valid:1, relative_volume_valid:1, absolute_volume_valid:1, muted_valid:1;
+ char device[PA_NAME_MAX];
};
-
enum {
SUBCOMMAND_TEST,
SUBCOMMAND_READ,
@@ -161,19 +163,19 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
if (data.dsize != sizeof(struct entry)) {
/* This is probably just a database upgrade, hence let's not
* consider this more than a debug message */
- pa_log_debug("Database contains entry for stream %s of wrong size %lu != %lu", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
+ pa_log_debug("Database contains entry for stream %s of wrong size %lu != %lu. Probably due to uprade, ignoring.", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
goto fail;
}
e = (struct entry*) data.dptr;
- if (!memchr(e->device, 0, sizeof(e->device))) {
- pa_log_warn("Database contains entry for stream %s with missing NUL byte in device name", name);
+ if (e->version != ENTRY_VERSION) {
+ pa_log_debug("Version of database entry for stream %s doesn't match our version. Probably due to upgrade, ignoring.", name);
goto fail;
}
- if (!(pa_channel_map_valid(&e->channel_map))) {
- pa_log_warn("Invalid channel map stored in database for stream %s", name);
+ if (!memchr(e->device, 0, sizeof(e->device))) {
+ pa_log_warn("Database contains entry for stream %s with missing NUL byte in device name", name);
goto fail;
}
@@ -182,6 +184,11 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
goto fail;
}
+ if ((e->relative_volume_valid || e->absolute_volume_valid) && !(pa_channel_map_valid(&e->channel_map))) {
+ pa_log_warn("Invalid channel map stored in database for stream %s", name);
+ goto fail;
+ }
+
if ((e->relative_volume_valid && (!pa_cvolume_valid(&e->relative_volume) || e->relative_volume.channels != e->channel_map.channels)) ||
(e->absolute_volume_valid && (!pa_cvolume_valid(&e->absolute_volume) || e->absolute_volume.channels != e->channel_map.channels))) {
pa_log_warn("Invalid volume stored in database for stream %s", name);
@@ -265,6 +272,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
return;
memset(&entry, 0, sizeof(entry));
+ entry.version = ENTRY_VERSION;
if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK_INPUT) {
pa_sink_input *sink_input;
@@ -697,6 +705,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
int k;
memset(&entry, 0, sizeof(entry));
+ entry.version = ENTRY_VERSION;
if (pa_tagstruct_gets(t, &name) < 0 ||
pa_tagstruct_get_channel_map(t, &entry.channel_map) ||
commit 786398dc6312263ec4a14abd474fd0fd3def1ea4
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 4 18:32:15 2009 +0100
fix a validity check
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 1444192..65cdcbe 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -240,7 +240,7 @@ static pa_bool_t entries_equal(const struct entry *a, const struct entry *b) {
return FALSE;
if (a->muted_valid != b->muted_valid ||
- (a->muted && (a->muted != b->muted)))
+ (a->muted_valid && (a->muted != b->muted)))
return FALSE;
t = b->relative_volume;
commit b2c923e727f302a9e9c3a33f74a707cb47944a77
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 4 18:33:01 2009 +0100
properly handle failing stream creation
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 21a2cfb..0931854 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -595,7 +595,7 @@ static record_stream* record_stream_new(
int *ret) {
record_stream *s;
- pa_source_output *source_output;
+ pa_source_output *source_output = NULL;
size_t base;
pa_source_output_new_data data;
@@ -618,7 +618,7 @@ static record_stream* record_stream_new(
if (peak_detect)
data.resample_method = PA_RESAMPLER_PEAKS;
- *ret = pa_source_output_new(&source_output, c->protocol->core, &data, flags);
+ *ret = -pa_source_output_new(&source_output, c->protocol->core, &data, flags);
pa_source_output_new_data_done(&data);
@@ -971,7 +971,7 @@ static playback_stream* playback_stream_new(
int *ret) {
playback_stream *s, *ssync;
- pa_sink_input *sink_input;
+ pa_sink_input *sink_input = NULL;
pa_memchunk silence;
uint32_t idx;
int64_t start_index;
@@ -1023,7 +1023,7 @@ static playback_stream* playback_stream_new(
pa_sink_input_new_data_set_muted(&data, muted);
data.sync_base = ssync ? ssync->sink_input : NULL;
- *ret = pa_sink_input_new(&sink_input, c->protocol->core, &data, flags);
+ *ret = -pa_sink_input_new(&sink_input, c->protocol->core, &data, flags);
pa_sink_input_new_data_done(&data);
commit d802a76963e32bd821edfa89d6fe39764f1942f6
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 4 18:34:08 2009 +0100
remove soft volume from pa_sink_input_new_info since it should be handled internally and automatically by the sink input
diff --git a/src/modules/module-position-event-sounds.c b/src/modules/module-position-event-sounds.c
index 8e4f4c3..e17cbe8 100644
--- a/src/modules/module-position-event-sounds.c
+++ b/src/modules/module-position-event-sounds.c
@@ -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;
}
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 65cdcbe..b1630fe 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -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;
diff --git a/src/pulsecore/play-memblockq.c b/src/pulsecore/play-memblockq.c
index d163126..44aa6bf 100644
--- a/src/pulsecore/play-memblockq.c
+++ b/src/pulsecore/play-memblockq.c
@@ -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);
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 0931854..39c834d 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -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;
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 71642bb..df42cae 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -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);
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index d82a3a6..f6c5aa1 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -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);
diff --git a/src/pulsecore/sound-file-stream.c b/src/pulsecore/sound-file-stream.c
index 67b072b..c3de306 100644
--- a/src/pulsecore/sound-file-stream.c
+++ b/src/pulsecore/sound-file-stream.c
@@ -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);
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list