Skip to content

Commit c70ed2f

Browse files
committed
Enable and fix plusgpl module with MSVC
1 parent ed20642 commit c70ed2f

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

CMakePresets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"MOD_OPENFX": "OFF",
2626
"MOD_MOVIT": "OFF",
2727
"MOD_PLUS": "ON",
28-
"MOD_PLUSGPL": "OFF",
28+
"MOD_PLUSGPL": "ON",
2929
"MOD_QT6": "ON",
3030
"MOD_SOX": "OFF",
3131
"MOD_GLAXNIMATE_QT6": "ON",
@@ -156,4 +156,4 @@
156156
]
157157
}
158158
]
159-
}
159+
}

src/modules/plusgpl/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ generate_export_header(mltplusgpl)
2020
target_compile_options(mltplusgpl PRIVATE ${MLT_COMPILE_OPTIONS})
2121
target_include_directories(mltplusgpl PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
2222
target_link_libraries(mltplusgpl PRIVATE mlt mlt++ Threads::Threads)
23-
if(NOT MSVC)
23+
if(MSVC)
24+
target_link_libraries(mltplusgpl PRIVATE PThreads4W::PThreads4W)
25+
else()
2426
target_link_libraries(mltplusgpl PRIVATE m)
2527
endif()
2628

src/modules/plusgpl/consumer_cbrts.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
#include <stdlib.h>
3535
#include <string.h>
3636
#include <sys/types.h>
37-
#include <unistd.h>
3837

39-
#include <strings.h>
4038
// includes for socket IO
4139
#if (_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE) && (_POSIX_TIMERS > 0)
4240
#if !(defined(__FreeBSD_kernel__) && defined(__GLIBC__))
@@ -48,12 +46,18 @@
4846
#include <sys/types.h>
4947
#endif
5048
#endif
51-
#include <sys/time.h>
5249
#include <time.h>
5350

5451
#ifdef _MSC_VER
5552
#define strncasecmp _strnicmp
5653
#define strcasecmp _stricmp
54+
#define STDOUT_FILENO _fileno( stdin )
55+
#include <BaseTsd.h>
56+
typedef SSIZE_T ssize_t;
57+
#else
58+
#include <unistd.h>
59+
#include <strings.h>
60+
#include <sys/time.h>
5761
#endif
5862

5963
#define TSP_BYTES (188)
@@ -268,7 +272,11 @@ static void load_sections(consumer_cbrts self, mlt_properties properties)
268272
#ifdef si_pid
269273
#undef si_pid
270274
#endif
271-
char si_pid[len + 1];
275+
char *si_pid = (char *)malloc(len + 1);
276+
if (!si_pid) {
277+
mlt_log_error(NULL, "Memory allocation failed for si_pid\n");
278+
return;
279+
}
272280

273281
si_name[len - 3 - 5] = 0;
274282
strcpy(si_pid, "si.");
@@ -282,7 +290,13 @@ static void load_sections(consumer_cbrts self, mlt_properties properties)
282290
ts_section *section = load_section(filename);
283291
if (section) {
284292
// Determine the periodicity of the section, if supplied
285-
char si_time[len + 1];
293+
char *si_time = (char *)malloc(len + 1);
294+
if (!si_time) {
295+
mlt_log_error(NULL, "Memory allocation failed for si_time\n");
296+
free(si_pid);
297+
free(si_name);
298+
return;
299+
}
286300

287301
strcpy(si_time, "si.");
288302
strcat(si_time, si_name);
@@ -318,8 +332,11 @@ static void load_sections(consumer_cbrts self, mlt_properties properties)
318332
section->size,
319333
free,
320334
NULL);
335+
336+
free(si_time);
321337
}
322338
}
339+
free(si_pid);
323340
free(si_name);
324341
}
325342
}

0 commit comments

Comments
 (0)