Skip to content

Commit

Permalink
build: use ifdef instead of `if for various defines
Browse files Browse the repository at this point in the history
Change-Id: I386bd1adddf403ff450e5d22688337b7d6d7c1f6
  • Loading branch information
aberaud committed Jun 23, 2022
1 parent ce645d4 commit fa7fb8b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion compat/msvc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
3 changes: 1 addition & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/client/videomanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/jami/plugin_manager_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <map>
#include <list>

#if __APPLE__
#ifdef __APPLE__
#import "TargetConditionals.h"
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/jami/videomanager_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void av_frame_free(AVFrame** frame);
#include <cstdint>
#include <cstdlib>

#if __APPLE__
#ifdef __APPLE__
#import "TargetConditionals.h"
#endif

Expand Down Expand Up @@ -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<std::string, std::string> getRenderer(const std::string& callId);
Expand Down Expand Up @@ -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";
Expand Down
14 changes: 7 additions & 7 deletions src/media/video/sinkclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -300,7 +300,7 @@ SinkClient::stop() noexcept
return true;
}

#else // HAVE_SHM
#else // ENABLE_SHM

std::string
SinkClient::openedName() const noexcept
Expand All @@ -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}
Expand Down Expand Up @@ -439,7 +439,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
}

bool doTransfer = hasTransformedListener or hasObservers;
#if HAVE_SHM
#ifdef ENABLE_SHM
doTransfer |= (shm_ && doShmTransfer_);
#endif

Expand All @@ -455,7 +455,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
setFrameSize(frame->width(), frame->height());
return;
}
#if HAVE_SHM
#ifdef ENABLE_SHM
if (shm_ && doShmTransfer_)
shm_->renderFrame(*frame);
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/media/video/sinkclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -82,7 +82,7 @@ class SinkClient : public VideoFramePassiveReader, public VideoFrameActiveWriter
target_ = std::move(target);
}

#if HAVE_SHM
#ifdef ENABLE_SHM
void enableShm(bool value) { doShmTransfer_.store(value); }
#endif

Expand Down Expand Up @@ -122,11 +122,11 @@ class SinkClient : public VideoFramePassiveReader, public VideoFrameActiveWriter
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<ShmHolder> shm_;
std::atomic_bool doShmTransfer_ {false};
#endif // HAVE_SHM
#endif // ENABLE_SHM
};

} // namespace video
Expand Down

0 comments on commit fa7fb8b

Please sign in to comment.