Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/framework/mlt_consumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef _MSC_VER
#include <gettimeofday.h>
#else
#include <sys/time.h>
#endif

/** Define this if you want an automatic deinterlace (if necessary) when the
* consumer's producer is not running at normal speed.
Expand Down
5 changes: 5 additions & 0 deletions src/framework/mlt_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@
#include "mlt_service.h"

#include <string.h>

#ifndef NDEBUG
#ifdef _MSC_VER
#include <gettimeofday.h>
#else
#include <sys/time.h>
#include <time.h>
#endif
#endif

static int log_level = MLT_LOG_WARNING;

Expand Down
1 change: 0 additions & 1 deletion src/framework/mlt_producer.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <sys/stat.h> // for stat()
#include <sys/types.h> // for stat()
#include <time.h> // for strftime() and gtime()
#include <unistd.h> // for stat()

/* Forward references. */

Expand Down
6 changes: 5 additions & 1 deletion src/framework/mlt_slices.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
#include <pthread.h>
#include <sched.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef _WIN32
#include <windows.h>
#else
// For _SC_NPROCESSORS_ONLN
#include <unistd.h>
#endif

#define MAX_SLICES 32
#define ENV_SLICES "MLT_SLICES_COUNT"

Expand Down
3 changes: 1 addition & 2 deletions src/melt/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
#include <string.h>
#ifndef _WIN32
#include <termios.h>
#include <unistd.h>
#else
// MinGW defines struct timespec in pthread.h
#include <pthread.h>
// for nanosleep()
#include <framework/mlt_types.h>
#include <windows.h>
#endif
#include <sys/time.h>
#include <unistd.h>

/* Application header files */
#include "io.h"
Expand Down
8 changes: 7 additions & 1 deletion src/melt/melt.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
#endif
#include <libgen.h>
#include <locale.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef _MSC_VER
#ifndef STDIN_FILENO
#define STDIN_FILENO _fileno(stdin)
#endif
#else
#include <unistd.h>
#endif

#include <framework/mlt.h>

Expand Down
1 change: 0 additions & 1 deletion src/modules/core/consumer_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>

// Forward references
static int start(mlt_consumer consumer);
Expand Down
5 changes: 5 additions & 0 deletions src/modules/plusgpl/consumer_cbrts.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
#include <sys/time.h>
#include <time.h>

#ifdef _MSC_VER
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif

#define TSP_BYTES (188)
#define MAX_PID (8192)
#define SCR_HZ (27000000ULL)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/sdl2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target_compile_options(mltsdl2 PRIVATE ${MLT_COMPILE_OPTIONS})
target_include_directories(mltsdl2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(mltsdl2 PRIVATE mlt Threads::Threads SDL2::SDL2)
if(MSVC)
target_link_libraries(mltsdl2 PRIVATE PThreads4W::PThreads4W)
target_link_libraries(mltsdl2 PRIVATE PThreads4W::PThreads4W msvccompat)
else()
target_link_libraries(mltsdl2 PRIVATE m)
endif()
Expand Down
5 changes: 5 additions & 0 deletions src/modules/sdl2/consumer_sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef _MSC_VER
#include <gettimeofday.h>
#else
#include <sys/time.h>
#endif

#undef MLT_IMAGE_FORMAT // only yuv422 working currently

Expand Down
5 changes: 5 additions & 0 deletions src/modules/sdl2/consumer_sdl2_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef _MSC_VER
#include <gettimeofday.h>
#else
#include <sys/time.h>
#endif

MLT_EXPORT extern pthread_mutex_t mlt_sdl_mutex;

Expand Down
2 changes: 1 addition & 1 deletion src/msvc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(msvccompat STATIC libgen.c)
add_library(msvccompat STATIC libgen.c gettimeofday.c)

target_include_directories(msvccompat PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
70 changes: 70 additions & 0 deletions src/msvc/gettimeofday.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copied from vcpkg:
* https://github.com/microsoft/vcpkg/blob/master/ports/gettimeofday/gettimeofday.c
*
* Originally copied from PostgreSQL source:
* http://doxygen.postgresql.org/gettimeofday_8c_source.html
*
*/

/*
* gettimeofday.c
* Win32 gettimeofday() replacement
*
* src/port/gettimeofday.c
*
* Copyright (c) 2003 SRA, Inc.
* Copyright (c) 2003 SKC, Inc.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose, without fee, and without a
* written agreement is hereby granted, provided that the above
* copyright notice and this paragraph and the following two
* paragraphs appear in all copies.
*
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
* DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
* IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/

#ifdef _MSC_VER

#include <winsock2.h>


/* FILETIME of Jan 1 1970 00:00:00. */
static const unsigned __int64 epoch = 116444736000000000Ui64;

/*
* timezone information is stored outside the kernel so tzp isn't used anymore.
*
* Note: this function is not for Win32 high precision timing purpose. See
* elapsed_time().
*/
int
gettimeofday(struct timeval * tp, struct timezone * tzp)
{
FILETIME file_time;
SYSTEMTIME system_time;
ULARGE_INTEGER ularge;

GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
ularge.LowPart = file_time.dwLowDateTime;
ularge.HighPart = file_time.dwHighDateTime;

tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);

return 0;
}

#endif /* _MSC_VER */
19 changes: 19 additions & 0 deletions src/msvc/gettimeofday.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copied from vcpkg:
* https://github.com/microsoft/vcpkg/blob/master/ports/gettimeofday/gettimeofday.h
*
*/

#ifndef _MY_GETTIMEOFDAY_H_
#define _MY_GETTIMEOFDAY_H_

#ifdef _MSC_VER

#include <winsock2.h>
#include <time.h>

int gettimeofday(struct timeval * tp, struct timezone * tzp);

#endif /* _MSC_VER */

#endif /* _MY_GETTIMEOFDAY_H_ */
7 changes: 7 additions & 0 deletions src/win32/strptime.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ __RCSID("$NetBSD: strptime.c,v 1.36 2012/03/13 21:13:48 christos Exp $");
__weak_alias(strptime,_strptime)
#endif
*/

#ifdef _MSC_VER
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif


typedef unsigned char u_char;
typedef unsigned int uint;
typedef unsigned __int64 uint64_t;
Expand Down