mirror of https://gerrit.osmocom.org/gapk
procqueue: add processing state callback
In some cases it's required to wait for some queue items to finish processing. For example, the ALSA sink writes the audio samples to the buffer in non-blocking mode, so as soon as all of them will be written, a program may finish execution, causing the playback abort. To prevent that, this change extends the library's API, allowing each queue item to have a processing state callback that returns a positive integer if processing is not finished yet, and 0 otherwise.
This commit is contained in:
parent
b40a54dc97
commit
1f6f807bb3
|
@ -40,6 +40,7 @@ struct osmo_gapk_pq_item {
|
|||
* \param[in] in_len length of input data \a in
|
||||
* \returns number of output bytes written to \a out; negative on error */
|
||||
int (*proc)(void *state, uint8_t *out, const uint8_t *in, unsigned int in_len);
|
||||
int (*wait)(void *state);
|
||||
void (*exit)(void *state);
|
||||
|
||||
/*! \brief link to a processing queue */
|
||||
|
|
|
@ -138,6 +138,7 @@ pq_queue_alsa_op(struct osmo_gapk_pq *pq, const char *alsa_dev, unsigned int blk
|
|||
item->len_out = in_out_n ? blk_len : 0;
|
||||
item->state = state;
|
||||
item->proc = in_out_n ? pq_cb_alsa_input : pq_cb_alsa_output;
|
||||
item->wait = NULL;
|
||||
item->exit = pq_cb_alsa_exit;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -71,6 +71,7 @@ osmo_gapk_pq_queue_codec(struct osmo_gapk_pq *pq, const struct osmo_gapk_codec_d
|
|||
}
|
||||
|
||||
item->exit = codec->codec_exit;
|
||||
item->wait = NULL;
|
||||
|
||||
LOGPGAPK(LOGL_DEBUG, "PQ: Adding codec %s, %s format %s\n", codec->name,
|
||||
enc_dec_n ? "encoding to" : "decoding from", fmt->name);
|
||||
|
|
|
@ -83,6 +83,7 @@ pq_queue_file_op(struct osmo_gapk_pq *pq, FILE *fh, unsigned int blk_len, int in
|
|||
item->len_out = in_out_n ? blk_len : 0;
|
||||
item->state = state;
|
||||
item->proc = in_out_n ? pq_cb_file_input : pq_cb_file_output;
|
||||
item->wait = NULL;
|
||||
item->exit = pq_cb_file_exit;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -70,6 +70,7 @@ osmo_gapk_pq_queue_fmt_convert(struct osmo_gapk_pq *pq, const struct osmo_gapk_f
|
|||
}
|
||||
|
||||
item->proc = pq_cb_fmt_convert;
|
||||
item->wait = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -229,6 +229,7 @@ pq_queue_rtp_op(struct osmo_gapk_pq *pq, int udp_fd, unsigned int blk_len, int i
|
|||
item->len_out = in_out_n ? blk_len : 0;
|
||||
item->state = state;
|
||||
item->proc = in_out_n ? pq_cb_rtp_input : pq_cb_rtp_output;
|
||||
item->wait = NULL;
|
||||
item->exit = pq_cb_rtp_exit;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue