2 * This file is part of FFmpeg.
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.
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.
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
19 #ifndef AVUTIL_THREADMESSAGE_H
20 #define AVUTIL_THREADMESSAGE_H
22 typedef struct AVThreadMessageQueue AVThreadMessageQueue;
24 typedef enum AVThreadMessageFlags {
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.
31 AV_THREAD_MESSAGE_NONBLOCK = 1,
33 } AVThreadMessageFlags;
36 * Allocate a new message queue.
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
44 int av_thread_message_queue_alloc(AVThreadMessageQueue **mq,
49 * Free a message queue.
51 * The message queue must no longer be in use by another thread.
53 void av_thread_message_queue_free(AVThreadMessageQueue **mq);
56 * Send a message on the queue.
58 int av_thread_message_queue_send(AVThreadMessageQueue *mq,
63 * Receive a message from the queue.
65 int av_thread_message_queue_recv(AVThreadMessageQueue *mq,
70 * Set the sending error code.
72 * If the error code is set to non-zero, av_thread_message_queue_recv() will
73 * return it immediately when there are no longer available messages.
74 * Conventional values, such as AVERROR_EOF or AVERROR(EAGAIN), can be used
75 * to cause the receiving thread to stop or suspend its operation.
77 void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq,
81 * Set the receiving error code.
83 * If the error code is set to non-zero, av_thread_message_queue_send() will
84 * return it immediately. Conventional values, such as AVERROR_EOF or
85 * AVERROR(EAGAIN), can be used to cause the sending thread to stop or
86 * suspend its operation.
88 void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq,
91 #endif /* AVUTIL_THREADMESSAGE_H */