Commit 66302e2c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

wasapi: use one-time init rather than DllMain()

parent 2a6f4315
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#define _WIN32_WINNT 0x600
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
...@@ -35,25 +36,14 @@ ...@@ -35,25 +36,14 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include "audio_output/mmdevice.h" #include "audio_output/mmdevice.h"
static LARGE_INTEGER freq; /* performance counters frequency */ static BOOL CALLBACK InitFreq(INIT_ONCE *once, void *param, void **context)
BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID); /* avoid warning */
BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved)
{ {
(void) dll; (void) once; (void) context;
(void) reserved; return QueryPerformanceFrequency(param);
switch (reason)
{
case DLL_PROCESS_ATTACH:
if (!QueryPerformanceFrequency(&freq))
return FALSE;
break;
}
return TRUE;
} }
static LARGE_INTEGER freq; /* performance counters frequency */
static UINT64 GetQPC(void) static UINT64 GetQPC(void)
{ {
LARGE_INTEGER counter; LARGE_INTEGER counter;
...@@ -355,6 +345,11 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict fmt, ...@@ -355,6 +345,11 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict fmt,
/* Fallback to other plugin until pass-through is implemented */ /* Fallback to other plugin until pass-through is implemented */
return E_NOTIMPL; return E_NOTIMPL;
static INIT_ONCE freq_once = INIT_ONCE_STATIC_INIT;
if (!InitOnceExecuteOnce(&freq_once, InitFreq, &freq, NULL))
return E_FAIL;
aout_stream_sys_t *sys = malloc(sizeof (*sys)); aout_stream_sys_t *sys = malloc(sizeof (*sys));
if (unlikely(sys == NULL)) if (unlikely(sys == NULL))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
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