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 moduleffmpeg.libavutil.threadmessage;
20 21 extern (C):
22 importffmpeg; @nogcnothrow:
23 24 structAVThreadMessageQueue;
25 26 enumAVThreadMessageFlags27 {
28 /**
29 * Perform non-blocking operation.
30 * If this flag is set, send and recv operations are non-blocking and
31 * return AVERROR(EAGAIN) immediately if they can not proceed.
32 */33 AV_THREAD_MESSAGE_NONBLOCK = 134 }
35 36 /**
37 * Allocate a new message queue.
38 *
39 * @param mq pointer to the message queue
40 * @param nelem maximum number of elements in the queue
41 * @param elsize size of each element in the queue
42 * @return >=0 for success; <0 for error, in particular AVERROR(ENOSYS) if
43 * lavu was built without thread support
44 */45 intav_thread_message_queue_alloc (
46 AVThreadMessageQueue** mq,
47 uintnelem,
48 uintelsize);
49 50 /**
51 * Free a message queue.
52 *
53 * The message queue must no longer be in use by another thread.
54 */55 voidav_thread_message_queue_free (AVThreadMessageQueue** mq);
56 57 /**
58 * Send a message on the queue.
59 */60 intav_thread_message_queue_send (
61 AVThreadMessageQueue* mq,
62 void* msg,
63 uintflags);
64 65 /**
66 * Receive a message from the queue.
67 */68 intav_thread_message_queue_recv (
69 AVThreadMessageQueue* mq,
70 void* msg,
71 uintflags);
72 73 /**
74 * Set the sending error code.
75 *
76 * If the error code is set to non-zero, av_thread_message_queue_send() will
77 * return it immediately. Conventional values, such as AVERROR_EOF or
78 * AVERROR(EAGAIN), can be used to cause the sending thread to stop or
79 * suspend its operation.
80 */81 voidav_thread_message_queue_set_err_send (AVThreadMessageQueue* mq, interr);
82 83 /**
84 * Set the receiving error code.
85 *
86 * If the error code is set to non-zero, av_thread_message_queue_recv() will
87 * return it immediately when there are no longer available messages.
88 * Conventional values, such as AVERROR_EOF or AVERROR(EAGAIN), can be used
89 * to cause the receiving thread to stop or suspend its operation.
90 */91 voidav_thread_message_queue_set_err_recv (AVThreadMessageQueue* mq, interr);
92 93 /**
94 * Set the optional free message callback function which will be called if an
95 * operation is removing messages from the queue.
96 */97 voidav_thread_message_queue_set_free_func (
98 AVThreadMessageQueue* mq,
99 voidfunction (void* msg) free_func);
100 101 /**
102 * Return the current number of messages in the queue.
103 *
104 * @return the current number of messages or AVERROR(ENOSYS) if lavu was built
105 * without thread support
106 */107 intav_thread_message_queue_nb_elems (AVThreadMessageQueue* mq);
108 109 /**
110 * Flush the message queue
111 *
112 * This function is mostly equivalent to reading and free-ing every message
113 * except that it will be done in a single operation (no lock/unlock between
114 * reads).
115 */116 voidav_thread_message_flush (AVThreadMessageQueue* mq);
117 118 /* AVUTIL_THREADMESSAGE_H */