Mercurial > hg > forks > libbpg
comparison libavutil/threadmessage.h @ 0:772086c29cc7
Initial import.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 16 Nov 2016 11:16:33 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:772086c29cc7 |
---|---|
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 | |
22 typedef struct AVThreadMessageQueue AVThreadMessageQueue; | |
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 */ | |
31 AV_THREAD_MESSAGE_NONBLOCK = 1, | |
32 | |
33 } AVThreadMessageFlags; | |
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 */ | |
44 int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, | |
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 */ | |
53 void av_thread_message_queue_free(AVThreadMessageQueue **mq); | |
54 | |
55 /** | |
56 * Send a message on the queue. | |
57 */ | |
58 int av_thread_message_queue_send(AVThreadMessageQueue *mq, | |
59 void *msg, | |
60 unsigned flags); | |
61 | |
62 /** | |
63 * Receive a message from the queue. | |
64 */ | |
65 int av_thread_message_queue_recv(AVThreadMessageQueue *mq, | |
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_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. | |
76 */ | |
77 void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, | |
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_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. | |
87 */ | |
88 void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, | |
89 int err); | |
90 | |
91 #endif /* AVUTIL_THREADMESSAGE_H */ |