static int udp_write(URLContext *h, const uint8_t *buf, int size)

{

    UDPContext *s = h->priv_data;

    int ret;



#if HAVE_PTHREAD_CANCEL

    if (s->fifo) {

        uint8_t tmp[4];



        pthread_mutex_lock(&s->mutex);



        /*

          Return error if last tx failed.

          Here we can't know on which packet error was, but it needs to know that error exists.

        */

        if (s->circular_buffer_error<0) {

            int err=s->circular_buffer_error;

            s->circular_buffer_error=0;

            pthread_mutex_unlock(&s->mutex);

            return err;

        }



        if(av_fifo_space(s->fifo) < size + 4) {

            /* What about a partial packet tx ? */

            pthread_mutex_unlock(&s->mutex);

            return AVERROR(ENOMEM);

        }

        AV_WL32(tmp, size);

        av_fifo_generic_write(s->fifo, tmp, 4, NULL); /* size of packet */

        av_fifo_generic_write(s->fifo, (uint8_t *)buf, size, NULL); /* the data */

        pthread_cond_signal(&s->cond);

        pthread_mutex_unlock(&s->mutex);

        return size;

    }

#endif

    if (!(h->flags & AVIO_FLAG_NONBLOCK)) {

        ret = ff_network_wait_fd(s->udp_fd, 1);

        if (ret < 0)

            return ret;

    }



    if (!s->is_connected) {

        ret = sendto (s->udp_fd, buf, size, 0,

                      (struct sockaddr *) &s->dest_addr,

                      s->dest_addr_len);

    } else

        ret = send(s->udp_fd, buf, size, 0);



    return ret < 0 ? ff_neterrno() : ret;

}

static int udp_write(URLContext *h, const uint8_t *buf, int size)

{

    UDPContext *s = h->priv_data;

    int ret;



#if HAVE_PTHREAD_CANCEL

    if (s->fifo) {

        uint8_t tmp[4];



        pthread_mutex_lock(&s->mutex);



        







        if (s->circular_buffer_error<0) {

            int err=s->circular_buffer_error;

            s->circular_buffer_error=0;

            pthread_mutex_unlock(&s->mutex);

            return err;

        }



        if(av_fifo_space(s->fifo) < size + 4) {

            

            pthread_mutex_unlock(&s->mutex);

            return AVERROR(ENOMEM);

        }

        AV_WL32(tmp, size);

        av_fifo_generic_write(s->fifo, tmp, 4, NULL); 

        av_fifo_generic_write(s->fifo, (uint8_t *)buf, size, NULL); 

        pthread_cond_signal(&s->cond);

        pthread_mutex_unlock(&s->mutex);

        return size;

    }

#endif

    if (!(h->flags & AVIO_FLAG_NONBLOCK)) {

        ret = ff_network_wait_fd(s->udp_fd, 1);

        if (ret < 0)

            return ret;

    }



    if (!s->is_connected) {

        ret = sendto (s->udp_fd, buf, size, 0,

                      (struct sockaddr *) &s->dest_addr,

                      s->dest_addr_len);

    } else

        ret = send(s->udp_fd, buf, size, 0);



    return ret < 0 ? ff_neterrno() : ret;

}

    UDPContext *s = h->priv_data;     int ret;     if (!(h->flags & AVIO_FLAG_NONBLOCK)) {         ret = ff_network_wait_fd(s->udp_fd, 1);     if (!s->is_connected) {         ret = sendto (s->udp_fd, buf, size, 0,                       (struct sockaddr *) &s->dest_addr,                       s->dest_addr_len);     } else         ret = send(s->udp_fd, buf, size, 0);         pthread_mutex_lock(&s->mutex);         pthread_mutex_unlock(&s->mutex);             s->circular_buffer_error=0;
static int FUNC_0(URLContext *VAR_0, const uint8_t *VAR_1, int VAR_2)

{

    UDPContext *s = VAR_0->priv_data;

    int VAR_3;



#if HAVE_PTHREAD_CANCEL

    if (s->fifo) {

        uint8_t tmp[4];



        pthread_mutex_lock(&s->mutex);



        







        if (s->circular_buffer_error<0) {

            int err=s->circular_buffer_error;

            s->circular_buffer_error=0;

            pthread_mutex_unlock(&s->mutex);

            return err;

        }



        if(av_fifo_space(s->fifo) < VAR_2 + 4) {

            

            pthread_mutex_unlock(&s->mutex);

            return AVERROR(ENOMEM);

        }

        AV_WL32(tmp, VAR_2);

        av_fifo_generic_write(s->fifo, tmp, 4, NULL); 

        av_fifo_generic_write(s->fifo, (uint8_t *)VAR_1, VAR_2, NULL); 

        pthread_cond_signal(&s->cond);

        pthread_mutex_unlock(&s->mutex);

        return VAR_2;

    }

#endif

    if (!(VAR_0->flags & AVIO_FLAG_NONBLOCK)) {

        VAR_3 = ff_network_wait_fd(s->udp_fd, 1);

        if (VAR_3 < 0)

            return VAR_3;

    }



    if (!s->is_connected) {

        VAR_3 = sendto (s->udp_fd, VAR_1, VAR_2, 0,

                      (struct sockaddr *) &s->dest_addr,

                      s->dest_addr_len);

    } else

        VAR_3 = send(s->udp_fd, VAR_1, VAR_2, 0);



    return VAR_3 < 0 ? ff_neterrno() : VAR_3;

}

static int FUNC_0(URLContext *VAR_0, const uint8_t *VAR_1, int VAR_2)
{ UDPContext *s = VAR_0->priv_data; int VAR_3; #if HAVE_PTHREAD_CANCEL
if (s->fifo) { uint8_t tmp[4]; pthread_mutex_lock(&s->mutex); if (s->circular_buffer_error<0) { int err=s->circular_buffer_error; s->circular_buffer_error=0; pthread_mutex_unlock(&s->mutex); return err; } if(av_fifo_space(s->fifo) < VAR_2 + 4) { pthread_mutex_unlock(&s->mutex); return AVERROR(ENOMEM); } AV_WL32(tmp, VAR_2); av_fifo_generic_write(s->fifo, tmp, 4, NULL); av_fifo_generic_write(s->fifo, (uint8_t *)VAR_1, VAR_2, NULL); pthread_cond_signal(&s->cond); pthread_mutex_unlock(&s->mutex); return VAR_2; } #endif
if (!(VAR_0->flags & AVIO_FLAG_NONBLOCK)) { VAR_3 = ff_network_wait_fd(s->udp_fd, 1); if (VAR_3 < 0)
return VAR_3; } if (!s->is_connected) { VAR_3 = sendto (s->udp_fd, VAR_1, VAR_2, 0,
(struct sockaddr *) &s->dest_addr,
s->dest_addr_len); } else VAR_3 = send(s->udp_fd, VAR_1, VAR_2, 0); return VAR_3 < 0 ? ff_neterrno() : VAR_3; }