FFmpeg
threadmessage.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVUTIL_THREADMESSAGE_H
20 #define AVUTIL_THREADMESSAGE_H
21 
23 
24 typedef enum AVThreadMessageFlags {
25 
26  /**
27  * Perform non-blocking operation.
28  * If this flag is set, send and recv operations are non-blocking and
29  * return AVERROR(EAGAIN) immediately if they can not proceed.
30  */
32 
34 
35 /**
36  * Allocate a new message queue.
37  *
38  * @param mq pointer to the message queue
39  * @param nelem maximum number of elements in the queue
40  * @param elsize size of each element in the queue
41  * @return >=0 for success; <0 for error, in particular AVERROR(ENOSYS) if
42  * lavu was built without thread support
43  */
45  unsigned nelem,
46  unsigned elsize);
47 
48 /**
49  * Free a message queue.
50  *
51  * The message queue must no longer be in use by another thread.
52  */
54 
55 /**
56  * Send a message on the queue.
57  */
59  void *msg,
60  unsigned flags);
61 
62 /**
63  * Receive a message from the queue.
64  */
66  void *msg,
67  unsigned flags);
68 
69 /**
70  * Set the sending error code.
71  *
72  * If the error code is set to non-zero, av_thread_message_queue_send() will
73  * return it immediately. Conventional values, such as AVERROR_EOF or
74  * AVERROR(EAGAIN), can be used to cause the sending thread to stop or
75  * suspend its operation.
76  */
78  int err);
79 
80 /**
81  * Set the receiving error code.
82  *
83  * If the error code is set to non-zero, av_thread_message_queue_recv() will
84  * return it immediately when there are no longer available messages.
85  * Conventional values, such as AVERROR_EOF or AVERROR(EAGAIN), can be used
86  * to cause the receiving thread to stop or suspend its operation.
87  */
89  int err);
90 
91 /**
92  * Set the optional free message callback function which will be called if an
93  * operation is removing messages from the queue.
94  */
96  void (*free_func)(void *msg));
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  */
105 
106 /**
107  * Flush the message queue
108  *
109  * This function is mostly equivalent to reading and free-ing every message
110  * except that it will be done in a single operation (no lock/unlock between
111  * reads).
112  */
114 
115 #endif /* AVUTIL_THREADMESSAGE_H */
AV_THREAD_MESSAGE_NONBLOCK
@ AV_THREAD_MESSAGE_NONBLOCK
Perform non-blocking operation.
Definition: threadmessage.h:31
av_thread_message_queue_set_err_recv
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
Definition: threadmessage.c:204
av_thread_message_queue_set_free_func
void av_thread_message_queue_set_free_func(AVThreadMessageQueue *mq, void(*free_func)(void *msg))
Set the optional free message callback function which will be called if an operation is removing mess...
Definition: threadmessage.c:88
av_thread_message_flush
void av_thread_message_flush(AVThreadMessageQueue *mq)
Flush the message queue.
Definition: threadmessage.c:226
av_thread_message_queue_set_err_send
void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, int err)
Set the sending error code.
Definition: threadmessage.c:193
AVThreadMessageQueue
Definition: threadmessage.c:30
av_thread_message_queue_send
int av_thread_message_queue_send(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Send a message on the queue.
Definition: threadmessage.c:161
av_thread_message_queue_alloc
int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, unsigned nelem, unsigned elsize)
Allocate a new message queue.
Definition: threadmessage.c:45
av_thread_message_queue_recv
int av_thread_message_queue_recv(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Receive a message from the queue.
Definition: threadmessage.c:177
av_thread_message_queue_nb_elems
int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq)
Return the current number of messages in the queue.
Definition: threadmessage.c:110
av_thread_message_queue_free
void av_thread_message_queue_free(AVThreadMessageQueue **mq)
Free a message queue.
Definition: threadmessage.c:96
AVThreadMessageFlags
AVThreadMessageFlags
Definition: threadmessage.h:24
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474