[vlc-commits] win32: revector system_Init() a bit
Rémi Denis-Courmont
git at videolan.org
Tue May 15 19:40:33 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue May 15 20:34:14 2012 +0300| [d5e4667b90ad65691f4c3c8b88108fcea95b7311] | committer: Rémi Denis-Courmont
win32: revector system_Init() a bit
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d5e4667b90ad65691f4c3c8b88108fcea95b7311
---
src/win32/specific.c | 60 ++++++++++++++++++++-----------------------------
1 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/src/win32/specific.c b/src/win32/specific.c
index 3350cff..8b334d6 100644
--- a/src/win32/specific.c
+++ b/src/win32/specific.c
@@ -39,43 +39,32 @@
#include <winsock.h>
-/*****************************************************************************
- * system_Init: initialize winsock and misc other things.
- *****************************************************************************/
-void system_Init( void )
-{
- WSADATA Data;
-#if !defined( UNDER_CE )
- timeBeginPeriod(5);
-#endif
+static int system_InitWSA(int hi, int lo)
+{
+ WSADATA data;
- /* WinSock Library Init. */
- if( !WSAStartup( MAKEWORD( 2, 2 ), &Data ) )
+ if (WSAStartup(MAKEWORD(hi, lo), &data) == 0)
{
- /* Aah, pretty useless check, we should always have Winsock 2.2
- * since it appeared in Win98. */
- if( LOBYTE( Data.wVersion ) != 2 || HIBYTE( Data.wVersion ) != 2 )
- /* We could not find a suitable WinSock DLL. */
- WSACleanup( );
- else
- /* Everything went ok. */
- return;
+ if (LOBYTE(data.wVersion) == 2 && HIBYTE(data.wVersion) == 2)
+ return 0;
+ /* Winsock DLL is not usable */
+ WSACleanup( );
}
+ return -1;
+}
- /* Let's try with WinSock 1.1 */
- if( !WSAStartup( MAKEWORD( 1, 1 ), &Data ) )
- {
- /* Confirm that the WinSock DLL supports 1.1.*/
- if( LOBYTE( Data.wVersion ) != 1 || HIBYTE( Data.wVersion ) != 1 )
- /* We could not find a suitable WinSock DLL. */
- WSACleanup( );
- else
- /* Everything went ok. */
- return;
- }
+/**
+ * Initializes MME timer, Winsock.
+ */
+void system_Init(void)
+{
+#if !defined( UNDER_CE )
+ timeBeginPeriod(5);
+#endif
- fprintf( stderr, "error: can't initialize WinSocks\n" );
+ if (system_InitWSA(2, 2) && system_InitWSA(1, 1))
+ fputs("Error: cannot initialize Winsocks\n", stderr);
}
/*****************************************************************************
@@ -327,10 +316,10 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
return DefWindowProc( hwnd, uMsg, wParam, lParam );
}
-/*****************************************************************************
- * system_End: terminate winsock.
- *****************************************************************************/
-void system_End( void )
+/**
+ * Cleans up after system_Init() and system_Configure().
+ */
+void system_End(void)
{
HWND ipcwindow;
@@ -349,5 +338,6 @@ void system_End( void )
timeEndPeriod(5);
#endif
+ /* XXX: In theory, we should not call this if WSAStartup() failed. */
WSACleanup();
}
More information about the vlc-commits
mailing list