1 STATIC
void lock(struct pkt_q_t
*this)
5 r
= pthread_mutex_lock(&this->mutex
);
7 fatalx("%d:unable to lock packet queue\n", this, r
);
9 STATIC
void unlock(struct pkt_q_t
*this)
13 r
= pthread_mutex_unlock(&this->mutex
);
15 fatalx("%d:unable to unlock packet queue\n", this, r
);
17 /* actually rotate the pkt ref ptrs */
18 STATIC
void deq(struct pkt_q_t
*this)
21 avcodec_pkt_ref_t
*save
;
24 memmove(&this->q
[0], &this->q
[1], (this->n
- 1)
25 * sizeof(this->q
[0]));
26 this->q
[this->n
- 1] = save
;
30 /* steal the pkt reference */
31 STATIC
void enq(struct pkt_q_t
*this, avcodec_pkt_ref_t
*pr
)
33 if (this->n
== this->n_max
)
35 avcodec_pkt_move_ref(this->q
[this->n
], pr
);
38 STATIC
void unref_all(struct pkt_q_t
*this)
46 avcodec_pkt_unref(this->q
[pr
]);
51 STATIC
struct pkt_q_t
*new(u8
*msg_hdr
)
56 this = malloc(sizeof(*this));
58 fatal("unable to allocate memory for the %s packet queue\n", msg_hdr
);
62 this->msg_hdr
= strdup(msg_hdr
);
63 r
= pthread_mutex_init(&this->mutex
, 0);
65 fatal("unable to init the mutex for the %s packet queue\n", msg_hdr
);
68 STATIC
bool has_eof(struct pkt_q_t
*this)
71 avcodec_pkt_ref_t
*last
;
73 last
= this->q
[this->n
- 1];
74 if (last
->data
== 0 && last
->sz
== 0)