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
)
9 fatal("invalid prefill of %u%% for the buffer for packet queues\n", percent
);
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
);
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)
23 eof_pkt_l
= avcodec_pkt_ref_alloc();
25 fatal("ffmpeg:unable to allocate a null/eof reference on a packet\n");
29 r
= pthread_mutex_init(&limits_p
.mutex
, 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)
38 r
= pthread_mutex_lock(&limits_p
.mutex
);
40 fatal("unable to lock the limits\n");
42 STATIC
void limits_unlock(void)
46 r
= pthread_mutex_unlock(&limits_p
.mutex
);
48 fatal("unable to unlock the limits\n");
50 STATIC
void read_thd_start(void)
56 r
= pthread_attr_init(&attr
);
58 fatal("unable to initialize read thread attribute\n");
59 r
= pthread_attr_setdetachstate(&attr
, PTHREAD_CREATE_DETACHED
);
61 fatal("unable to set the read thread attribute to detach mode\n");
62 r
= pthread_create(&id
, &attr
, &read_thd_entry
, 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)
74 r
= pthread_attr_init(&attr
);
76 fatal("unable to initialize audio thread attribute\n");
77 r
= pthread_attr_setdetachstate(&attr
, PTHREAD_CREATE_DETACHED
);
79 fatal("unable to set the audio thread attribute to detach mode\n");
80 r
= pthread_create(&id
, &attr
, &audio_thd_entry
, 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)
92 r
= pthread_attr_init(&attr
);
94 fatal("unable to initialize video thread attribute\n");
95 r
= pthread_attr_setdetachstate(&attr
, PTHREAD_CREATE_DETACHED
);
97 fatal("unable to set the video thread attribute to detach mode\n");
98 r
= pthread_create(&id
, &attr
, &video_thd_entry
, 0);
100 fatal("unable to create the video thread\n");
101 pout("video thread %lu\n", (unsigned long)id
);
102 pthread_attr_destroy(&attr
);