[Ffmpeg-devel] Network patch for MingW users

Måns Rullgård mans
Sat Feb 24 14:33:26 CET 2007


Alex Beregszaszi <alex at rtfs.hu> writes:

> Hi,
>
>> > >> It's slightly more code, but it makes the code easier to
>> > >> understand without looking up the definitions of the macros.
>> > >
>> > > Can we do a short voting about this now?
>> > >
>> > > I perfectly ok with both systems.
>> > 
>> > Fine, then what is there to vote about?  
>> 
>> i vote for if(foobar == WHATEVER(ESOMETHING)) instead of if(barfoo(ESOMETHING))
>
> This patch uses ff_neterrno() and FF_NETERROR(). It wont apply cleanly.
>
> Also I have av_socket_nonblock() in there. Should I use the ff_ prefix?
>
> Also the same changes apply to ffserver.c
>
> Index: libavformat/network.h
> ===================================================================
> --- libavformat/network.h	(revision 8077)
> +++ libavformat/network.h	(working copy)
> @@ -21,10 +21,50 @@
>  #ifndef NETWORK_H
>  #define NETWORK_H
>  
> +#ifdef __MINGW32__
> +#include <winsock2.h>
> +#include <ws2tcpip.h>
> +#else
>  #include <sys/types.h>
>  #include <sys/socket.h>
>  #include <netinet/in.h>
>  #include <arpa/inet.h>
>  #include <netdb.h>
> +#endif
>  
> +/**
> + * sets the non-blocking io on socket
> + */
> +static inline int av_socket_nonblock(int socket, int enable)
> +{
> +#ifdef __MINGW32__
> +   return ioctlsocket(socket, FIONBIO, &enable);
> +#else
> +   if (enable)
> +      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
> +   else
> +      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
>  #endif
> +}

This should be in os_support.c with a prototype here.

> +#ifdef __MINGW32__
> +#define ff_neterrno() WSAGetLastError()
> +#define FF_NETERROR(err) WSA##err
> +#define WSAEAGAIN WSAEWOULDBLOCK
> +#else
> +#define ff_neterrno() errno
> +#define FF_NETERROR(err) err
> +#endif

This should be merged with the #ifdef chunk above.

The rest of the errno bits look OK.

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




More information about the ffmpeg-devel mailing list