npv:vulkan synchronization less wrong
[nyanmp.git] / npv / pipeline / public / code.frag.c
blobbe4a0a172d8b1bf181d77bc7691ea3cf2eb9e04b
1 STATIC void limits_reset(void)
3 limits_p.pkts.bytes_n = 0;
4 limits_p.pkts.limit.bytes_n = PIPELINE_BYTES_N_MAX;
6 STATIC void prefill_reset(u8 percent)
8 if (percent > 100)
9 fatal("invalid prefill of %u%% for the buffer for packet queues\n", percent);
10 if (percent != 0) {
11 limits_p.pkts.prefill.bytes_rem =
12 limits_p.pkts.limit.bytes_n * percent / 100;
13 pout("prefill size for the buffer for packet queues is %u%%/%"PRId64" bytes (100%%=%"PRId64" bytes)\n", percent, limits_p.pkts.prefill.bytes_rem, PIPELINE_BYTES_N_MAX);
14 } else {
15 limits_p.pkts.prefill.bytes_rem = 0;
16 pout("prefill for the buffer for packet queues is disabled\n");
19 STATIC void init_once(void)
21 int r;
23 eof_pkt_l = avcodec_pkt_ref_alloc();
24 if (eof_pkt_l == 0)
25 fatal("ffmpeg:unable to allocate a null/eof reference on a packet\n");
26 eof_pkt_l->data = 0;
27 eof_pkt_l->sz = 0;
29 r = pthread_mutex_init(&limits_p.mutex, 0);
30 if (r != 0)
31 fatal("unable to initialize the mutex to guard the accounting of limits\n");
32 memset(&rate_limiter_previous_tp, 0, sizeof(rate_limiter_previous_tp));
34 STATIC void limits_lock(void)
36 int r;
38 r = pthread_mutex_lock(&limits_p.mutex);
39 if (r != 0)
40 fatal("unable to lock the limits\n");
42 STATIC void limits_unlock(void)
44 int r;
46 r = pthread_mutex_unlock(&limits_p.mutex);
47 if (r != 0)
48 fatal("unable to unlock the limits\n");
50 STATIC void read_thd_start(void)
52 int r;
53 pthread_t id;
54 pthread_attr_t attr;
56 r = pthread_attr_init(&attr);
57 if (r != 0)
58 fatal("unable to initialize read thread attribute\n");
59 r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
60 if (r != 0)
61 fatal("unable to set the read thread attribute to detach mode\n");
62 r = pthread_create(&id, &attr, &read_thd_entry, 0);
63 if (r != 0)
64 fatal("unable to create the read thread\n");
65 pout("read thread %lu\n", (unsigned long)id);
66 pthread_attr_destroy(&attr);
68 STATIC void audio_thd_start(void)
70 int r;
71 pthread_t id;
72 pthread_attr_t attr;
74 r = pthread_attr_init(&attr);
75 if (r != 0)
76 fatal("unable to initialize audio thread attribute\n");
77 r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
78 if (r != 0)
79 fatal("unable to set the audio thread attribute to detach mode\n");
80 r = pthread_create(&id, &attr, &audio_thd_entry, 0);
81 if (r != 0)
82 fatal("unable to create the audio thread\n");
83 pout("audio thread %lu\n", (unsigned long)id);
84 pthread_attr_destroy(&attr);
86 STATIC void video_thd_start(void)
88 int r;
89 pthread_t id;
90 pthread_attr_t attr;
92 r = pthread_attr_init(&attr);
93 if (r != 0)
94 fatal("unable to initialize video thread attribute\n");
95 r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
96 if (r != 0)
97 fatal("unable to set the video thread attribute to detach mode\n");
98 r = pthread_create(&id, &attr, &video_thd_entry, 0);
99 if (r != 0)
100 fatal("unable to create the video thread\n");
101 pout("video thread %lu\n", (unsigned long)id);
102 pthread_attr_destroy(&attr);