From 408be3638b3cd84462632ae8fe0b92e93064ca57 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sat, 9 Sep 2017 20:57:13 +0300 Subject: [PATCH] procqueue: add item type enum (source, sink, proc) There are currently three types of prcessing queue items: - source (file, alsa, rtp) - proc (format, codec) - sink (file, alsa, rtp) Let's assign corresponding type for each item. This would facilitate logging and the queue checking. --- include/osmocom/gapk/procqueue.h | 8 ++++++++ src/libosmogapk.map | 1 + src/pq_alsa.c | 3 +++ src/pq_codec.c | 1 + src/pq_file.c | 3 +++ src/pq_format.c | 1 + src/pq_rtp.c | 3 +++ 7 files changed, 20 insertions(+) diff --git a/include/osmocom/gapk/procqueue.h b/include/osmocom/gapk/procqueue.h index dfd0db1..f5b8d53 100644 --- a/include/osmocom/gapk/procqueue.h +++ b/include/osmocom/gapk/procqueue.h @@ -24,6 +24,12 @@ #include +enum osmo_gapk_pq_item_type { + OSMO_GAPK_ITEM_TYPE_SOURCE, + OSMO_GAPK_ITEM_TYPE_SINK, + OSMO_GAPK_ITEM_TYPE_PROC, +}; + struct osmo_gapk_pq_item { /*! input frame size (in bytes). '0' in case of variable frames */ unsigned int len_in; @@ -45,6 +51,8 @@ struct osmo_gapk_pq_item { /*! \brief link to a processing queue */ struct llist_head list; + /*! \brief type of item */ + enum osmo_gapk_pq_item_type type; }; #define VAR_BUF_SIZE 320 diff --git a/src/libosmogapk.map b/src/libosmogapk.map index a6ce08d..e704c31 100644 --- a/src/libosmogapk.map +++ b/src/libosmogapk.map @@ -6,6 +6,7 @@ osmo_gapk_set_talloc_ctx; osmo_gapk_pq; osmo_gapk_pq_item; +osmo_gapk_pq_item_type; osmo_gapk_pq_create; osmo_gapk_pq_prepare; diff --git a/src/pq_alsa.c b/src/pq_alsa.c index 8355349..3025c2a 100644 --- a/src/pq_alsa.c +++ b/src/pq_alsa.c @@ -140,6 +140,9 @@ pq_queue_alsa_op(struct osmo_gapk_pq *pq, const char *alsa_dev, unsigned int blk goto out_close; } + item->type = in_out_n ? + OSMO_GAPK_ITEM_TYPE_SOURCE : OSMO_GAPK_ITEM_TYPE_SINK; + item->len_in = in_out_n ? 0 : blk_len; item->len_out = in_out_n ? blk_len : 0; item->state = state; diff --git a/src/pq_codec.c b/src/pq_codec.c index e033a7d..db99d5c 100644 --- a/src/pq_codec.c +++ b/src/pq_codec.c @@ -70,6 +70,7 @@ osmo_gapk_pq_queue_codec(struct osmo_gapk_pq *pq, const struct osmo_gapk_codec_d item->proc = codec->codec_decode; } + item->type = OSMO_GAPK_ITEM_TYPE_PROC; item->exit = codec->codec_exit; item->wait = NULL; diff --git a/src/pq_file.c b/src/pq_file.c index f3bb9a3..73a7099 100644 --- a/src/pq_file.c +++ b/src/pq_file.c @@ -78,6 +78,9 @@ pq_queue_file_op(struct osmo_gapk_pq *pq, FILE *fh, unsigned int blk_len, int in return -ENOMEM; } + item->type = in_out_n ? + OSMO_GAPK_ITEM_TYPE_SOURCE : OSMO_GAPK_ITEM_TYPE_SINK; + item->len_in = in_out_n ? 0 : blk_len; item->len_out = in_out_n ? blk_len : 0; item->state = state; diff --git a/src/pq_format.c b/src/pq_format.c index 8ea8b86..dad1d9e 100644 --- a/src/pq_format.c +++ b/src/pq_format.c @@ -69,6 +69,7 @@ osmo_gapk_pq_queue_fmt_convert(struct osmo_gapk_pq *pq, const struct osmo_gapk_f item->state = fmt->conv_to_canon; } + item->type = OSMO_GAPK_ITEM_TYPE_PROC; item->proc = pq_cb_fmt_convert; item->wait = NULL; diff --git a/src/pq_rtp.c b/src/pq_rtp.c index 27b868c..799b324 100644 --- a/src/pq_rtp.c +++ b/src/pq_rtp.c @@ -224,6 +224,9 @@ pq_queue_rtp_op(struct osmo_gapk_pq *pq, int udp_fd, unsigned int blk_len, int i return -ENOMEM; } + item->type = in_out_n ? + OSMO_GAPK_ITEM_TYPE_SOURCE : OSMO_GAPK_ITEM_TYPE_SINK; + item->len_in = in_out_n ? 0 : blk_len; item->len_out = in_out_n ? blk_len : 0; item->state = state;