Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 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 | 21 | -------- 8< --------- FFmpeg 4.0 was cut here -------- 8< --------- |
| 19 | 22 | |
| 20 | 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 | 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 | 118 | #if HAVE_THREADS |
| 106 | 119 | |
| 107 | 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 | 95 | void av_thread_message_queue_set_free_func(AVThreadMessageQueue *mq, |
| 96 | 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 | 107 | * Flush the message queue |
| 100 | 108 | * |
| @@ -79,7 +79,7 @@ · 78 unmodified lines | ||
| 79 | 79 | */ |
| 80 | 80 | |
| 81 | 81 | #define LIBAVUTIL_VERSION_MAJOR 56 |
| 82 | −#define LIBAVUTIL_VERSION_MINOR 15 | |
| 82 | +#define LIBAVUTIL_VERSION_MINOR 16 | |
| 83 | 83 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 84 | 84 | |
| 85 | 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 | 131 | for (i = 0; i < rd->workload; i++) { |
| 132 | 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 | 136 | av_thread_message_flush(rd->queue); |
| 135 | 137 | } else { |
| 136 | 138 | struct message msg; |