[pulseaudio-commits] [Git][pulseaudio/paprefs][master] 2 commits: Fix indentation
PulseAudio Marge Bot (@pulseaudio-merge-bot)
gitlab at gitlab.freedesktop.org
Wed Aug 25 16:11:46 UTC 2021
PulseAudio Marge Bot pushed to branch master at PulseAudio / paprefs
Commits:
4dadcc77 by Tanu Kaskinen at 2021-08-25T18:48:03+03:00
Fix indentation
Part-of: <https://gitlab.freedesktop.org/pulseaudio/paprefs/-/merge_requests/7>
- - - - -
880bc732 by Tanu Kaskinen at 2021-08-25T18:51:36+03:00
Update module directory logic
PulseAudio 16.0 will change the module directory, and this patch adds
support for the new directory in paprefs, while retaining compatibility
with older PulseAudio versions too.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/paprefs/-/merge_requests/7>
- - - - -
1 changed file:
- src/paprefs.cc
Changes:
=====================================
src/paprefs.cc
=====================================
@@ -335,10 +335,10 @@ void MainWindow::onChangeUpnp() {
}
void MainWindow::showInstallButton(Gtk::Button *button, bool available) {
- if (available || !packageKitAvailable)
- button->hide();
- else
- button->show();
+ if (available || !packageKitAvailable)
+ button->hide();
+ else
+ button->show();
}
void MainWindow::installFiles(const char *a, const char *b = NULL) {
@@ -370,16 +370,16 @@ void MainWindow::installFiles(const char *a, const char *b = NULL) {
}
void MainWindow::installModules(const char *a, const char *b = NULL) {
- gchar *ma, *mb = NULL;
+ gchar *ma, *mb = NULL;
- ma = modulePath (a);
- if (b != NULL)
- mb = modulePath (b);
+ ma = modulePath (a);
+ if (b != NULL)
+ mb = modulePath (b);
- installFiles (ma, mb);
+ installFiles (ma, mb);
- g_free (ma);
- g_free (mb);
+ g_free (ma);
+ g_free (mb);
}
void MainWindow::onZeroconfDiscoverInstallButtonClicked() {
@@ -673,38 +673,76 @@ void MainWindow::readFromGSettings() {
}
gchar * MainWindow::modulePath(const gchar *name) {
- gchar *path, **versions;
+ /* PulseAudio 16.0 dropped the version number from the module directory.
+ * The old module directory looked like "${libdir}/pulse-X.Y/modules", the
+ * new directory looks like "${libdir}/pulseaudio/modules". To deal with
+ * the change, we have three cases:
+ *
+ * 1) If MODDIR ends with "/pulseaudio/modules", we assume it's can be used
+ * as is.
+ *
+ * 2) Otherwise paprefs might be built against an older PulseAudio version,
+ * but the running PulseAudio version might be newer, so we check if
+ * "${libdir}/pulseaudio/modules" exists, in which case we use it. We
+ * don't actually use libdir in the check, though, we use MODDIR with
+ * the last two components removed (the removed part is assumed to be
+ * "/pulse-X.Y/modules"). In the usual case that will be the same as
+ * libdir, but PulseAudio might be built with a custom module directory,
+ * so it's better to use MODDIR.
+ *
+ * 3) Otherwise we assume that MODDIR ends with "/pulse-X.Y/modules" and we
+ * use that, except we replace the version number with the version
+ * reported by pa_get_library_version().
+ *
+ * FIXME: It would be better to connect to the PulseAudio server and ask
+ * its version, but that would require adding a "connecting to PulseAudio"
+ * phase to startup (requiring UI changes), so implementing it requires
+ * more work. */
+
+ gchar *libdir = NULL, *search, *moddir = NULL, *path, **versions;
+
+ /* Case 1: */
+ if (g_str_has_suffix(MODDIR, G_DIR_SEPARATOR_S "pulseaudio" G_DIR_SEPARATOR_S "modules"))
+ return g_build_filename(MODDIR, name, NULL);
+
+ /* Case 2: */
+ libdir = g_strdup(MODDIR);
+ if ((search = g_strrstr(libdir, G_DIR_SEPARATOR_S))) {
+ *search = '\0';
+ if ((search = g_strrstr(libdir, G_DIR_SEPARATOR_S)))
+ *search = '\0';
+ }
- versions = g_strsplit(pa_get_library_version(), ".", 3);
- if (versions[0] && versions[1]) {
- gchar *pulsedir, *search;
+ moddir = g_build_filename(libdir, "pulseaudio", "modules", NULL);
+ if (g_file_test(moddir, G_FILE_TEST_IS_DIR)) {
+ path = g_build_filename(moddir, name, NULL);
+ goto finish;
+ }
+
+ /* Case 3: */
+ versions = g_strsplit(pa_get_library_version(), ".", 3);
+ if (versions[0] && versions[1])
+ path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "pulse-%s.%s" G_DIR_SEPARATOR_S "modules" G_DIR_SEPARATOR_S "%s", libdir, versions[0], versions[1], name);
+ else
+ path = g_build_filename (MODDIR, name, NULL);
+ g_strfreev(versions);
- /* Remove the "/pulse-x.y/modules" suffix so we can dynamically inject
- * it again with runtime library version numbers */
- pulsedir = g_strdup_printf ("%s", MODDIR);
- if ((search = g_strrstr (pulsedir, G_DIR_SEPARATOR_S))) {
- *search = '\0';
- if ((search = g_strrstr (pulsedir, G_DIR_SEPARATOR_S)))
- *search = '\0';
- }
- path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "pulse-%s.%s" G_DIR_SEPARATOR_S "modules" G_DIR_SEPARATOR_S "%s", pulsedir, versions[0], versions[1], name);
- g_free (pulsedir);
- } else
- path = g_build_filename (MODDIR, name, NULL);
- g_strfreev(versions);
+finish:
+ g_free(moddir);
+ g_free(libdir);
- return path;
+ return path;
}
bool MainWindow::moduleExists(const gchar *name) {
- gchar *path = modulePath (name);
- bool ret;
+ gchar *path = modulePath (name);
+ bool ret;
- ret = g_file_test (path, G_FILE_TEST_EXISTS);
+ ret = g_file_test (path, G_FILE_TEST_EXISTS);
- g_free (path);
+ g_free (path);
- return ret;
+ return ret;
}
void MainWindow::checkForModules() {
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/paprefs/-/compare/0b69621331ab34154e663fcb61fea36308be687c...880bc732557f1b653c8d8f17a668212561e3dcf2
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/paprefs/-/compare/0b69621331ab34154e663fcb61fea36308be687c...880bc732557f1b653c8d8f17a668212561e3dcf2
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210825/c17bbe82/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list