summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-07 18:42:49 +0300
committerVadim Yanitskiy <axilirator@gmail.com>2017-12-31 12:20:59 +0100
commit1f6f807bb35228f7d6f50cf61283b9ceb8f46eee (patch)
tree9028c4ca2eee9b5e422cf4aaa40f3997fc824720
parentb40a54dc97e28e31e4a9be8a3aa634eaafb219d5 (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.h1
-rw-r--r--src/pq_alsa.c1
-rw-r--r--src/pq_codec.c1
-rw-r--r--src/pq_file.c1
-rw-r--r--src/pq_format.c1
-rw-r--r--src/pq_rtp.c1
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;