From fa7fb8beb0c30e155d2c95b0cba452fcbc1fbc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Wed, 22 Jun 2022 16:27:06 -0400 Subject: [PATCH] build: use `ifdef` instead of `if for various defines Change-Id: I386bd1adddf403ff450e5d22688337b7d6d7c1f6 --- compat/msvc/config.h | 2 +- configure.ac | 6 ++---- meson.build | 3 +-- src/client/videomanager.cpp | 2 +- src/jami/plugin_manager_interface.h | 2 +- src/jami/videomanager_interface.h | 6 +++--- src/media/video/sinkclient.cpp | 14 +++++++------- src/media/video/sinkclient.h | 10 +++++----- 8 files changed, 21 insertions(+), 24 deletions(-) diff --git a/compat/msvc/config.h b/compat/msvc/config.h index 5e31cb7de..86cc02389 100644 --- a/compat/msvc/config.h +++ b/compat/msvc/config.h @@ -89,7 +89,7 @@ systems. This function is required for `alloca.c' support on those systems. #define HAVE_PULSE 0 /* Define if you have shared memory support */ -#define HAVE_SHM 0 +#undef ENABLE_SHM /* Define if you have libspeex */ #define HAVE_SPEEX 0 diff --git a/configure.ac b/configure.ac index 025aa84e5..8e7c38e37 100644 --- a/configure.ac +++ b/configure.ac @@ -620,10 +620,8 @@ AM_CONDITIONAL([BUILD_NATPMP], test "x$with_natpmp" = "xyes") # SHM dnl check for shm - -AC_DEFINE_UNQUOTED([HAVE_SHM], - `if test "x$with_dbus" == xyes; then echo 1; else echo 0; fi`, - [Define if you have shared memory support]) +AS_IF([test "x$with_dbus" == xyes], + AC_DEFINE([ENABLE_SHM], [1], [Define if you have shared memory support])) # LTTNG AM_COND_IF([ENABLE_TRACEPOINTS], diff --git a/meson.build b/meson.build index f62198119..45d0c07d7 100644 --- a/meson.build +++ b/meson.build @@ -156,8 +156,7 @@ else endif conf.set10('HAVE_COREAUDIO', host_machine.system() == 'darwin') -conf.set10('HAVE_SHM', get_option('interfaces').contains('dbus')) - +conf.set('ENABLE_SHM', get_option('interfaces').contains('dbus')) configure_file( output: 'config.h', configuration: conf diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp index 8cb564139..a0d43c0a0 100644 --- a/src/client/videomanager.cpp +++ b/src/client/videomanager.cpp @@ -535,7 +535,7 @@ registerSinkTarget(const std::string& sinkId, SinkTarget target) return false; } -#if HAVE_SHM +#ifdef ENABLE_SHM void startShmSink(const std::string& sinkId, bool value) { diff --git a/src/jami/plugin_manager_interface.h b/src/jami/plugin_manager_interface.h index f35a05a11..8df15ec0a 100644 --- a/src/jami/plugin_manager_interface.h +++ b/src/jami/plugin_manager_interface.h @@ -29,7 +29,7 @@ #include #include -#if __APPLE__ +#ifdef __APPLE__ #import "TargetConditionals.h" #endif diff --git a/src/jami/videomanager_interface.h b/src/jami/videomanager_interface.h index 955d290d5..6a444f761 100644 --- a/src/jami/videomanager_interface.h +++ b/src/jami/videomanager_interface.h @@ -43,7 +43,7 @@ void av_frame_free(AVFrame** frame); #include #include -#if __APPLE__ +#ifdef __APPLE__ #import "TargetConditionals.h" #endif @@ -195,7 +195,7 @@ DRING_PUBLIC bool playerSeekToTime(const std::string& id, int time); int64_t getPlayerPosition(const std::string& id); DRING_PUBLIC bool registerSinkTarget(const std::string& sinkId, SinkTarget target); -#if HAVE_SHM +#ifdef ENABLE_SHM DRING_PUBLIC void startShmSink(const std::string& sinkId, bool value); #endif DRING_PUBLIC std::map getRenderer(const std::string& callId); @@ -252,7 +252,7 @@ struct DRING_PUBLIC VideoSignal const std::string& /*shm_path*/, bool /*is_mixer*/); }; -#if __ANDROID__ +#ifdef __ANDROID__ struct DRING_PUBLIC SetParameters { constexpr static const char* name = "SetParameters"; diff --git a/src/media/video/sinkclient.cpp b/src/media/video/sinkclient.cpp index 4e9f15bd4..f9c5c5d74 100644 --- a/src/media/video/sinkclient.cpp +++ b/src/media/video/sinkclient.cpp @@ -26,9 +26,9 @@ #include "sinkclient.h" -#if HAVE_SHM +#ifdef ENABLE_SHM #include "shm_header.h" -#endif // HAVE_SHM +#endif // ENABLE_SHM #include "media_buffer.h" #include "logger.h" @@ -63,7 +63,7 @@ namespace video { const constexpr char FILTER_INPUT_NAME[] = "in"; -#if HAVE_SHM +#ifdef ENABLE_SHM // RAII class helper on sem_wait/sem_post sempahore operations class SemGuardLock { @@ -300,7 +300,7 @@ SinkClient::stop() noexcept return true; } -#else // HAVE_SHM +#else // ENABLE_SHM std::string SinkClient::openedName() const noexcept @@ -322,7 +322,7 @@ SinkClient::stop() noexcept return true; } -#endif // !HAVE_SHM +#endif // !ENABLE_SHM SinkClient::SinkClient(const std::string& id, bool mixer) : id_ {id} @@ -439,7 +439,7 @@ SinkClient::update(Observable>* /*obs*/, } bool doTransfer = hasTransformedListener or hasObservers; -#if HAVE_SHM +#ifdef ENABLE_SHM doTransfer |= (shm_ && doShmTransfer_); #endif @@ -455,7 +455,7 @@ SinkClient::update(Observable>* /*obs*/, setFrameSize(frame->width(), frame->height()); return; } -#if HAVE_SHM +#ifdef ENABLE_SHM if (shm_ && doShmTransfer_) shm_->renderFrame(*frame); #endif diff --git a/src/media/video/sinkclient.h b/src/media/video/sinkclient.h index ed3d9fdfe..adce5090c 100644 --- a/src/media/video/sinkclient.h +++ b/src/media/video/sinkclient.h @@ -42,9 +42,9 @@ class MediaFilter; namespace jami { namespace video { -#if HAVE_SHM +#ifdef ENABLE_SHM class ShmHolder; -#endif // HAVE_SHM +#endif // ENABLE_SHM class VideoScaler; @@ -82,7 +82,7 @@ public: target_ = std::move(target); } -#if HAVE_SHM +#ifdef ENABLE_SHM void enableShm(bool value) { doShmTransfer_.store(value); } #endif @@ -122,11 +122,11 @@ private: std::chrono::steady_clock::time_point lastFrameDebug_; #endif -#if HAVE_SHM +#ifdef ENABLE_SHM // using shared_ptr and not unique_ptr as ShmHolder is forwared only std::shared_ptr shm_; std::atomic_bool doShmTransfer_ {false}; -#endif // HAVE_SHM +#endif // ENABLE_SHM }; } // namespace video