Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines | |||
| 15 | 15 | ||
| 16 | API changes, most recent first: | 16 | API changes, most recent first: |
| 17 | 17 | ||
| 18 | 2018-04-xx - xxxxxxxxxx - lavu 56.16.100 - threadmessage.h | ||
| 19 | Add av_thread_message_queue_nb_elems(). | ||
| 20 | |||
| 18 | -------- 8< --------- FFmpeg 4.0 was cut here -------- 8< --------- | 21 | -------- 8< --------- FFmpeg 4.0 was cut here -------- 8< --------- |
| 19 | 22 | ||
| 20 | 2018-04-03 - d6fc031caf - lavu 56.13.100 - pixdesc.h | 23 | 2018-04-03 - d6fc031caf - lavu 56.13.100 - pixdesc.h |
| @@ -102,6 +102,19 @@ void av_thread_message_queue_free(AVThreadMessageQueue **mq) · 101 unmodified lines | |||
| 102 | #endif | 102 | #endif |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq) | ||
| 106 | { | ||
| 107 | #if HAVE_THREADS | ||
| 108 | int ret; | ||
| 109 | pthread_mutex_lock(&mq->lock); | ||
| 110 | ret = av_fifo_size(mq->fifo); | ||
| 111 | pthread_mutex_unlock(&mq->lock); | ||
| 112 | return ret / mq->elsize; | ||
| 113 | #else | ||
| 114 | return AVERROR(ENOSYS); | ||
| 115 | #endif | ||
| 116 | } | ||
| 117 | |||
| 105 | #if HAVE_THREADS | 118 | #if HAVE_THREADS |
| 106 | 119 | ||
| 107 | static int av_thread_message_queue_send_locked(AVThreadMessageQueue *mq, | 120 | static int av_thread_message_queue_send_locked(AVThreadMessageQueue *mq, |
| @@ -95,6 +95,14 @@ void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, · 94 unmodified lines | |||
| 95 | void av_thread_message_queue_set_free_func(AVThreadMessageQueue *mq, | 95 | void av_thread_message_queue_set_free_func(AVThreadMessageQueue *mq, |
| 96 | void (*free_func)(void *msg)); | 96 | void (*free_func)(void *msg)); |
| 97 | 97 | ||
| 98 | /** | ||
| 99 | * Return the current number of messages in the queue. | ||
| 100 | * | ||
| 101 | * @return the current number of messages or AVERROR(ENOSYS) if lavu was built | ||
| 102 | * without thread support | ||
| 103 | */ | ||
| 104 | int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq); | ||
| 105 | |||
| 98 | /** | 106 | /** |
| 99 | * Flush the message queue | 107 | * Flush the message queue |
| 100 | * | 108 | * |
| @@ -79,7 +79,7 @@ · 78 unmodified lines | |||
| 79 | */ | 79 | */ |
| 80 | 80 | ||
| 81 | #define LIBAVUTIL_VERSION_MAJOR 56 | 81 | #define LIBAVUTIL_VERSION_MAJOR 56 |
| 82 | #define LIBAVUTIL_VERSION_MINOR 15 | 82 | #define LIBAVUTIL_VERSION_MINOR 16 |
| 83 | #define LIBAVUTIL_VERSION_MICRO 100 | 83 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 84 | 84 | ||
| 85 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 85 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -130,7 +130,9 @@ static void *receiver_thread(void *arg) · 129 unmodified lines | |||
| 130 | 130 | ||
| 131 | for (i = 0; i < rd->workload; i++) { | 131 | for (i = 0; i < rd->workload; i++) { |
| 132 | if (rand() % rd->workload < rd->workload / 10) { | 132 | if (rand() % rd->workload < rd->workload / 10) { |
| 133 | av_log(NULL, AV_LOG_INFO, "receiver #%d: flushing the queue\n", rd->id); | 133 | av_log(NULL, AV_LOG_INFO, "receiver #%d: flushing the queue, " |
| 134 | "discarding %d message(s)\n", rd->id, | ||
| 135 | av_thread_message_queue_nb_elems(rd->queue)); | ||
| 134 | av_thread_message_flush(rd->queue); | 136 | av_thread_message_flush(rd->queue); |
| 135 | } else { | 137 | } else { |
| 136 | struct message msg; | 138 | struct message msg; |