diff --git a/libavformat/udp.c b/libavformat/udp.c
index cdcd136..a49b94d 100644
|
a
|
b
|
typedef struct {
|
| 71 | 71 | pthread_t circular_buffer_thread; |
| 72 | 72 | pthread_mutex_t mutex; |
| 73 | 73 | pthread_cond_t cond; |
| | 74 | int exit_thread; |
| 74 | 75 | #endif |
| 75 | 76 | uint8_t tmp[UDP_MAX_PKT_SIZE+4]; |
| 76 | 77 | int remaining_in_dg; |
| … |
… |
static void *circular_buffer_task( void *_URLContext)
|
| 327 | 328 | fd_set rfds; |
| 328 | 329 | struct timeval tv; |
| 329 | 330 | |
| 330 | | for(;;) { |
| | 331 | while(!s->exit_thread) { |
| 331 | 332 | int left; |
| 332 | 333 | int ret; |
| 333 | 334 | int len; |
| … |
… |
static int udp_open(URLContext *h, const char *uri, int flags)
|
| 529 | 530 | s->fifo = av_fifo_alloc(s->circular_buffer_size); |
| 530 | 531 | pthread_mutex_init(&s->mutex, NULL); |
| 531 | 532 | pthread_cond_init(&s->cond, NULL); |
| | 533 | s->exit_thread = 0; |
| 532 | 534 | if (pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, h)) { |
| 533 | 535 | av_log(h, AV_LOG_ERROR, "pthread_create failed\n"); |
| 534 | 536 | goto fail; |
| … |
… |
static int udp_write(URLContext *h, const uint8_t *buf, int size)
|
| 617 | 619 | static int udp_close(URLContext *h) |
| 618 | 620 | { |
| 619 | 621 | UDPContext *s = h->priv_data; |
| | 622 | int ret; |
| 620 | 623 | |
| 621 | 624 | if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) |
| 622 | 625 | udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr); |
| 623 | 626 | closesocket(s->udp_fd); |
| 624 | 627 | av_fifo_free(s->fifo); |
| 625 | 628 | #if HAVE_PTHREADS |
| | 629 | s->exit_thread = 1; |
| | 630 | ret = pthread_join(s->circular_buffer_thread, NULL); |
| | 631 | if (ret != 0) |
| | 632 | { |
| | 633 | av_log(h, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret)); |
| | 634 | } |
| 626 | 635 | pthread_mutex_destroy(&s->mutex); |
| 627 | 636 | pthread_cond_destroy(&s->cond); |
| 628 | 637 | #endif |