lavu/threadmessage: add av_thread_message_queue_nb_elems()

This commit is contained in:
Clément Bœsch
2018-04-21 21:42:19 +02:00
parent 02e4970bc9
commit 71fa82bed6
5 changed files with 28 additions and 2 deletions

View File

@@ -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,

View File

@@ -95,6 +95,14 @@ void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq,
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
*

View File

@@ -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, \