diff mbox

[FFmpeg-devel,2/3] avformat/udp: Use avutil compat pthread_cond_timedwait.

Message ID CAHVN4mjqFFEvsTDWA=p1eS2Mka4n9+ST6U1gO-7AtxHAqaC-=Q@mail.gmail.com
State New
Headers show

Commit Message

Matt Oliver Dec. 7, 2016, 6:04 a.m. UTC
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
---
 libavformat/udp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

                 nonblock = 1;
             }

Comments

Carl Eugen Hoyos Dec. 10, 2016, 1:21 p.m. UTC | #1
2016-12-07 7:04 GMT+01:00 Matt Oliver <protogonoi@gmail.com>:

> -#if HAVE_PTHREAD_CANCEL
> -#include <pthread.h>
> -#endif
> -

>  #ifndef HAVE_PTHREAD_CANCEL
>  #define HAVE_PTHREAD_CANCEL 0
>  #endif

Do you know what this block is supposed to do?
If you remove it first, the diff gets much smaller...

Carl Eugen
Matt Oliver Dec. 11, 2016, 8:36 a.m. UTC | #2
On 11 December 2016 at 00:21, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2016-12-07 7:04 GMT+01:00 Matt Oliver <protogonoi@gmail.com>:
>
> > -#if HAVE_PTHREAD_CANCEL
> > -#include <pthread.h>
> > -#endif
> > -
>
> >  #ifndef HAVE_PTHREAD_CANCEL
> >  #define HAVE_PTHREAD_CANCEL 0
> >  #endif
>

I have no idea why that line is there as configure should set it to a
value, I just didnt remove it in case there was still some reason that I
couldnt see.
diff mbox

Patch

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 3835f98..f8c861d 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -60,14 +60,14 @@ 
 #define IPPROTO_UDPLITE                                  136
 #endif

-#if HAVE_PTHREAD_CANCEL
-#include <pthread.h>
-#endif
-
 #ifndef HAVE_PTHREAD_CANCEL
 #define HAVE_PTHREAD_CANCEL 0
 #endif

+#if HAVE_PTHREAD_CANCEL
+#include "libavutil/thread.h"
+#endif
+
 #ifndef IPV6_ADD_MEMBERSHIP
 #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
 #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
@@ -1054,9 +1054,9 @@  static int udp_read(URLContext *h, uint8_t *buf, int
size)
                 int64_t t = av_gettime() + 100000;
                 struct timespec tv = { .tv_sec  =  t / 1000000,
                                        .tv_nsec = (t % 1000000) * 1000 };
-                if (pthread_cond_timedwait(&s->cond, &s->mutex, &tv) < 0) {
+                if (ret = pthread_cond_timedwait(&s->cond, &s->mutex, &tv)
< 0) {
                     pthread_mutex_unlock(&s->mutex);
-                    return AVERROR(errno == ETIMEDOUT ? EAGAIN : errno);
+                    return AVERROR(ret == ETIMEDOUT ? EAGAIN : ret);
                 }