[vlc-commits] wasapi: use one-time init rather than DllMain()
Rémi Denis-Courmont
git at videolan.org
Wed Oct 21 17:45:03 CEST 2015
vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jun 28 19:08:28 2015 +0300| [baa16ca4c818738c7f114d38c15c27c368330f90] | committer: Jean-Baptiste Kempf
wasapi: use one-time init rather than DllMain()
(cherry picked from commit 66302e2c16462072153ff85a621d83c0944a03dc)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=baa16ca4c818738c7f114d38c15c27c368330f90
---
modules/audio_output/wasapi.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index 7a47161..48f6d95 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#define _WIN32_WINNT 0x600
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@@ -35,25 +36,14 @@
#include <vlc_plugin.h>
#include "audio_output/mmdevice.h"
-static LARGE_INTEGER freq; /* performance counters frequency */
-
-BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID); /* avoid warning */
-
-BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved)
+static BOOL CALLBACK InitFreq(INIT_ONCE *once, void *param, void **context)
{
- (void) dll;
- (void) reserved;
-
- switch (reason)
- {
- case DLL_PROCESS_ATTACH:
- if (!QueryPerformanceFrequency(&freq))
- return FALSE;
- break;
- }
- return TRUE;
+ (void) once; (void) context;
+ return QueryPerformanceFrequency(param);
}
+static LARGE_INTEGER freq; /* performance counters frequency */
+
static UINT64 GetQPC(void)
{
LARGE_INTEGER counter;
@@ -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 */
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));
if (unlikely(sys == NULL))
return E_OUTOFMEMORY;
More information about the vlc-commits
mailing list