summaryrefslogtreecommitdiff
path: root/src/modules/module-stream-restore.c
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2020-05-26 15:04:59 +0300
committerGeorg Chini <georg@chini.tk>2020-06-01 18:24:16 +0000
commit1fe37e6d4bd5b2d183244538b250dae82ea27d47 (patch)
tree71cb99c26c1bf7d8c92204cde6a97d73571efce8 /src/modules/module-stream-restore.c
parent2ac2b445fcb81a3e6439e94cdefc2a482eab4fd1 (diff)
downloadpulseaudio-1fe37e6d4bd5b2d183244538b250dae82ea27d47.tar.gz
stream-restore: Forget pre-14.0 stream routing
Prior to commits f899d5f4669dcd536cc142cee99fe359dd8af3d6 and f62a49b8cf109c011a9818d2358beb6834e6ec25, GNOME's sound settings overwrote the routing for all entries in the stream-restore database when selecting a device. Now we prevent that from happening (see the aforementioned commits), but the old overwritten settings can still be in the database after updating to PulseAudio 14.0, and they can cause problems, as documented here: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/832 We can't distinguish between devices set by GNOME's sound settings and devices set by the user, so this patch discards all old device settings, even though that is going to cause PulseAudio to forget routing settings for many users. This is less bad than keeping the incorrect routing settings in the database, because it's difficult for users to figure out how to fix the situation when e.g. speaker test tones go to the internal speakers no matter what device is selected as the default, whereas old manual configuration can be restored restored by doing the manual configuration again. Also, it's probably more common to have at some point changed the default device in GNOME's sound settings than it is to have any manual per-stream routing settings. This is disabled by default, because this causes data loss, but distributions that use GNOME are recommended to enable this with the --enable-stream-restore-clear-old-devices (Autotools) or -Dstream-restore-clear-old-devices=true (Meson) build option. Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/832
Diffstat (limited to 'src/modules/module-stream-restore.c')
-rw-r--r--src/modules/module-stream-restore.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index a86e6bc31..a3c76714c 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -113,7 +113,7 @@ struct userdata {
#endif
};
-#define ENTRY_VERSION 1
+#define ENTRY_VERSION 2
struct entry {
bool muted_valid, volume_valid, device_valid, card_valid;
@@ -1167,6 +1167,46 @@ static struct entry *entry_read(struct userdata *u, const char *name) {
pa_tagstruct_free(t);
pa_datum_free(&data);
+#ifdef STREAM_RESTORE_CLEAR_OLD_DEVICES
+ if (version < ENTRY_VERSION && e->device_valid) {
+ /* Prior to PulseAudio 14.0, GNOME's sound settings overwrote the
+ * routing for all entries in the stream-restore database when
+ * selecting a device. PulseAudio 14.0 prevents that from happening,
+ * but the old overwritten settings can still be in the database after
+ * updating to PulseAudio 14.0, and they can cause problems, as
+ * documented here:
+ * https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/832
+ *
+ * We can't distinguish between devices set by GNOME's sound settings
+ * and devices set by the user, so we discard all old device settings,
+ * even though that is going to cause PulseAudio to forget routing
+ * settings for many users. This is less bad than keeping the incorrect
+ * routing settings in the database, because it's difficult for users
+ * to figure out how to fix the situation when e.g. speaker test tones
+ * go to the internal speakers no matter what device is selected as the
+ * default, whereas old manual configuration can be restored restored
+ * by doing the manual configuration again. Also, it's probably more
+ * common to have at some point changed the default device in GNOME's
+ * sound settings than it is to have any manual per-stream routing
+ * settings. */
+ pa_log_warn("Device set, but it might be incorrect. Clearing the device. If this messes up your manual stream "
+ "routing configuration, sorry about that. This is a workaround for this bug: "
+ "https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/832");
+ pa_log_warn("%s: device: %s -> (unset)", name, e->device);
+ pa_xfree(e->device);
+ e->device = NULL;
+ e->device_valid = false;
+ if (e->card_valid) {
+ pa_log_warn("%s: card: %s -> (unset)", name, e->card);
+ pa_xfree(e->card);
+ e->card = NULL;
+ e->card_valid = false;
+ }
+ entry_write(u, name, e, true);
+ trigger_save(u);
+ }
+#endif
+
return e;
fail: