diff options
| author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-07 18:42:49 +0300 |
|---|---|---|
| committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-08 00:13:42 +0300 |
| commit | 8923276018b9a8d5ebafa2e18676fe6b8cef26a4 (patch) | |
| tree | d33348964ef4899d5da2988471ef7b985c60be8a | |
| parent | 3e8cfdea6a2e1da03b6601c96b87d2a5683c73c6 (diff) | |
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.
| -rw-r--r-- | include/osmocom/gapk/procqueue.h | 1 | ||||
| -rw-r--r-- | src/pq_alsa.c | 1 | ||||
| -rw-r--r-- | src/pq_codec.c | 1 | ||||
| -rw-r--r-- | src/pq_file.c | 1 | ||||
| -rw-r--r-- | src/pq_format.c | 1 | ||||
| -rw-r--r-- | src/pq_rtp.c | 1 |
6 files changed, 6 insertions, 0 deletions
diff --git a/include/osmocom/gapk/procqueue.h b/include/osmocom/gapk/procqueue.h index a72fd61..9b049a5 100644 --- a/include/osmocom/gapk/procqueue.h +++ b/include/osmocom/gapk/procqueue.h @@ -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 */ diff --git a/src/pq_alsa.c b/src/pq_alsa.c index b91457e..779dd96 100644 --- a/src/pq_alsa.c +++ b/src/pq_alsa.c @@ -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; diff --git a/src/pq_codec.c b/src/pq_codec.c index f5da628..e033a7d 100644 --- a/src/pq_codec.c +++ b/src/pq_codec.c @@ -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); diff --git a/src/pq_file.c b/src/pq_file.c index b31ef52..d05f82a 100644 --- a/src/pq_file.c +++ b/src/pq_file.c @@ -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; diff --git a/src/pq_format.c b/src/pq_format.c index ae5386e..8ea8b86 100644 --- a/src/pq_format.c +++ b/src/pq_format.c @@ -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; } diff --git a/src/pq_rtp.c b/src/pq_rtp.c index 6e7a87d..1c37475 100644 --- a/src/pq_rtp.c +++ b/src/pq_rtp.c @@ -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; |
