[Ffmpeg-devel] Network patch for MingW users

Måns Rullgård mans
Wed Feb 21 01:27:02 CET 2007


Ryan Martell <rdm4 at martellventures.com> writes:

> On Feb 19, 2007, at 11:42 PM, Fran?ois Revol wrote:
>>>>  #ifdef __MINGW32__
>>>>  __declspec(dllimport) void __stdcall Sleep(unsigned long
>>>> dwMilliseconds);
>>>>  // #  include <windows.h>
>>>> +#define GUID microsoft_issue_GUID
>>>> +#include <winsock.h>
>>>> +#undef GUID
>>>>  #  define usleep(t)    Sleep((t) / 1000)
>>>> -#  include <fcntl.h>
>>>> -#  define lseek(f,p,w) _lseeki64((f), (p), (w))
>>>> +#  define sleep(t)     Sleep((t) * 1000)
>>>> +#define O_NONBLOCK FIONBIO
>>>> +#define fcntl(fd,b,c) { u_long arg=1L; \
>>>> +                        ioctlsocket(fd, c, &arg); }
>>>
>>> I'm not convinced this is a good idea.  Someone might use fcntl()
>>> on a real file.
>>
>> Why not just define a fcntlsocket() that other OSes would just map to
>> fcntl like is done for close already ? Much cleaner.
>>
>>>>      if (port <= 0 || port >= 65536)
>>>>          goto fail;
>>>>
>>>> +#ifdef __MINGW32__
>>>> +    init_winsock();
>>>> +#endif
>>>
>>> Aaaaiiiieeee!  NO MORE OF THIS. PLEASE.
>>
>> Also that's totally definitely non threadsafe.
>
> fcntlsocket() as above..

Either that, or a more specific function/macro to set non-blocking
mode.  That hack above won't work for much else anyway.

> and
>
> initialize_sockets() and shutdown_sockets(), which do nothing on real
> os's, but does the init_winsock thing on windows?

That's what I had in mind.  I don't care much what the actual names
are, but they should have an ff_ prefix.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list