From 944460ac74166beedaba77aca197b3d5448f7058 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 25 May 2023 22:49:55 +0200 Subject: [PATCH] msvc compat bits Signed-off-by: falkTX --- cmake/CMakeLists.txt | 12 +++++++++ source/modules/audio_decoder/ad_ffmpeg.c | 27 +++++++++++---------- source/modules/audio_decoder/ad_minimp3.c | 3 +-- source/modules/audio_decoder/ad_plugin.c | 2 +- source/modules/audio_decoder/ad_soundfile.c | 7 +++--- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 147527651..e5c473c5d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -384,6 +384,11 @@ add_library(carla::native-plugins ALIAS carla-native-plugins) set_common_target_properties(carla-native-plugins) +target_compile_definitions(carla-native-plugins + PRIVATE + $<$:_USE_MATH_DEFINES> +) + target_include_directories(carla-native-plugins PRIVATE ../source/includes @@ -435,6 +440,7 @@ target_link_libraries(carla-rtmempool PRIVATE ${CARLA_LIBDL} ${CARLA_LIBRT} + ${CARLA_PTHREADS} ) target_sources(carla-rtmempool @@ -494,6 +500,7 @@ target_link_libraries(carla-water $<$:winmm> ${CARLA_LIBDL} ${CARLA_LIBRT} + ${CARLA_PTHREADS} ) target_sources(carla-water @@ -630,6 +637,11 @@ target_include_directories(carla-zita-resampler ../source/includes ) +target_link_libraries(carla-zita-resampler + PRIVATE + ${CARLA_PTHREADS} +) + target_sources(carla-zita-resampler PRIVATE ../source/modules/zita-resampler/cresampler.cc diff --git a/source/modules/audio_decoder/ad_ffmpeg.c b/source/modules/audio_decoder/ad_ffmpeg.c index 266fed6d0..85bde96d8 100644 --- a/source/modules/audio_decoder/ad_ffmpeg.c +++ b/source/modules/audio_decoder/ad_ffmpeg.c @@ -16,16 +16,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "ad_plugin.h" + +#ifdef HAVE_FFMPEG + #include #include #include #include #include -#include "ad_plugin.h" - -#ifdef HAVE_FFMPEG - #include "ffcompat.h" #ifndef MIN @@ -93,10 +94,10 @@ static int ad_info_ffmpeg(void *sf, struct adinfo *nfo) { static void *ad_open_ffmpeg(const char *fn, struct adinfo *nfo) { ffmpeg_audio_decoder *priv = (ffmpeg_audio_decoder*) calloc(1, sizeof(ffmpeg_audio_decoder)); - + priv->m_tmpBufferStart=NULL; priv->m_tmpBufferLen=0; - priv->decoder_clock=priv->output_clock=priv->seek_frame=0; + priv->decoder_clock=priv->output_clock=priv->seek_frame=0; priv->packet.size=0; priv->packet.data=NULL; if (avformat_open_input(&priv->formatContext, fn, NULL, NULL) <0) { @@ -154,7 +155,7 @@ static void *ad_open_ffmpeg(const char *fn, struct adinfo *nfo) { } dbg(1, "ffmpeg - %s", fn); - if (nfo) + if (nfo) dbg(1, "ffmpeg - sr:%i c:%i d:%"PRIi64" f:%"PRIi64, nfo->sample_rate, nfo->channels, nfo->length, nfo->frames); return (void*) priv; @@ -275,9 +276,9 @@ static ssize_t ad_read_ffmpeg(void *sf, float* d, size_t len) { } /* align buffer after seek. */ - if (priv->seek_frame > 0) { + if (priv->seek_frame > 0) { const int diff = priv->output_clock-priv->decoder_clock; - if (diff<0) { + if (diff<0) { /* seek ended up past the wanted sample */ dbg(0, " !!! Audio seek failed."); return -1; @@ -335,16 +336,16 @@ static int64_t ad_seek_ffmpeg(void *sf, int64_t pos) { const int64_t timestamp = pos / av_q2d(priv->formatContext->streams[priv->audioStream]->time_base) / priv->samplerate; dbg(2, "seek frame:%"PRIi64" - idx:%"PRIi64, pos, timestamp); - + av_seek_frame(priv->formatContext, priv->audioStream, timestamp, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); avcodec_flush_buffers(priv->codecContext); return pos; } -static int ad_eval_ffmpeg(const char *f) { +static int ad_eval_ffmpeg(const char *f) { char *ext = strrchr(f, '.'); if (!ext) return 10; - // libavformat.. guess_format.. + // libavformat.. guess_format.. return 40; } #endif @@ -382,7 +383,7 @@ const ad_plugin * adp_get_ffmpeg() { avcodec_register_all(); if(ad_debug_level <= 1) av_log_set_level(AV_LOG_QUIET); - else + else av_log_set_level(AV_LOG_VERBOSE); } #endif diff --git a/source/modules/audio_decoder/ad_minimp3.c b/source/modules/audio_decoder/ad_minimp3.c index 6d6f50068..e2c2b7eed 100644 --- a/source/modules/audio_decoder/ad_minimp3.c +++ b/source/modules/audio_decoder/ad_minimp3.c @@ -16,11 +16,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include #include -#include -#include #include #include "ad_plugin.h" diff --git a/source/modules/audio_decoder/ad_plugin.c b/source/modules/audio_decoder/ad_plugin.c index 24604237a..9a2abf96b 100644 --- a/source/modules/audio_decoder/ad_plugin.c +++ b/source/modules/audio_decoder/ad_plugin.c @@ -16,11 +16,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include #include #include -#include #include #include "ad_plugin.h" diff --git a/source/modules/audio_decoder/ad_soundfile.c b/source/modules/audio_decoder/ad_soundfile.c index 5b20a808f..1e6419bf9 100644 --- a/source/modules/audio_decoder/ad_soundfile.c +++ b/source/modules/audio_decoder/ad_soundfile.c @@ -16,11 +16,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include #include -#include -#include #include #include "ad_plugin.h" @@ -85,7 +84,7 @@ static void *ad_open_sndfile(const char *fn, struct adinfo *nfo) { static int ad_close_sndfile(void *sf) { sndfile_audio_decoder *priv = (sndfile_audio_decoder*) sf; if (!priv) return -1; - if(!sf || sf_close(priv->sffile)) { + if(!sf || sf_close(priv->sffile)) { dbg(0, "fatal: bad file close.\n"); return -1; } @@ -111,7 +110,7 @@ static int ad_get_bitrate_sndfile(void *sf) { return parse_bit_depth(priv->sfinfo.format) * priv->sfinfo.channels * priv->sfinfo.samplerate; } -static int ad_eval_sndfile(const char *f) { +static int ad_eval_sndfile(const char *f) { char *ext = strrchr(f, '.'); if (strstr (f, "://")) return 0; if (!ext) return 5;