summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2018-04-21 21:42:19 +0200
committerClément Bœsch <u@pkh.me>2018-04-26 19:41:19 +0200
commit71fa82bed62f812d30aee26f3c6385e2ec890ebb (patch)
treec31086aa145158b69342c779a9e174dccb741e43 /libavutil
parent02e4970bc9d3215f862a5d64ec48922d98eb17c1 (diff)
lavu/threadmessage: add av_thread_message_queue_nb_elems()
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/threadmessage.c13
-rw-r--r--libavutil/threadmessage.h8
-rw-r--r--libavutil/version.h2
3 files changed, 22 insertions, 1 deletions
diff --git a/libavutil/threadmessage.c b/libavutil/threadmessage.c
index 872e9392b1..764b7fb813 100644
--- a/libavutil/threadmessage.c
+++ b/libavutil/threadmessage.c
@@ -102,6 +102,19 @@ void av_thread_message_queue_free(AVThreadMessageQueue **mq)
#endif
}
+int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq)
+{
+#if HAVE_THREADS
+ int ret;
+ pthread_mutex_lock(&mq->lock);
+ ret = av_fifo_size(mq->fifo);
+ pthread_mutex_unlock(&mq->lock);
+ return ret / mq->elsize;
+#else
+ return AVERROR(ENOSYS);
+#endif
+}
+
#if HAVE_THREADS
static int av_thread_message_queue_send_locked(AVThreadMessageQueue *mq,
diff --git a/libavutil/threadmessage.h b/libavutil/threadmessage.h
index 8480a0a3db..42ce655f36 100644
--- a/libavutil/threadmessage.h
+++ b/libavutil/threadmessage.h
@@ -96,6 +96,14 @@ void av_thread_message_queue_set_free_func(AVThreadMessageQueue *mq,
void (*free_func)(void *msg));
/**
+ * Return the current number of messages in the queue.
+ *
+ * @return the current number of messages or AVERROR(ENOSYS) if lavu was built
+ * without thread support
+ */
+int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq);
+
+/**
* Flush the message queue
*
* This function is mostly equivalent to reading and free-ing every message
diff --git a/libavutil/version.h b/libavutil/version.h
index 387421775f..23567000a3 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR 15
+#define LIBAVUTIL_VERSION_MINOR 16
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \