Commit d16bd481 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

core: win32: do not load winmm.dll on startup, it's not a Known DLL

Modified-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent d141214e
......@@ -315,9 +315,7 @@ AS_IF([test "${SYS}" = "mingw32"],[
LIBCOM=""
VLC_ADD_LIBS([libvlccore], [-lruntimeobject])
AC_LIBOBJ([gai_strerror])
],[
VLC_ADD_LIBS([libvlccore],[-lwinmm])
])
],[])
AC_SUBST(LIBCOM)
])
AC_DEFINE_UNQUOTED(VLC_WINSTORE_APP, ${vlc_winstore_app}, [Define to 1 if you want to build for Windows Store apps])
......
......@@ -55,11 +55,17 @@ static int system_InitWSA(int hi, int lo)
/**
* Initializes MME timer, Winsock.
*/
static HMODULE hWinmm = INVALID_HANDLE_VALUE;
void system_Init(void)
{
#if !VLC_WINSTORE_APP
timeBeginPeriod(5);
#endif
hWinmm = LoadLibrary(TEXT("winmm.dll"));
if (hWinmm)
{
MMRESULT (WINAPI * timeBeginPeriod)(UINT);
timeBeginPeriod = (void*)GetProcAddress(hWinmm, "timeBeginPeriod");
if (timeBeginPeriod)
timeBeginPeriod(5);
}
if (system_InitWSA(2, 2) && system_InitWSA(1, 1))
fputs("Error: cannot initialize Winsocks\n", stderr);
......@@ -204,9 +210,14 @@ void system_Configure( libvlc_int_t *p_this, int i_argc, const char *const ppsz_
*/
void system_End(void)
{
#if !VLC_WINSTORE_APP
timeEndPeriod(5);
#endif
if (hWinmm)
{
MMRESULT (WINAPI * timeEndPeriod)(UINT);
timeEndPeriod = (void*)GetProcAddress(hWinmm, "timeEndPeriod");
if (timeEndPeriod)
timeEndPeriod(5);
FreeLibrary(hWinmm);
}
/* XXX: In theory, we should not call this if WSAStartup() failed. */
WSACleanup();
......
......@@ -38,6 +38,9 @@
#include <limits.h>
#include <errno.h>
#include <time.h>
#if !VLC_WINSTORE_APP
#include <mmsystem.h>
#endif
/*** Static mutex and condition variable ***/
static CRITICAL_SECTION super_mutex;
......@@ -709,6 +712,13 @@ static union
{
LARGE_INTEGER freq;
} perf;
#if !VLC_WINSTORE_APP
struct
{
MMRESULT (WINAPI *timeGetDevCaps)(LPTIMECAPS ptc,UINT cbtc);
DWORD (WINAPI *timeGetTime)(void);
} multimedia;
#endif
} clk;
static mtime_t mdate_interrupt (void)
......@@ -742,10 +752,9 @@ static mtime_t mdate_tick (void)
return ts * (CLOCK_FREQ / 1000);
}
#if !VLC_WINSTORE_APP
#include <mmsystem.h>
static mtime_t mdate_multimedia (void)
{
DWORD ts = timeGetTime ();
DWORD ts = clk.multimedia.timeGetTime ();
/* milliseconds */
static_assert ((CLOCK_FREQ % 1000) == 0, "Broken frequencies ratio");
......@@ -884,9 +893,18 @@ static void SelectClockSource (vlc_object_t *obj)
{
TIMECAPS caps;
HMODULE hWinmm = GetModuleHandle(TEXT("winmm.dll"));
if (!hWinmm)
goto perf;
clk.multimedia.timeGetDevCaps = (void*)GetProcAddress(hWinmm, "timeGetDevCaps");
clk.multimedia.timeGetTime = (void*)GetProcAddress(hWinmm, "timeGetTime");
if (!clk.multimedia.timeGetDevCaps || !clk.multimedia.timeGetTime)
goto perf;
msg_Dbg (obj, "using multimedia timers as clock source");
if (timeGetDevCaps (&caps, sizeof (caps)) != MMSYSERR_NOERROR)
abort ();
if (clk.multimedia.timeGetDevCaps (&caps, sizeof (caps)) != MMSYSERR_NOERROR)
goto perf;
msg_Dbg (obj, " min period: %u ms, max period: %u ms",
caps.wPeriodMin, caps.wPeriodMax);
mdate_selected = mdate_multimedia;
......@@ -895,6 +913,7 @@ static void SelectClockSource (vlc_object_t *obj)
else
if (!strcmp (name, "perf"))
{
perf:
msg_Dbg (obj, "using performance counters as clock source");
if (!QueryPerformanceFrequency (&clk.perf.freq))
abort ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment