53 #define MAGIC 0xdeadc0de 131 for (i = 0; i < rd->
workload; i++) {
159 return maxv == minv ? maxv : rand() % (maxv - minv) + minv;
166 int nb_senders, sender_min_load, sender_max_load;
167 int nb_receivers, receiver_min_load, receiver_max_load;
174 "<nb_senders> <sender_min_send> <sender_max_send> " 175 "<nb_receivers> <receiver_min_recv> <receiver_max_recv>\n", av[0]);
179 max_queue_size = atoi(av[1]);
180 nb_senders = atoi(av[2]);
181 sender_min_load = atoi(av[3]);
182 sender_max_load = atoi(av[4]);
183 nb_receivers = atoi(av[5]);
184 receiver_min_load = atoi(av[6]);
185 receiver_max_load = atoi(av[7]);
187 if (max_queue_size <= 0 ||
188 nb_senders <= 0 || sender_min_load <= 0 || sender_max_load <= 0 ||
189 nb_receivers <= 0 || receiver_min_load <= 0 || receiver_max_load <= 0) {
195 "%d receivers receiving [%d-%d]\n", max_queue_size,
196 nb_senders, sender_min_load, sender_max_load,
197 nb_receivers, receiver_min_load, receiver_max_load);
201 if (!senders || !receivers) {
212 #define SPAWN_THREADS(type) do { \ 213 for (i = 0; i < nb_##type##s; i++) { \ 214 struct type##_data *td = &type##s[i]; \ 218 td->workload = get_workload(type##_min_load, type##_max_load); \ 220 ret = pthread_create(&td->tid, NULL, type##_thread, td); \ 222 const int err = AVERROR(ret); \ 223 av_log(NULL, AV_LOG_ERROR, "Unable to start " AV_STRINGIFY(type) \ 224 " thread: %s\n", av_err2str(err)); \ 230 #define WAIT_THREADS(type) do { \ 231 for (i = 0; i < nb_##type##s; i++) { \ 232 struct type##_data *td = &type##s[i]; \ 234 ret = pthread_join(td->tid, NULL); \ 236 const int err = AVERROR(ret); \ 237 av_log(NULL, AV_LOG_ERROR, "Unable to join " AV_STRINGIFY(type) \ 238 " thread: %s\n", av_err2str(err)); \
const char const char void * val
This structure describes decoded (raw) audio or video data.
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
static int get_workload(int minv, int maxv)
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...
AVThreadMessageQueue * queue
#define SPAWN_THREADS(type)
static void * sender_thread(void *arg)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_thread_message_queue_recv(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Receive a message from the queue.
static av_cold int end(AVCodecContext *avctx)
int av_thread_message_queue_send(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Send a message on the queue.
static void * receiver_thread(void *arg)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_EOF
End of file.
AVDictionary * metadata
metadata.
AVThreadMessageQueue * queue
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_thread_message_flush(AVThreadMessageQueue *mq)
Flush the message queue.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
simple assert() macros that are a bit more flexible than ISO C assert().
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
reference-counted frame API
char * av_asprintf(const char *fmt,...)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#define AV_LOG_INFO
Standard information.
void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, int err)
Set the sending error code.
int main(int ac, char **av)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, unsigned nelem, unsigned elsize)
Allocate a new message queue.
#define WAIT_THREADS(type)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_thread_message_queue_free(AVThreadMessageQueue **mq)
Free a message queue.
static void free_frame(void *arg)
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().