From 93348331bb415b1d0a5a1067fbe597f58353c5c9 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Tue, 22 Mar 2011 16:02:24 +0100 Subject: Move compile-time checks around pa_run_from_build_tree to core-util To make the code cleaner and have the checks all in one place. --- src/daemon/daemon-conf.c | 11 +---------- src/modules/alsa/alsa-mixer.c | 12 ++++-------- src/pulsecore/core-util.c | 3 --- src/pulsecore/core-util.h | 5 +++++ 4 files changed, 10 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 59579d92..2872c745 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -144,7 +144,7 @@ static const pa_daemon_conf default_conf = { #endif }; -pa_daemon_conf* pa_daemon_conf_new(void) { +pa_daemon_conf *pa_daemon_conf_new(void) { pa_daemon_conf *c; c = pa_xnewdup(pa_daemon_conf, &default_conf, 1); @@ -153,19 +153,10 @@ pa_daemon_conf* pa_daemon_conf_new(void) { c->dl_search_path = pa_sprintf_malloc("%s" PA_PATH_SEP "lib" PA_PATH_SEP "pulse-%d.%d" PA_PATH_SEP "modules", pa_win32_get_toplevel(NULL), PA_MAJOR, PA_MINOR); #else -#if defined(__linux__) && !defined(__OPTIMIZE__) - - /* We abuse __OPTIMIZE__ as a check whether we are a debug build - * or not. If we are and are run from the build tree then we - * override the search path to point to our build tree */ - if (pa_run_from_build_tree()) { pa_log_notice("Detected that we are run from the build tree, fixing search path."); c->dl_search_path = pa_xstrdup(PA_BUILDDIR "/.libs/"); - } else - -#endif c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH); #endif diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 51a6cd64..286931f4 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -85,7 +85,7 @@ struct pa_alsa_fdlist { void *userdata; }; -static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t events, void *userdata) { +static void io_cb(pa_mainloop_api *a, pa_io_event *e, int fd, pa_io_event_flags_t events, void *userdata) { struct pa_alsa_fdlist *fdl = userdata; int err; @@ -132,7 +132,7 @@ static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t snd_mixer_handle_events(fdl->mixer); } -static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) { +static void defer_cb(pa_mainloop_api *a, pa_defer_event *e, void *userdata) { struct pa_alsa_fdlist *fdl = userdata; unsigned num_fds, i; int err, n; @@ -230,7 +230,7 @@ void pa_alsa_fdlist_free(struct pa_alsa_fdlist *fdl) { pa_xfree(fdl); } -int pa_alsa_fdlist_set_mixer(struct pa_alsa_fdlist *fdl, snd_mixer_t *mixer_handle, pa_mainloop_api* m) { +int pa_alsa_fdlist_set_mixer(struct pa_alsa_fdlist *fdl, snd_mixer_t *mixer_handle, pa_mainloop_api *m) { pa_assert(fdl); pa_assert(mixer_handle); pa_assert(m); @@ -2229,9 +2229,7 @@ pa_alsa_path* pa_alsa_path_new(const char *fname, pa_alsa_direction_t direction) items[2].data = &p->name; fn = pa_maybe_prefix_path(fname, -#if defined(__linux__) && !defined(__OPTIMIZE__) pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/paths/" : -#endif PA_ALSA_PATHS_DIR); r = pa_config_parse(fn, NULL, items, p); @@ -2250,7 +2248,7 @@ fail: return NULL; } -pa_alsa_path* pa_alsa_path_synthesize(const char*element, pa_alsa_direction_t direction) { +pa_alsa_path *pa_alsa_path_synthesize(const char *element, pa_alsa_direction_t direction) { pa_alsa_path *p; pa_alsa_element *e; @@ -3744,9 +3742,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel fname = "default.conf"; fn = pa_maybe_prefix_path(fname, -#if defined(__linux__) && !defined(__OPTIMIZE__) pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/profile-sets/" : -#endif PA_ALSA_PROFILE_SETS_DIR); r = pa_config_parse(fn, NULL, items, ps); diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 796ff57c..48231985 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2991,9 +2991,6 @@ pa_bool_t pa_run_from_build_tree(void) { char *rp; pa_bool_t b = FALSE; - /* We abuse __OPTIMIZE__ as a check whether we are a debug build - * or not. */ - if ((rp = pa_readlink("/proc/self/exe"))) { b = pa_startswith(rp, PA_BUILDDIR); pa_xfree(rp); diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index 80b47395..32641a3f 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -254,8 +254,13 @@ size_t pa_pipe_buf(int fd); void pa_reset_personality(void); +/* We abuse __OPTIMIZE__ as a check whether we are a debug build + * or not. If we are and are run from the build tree then we + * override the search path to point to our build tree */ #if defined(__linux__) && !defined(__OPTIMIZE__) pa_bool_t pa_run_from_build_tree(void); +#else +static inline pa_bool_t pa_run_from_build_tree(void) {return FALSE;} #endif const char *pa_get_temp_dir(void); -- cgit