procqueue: add item catedory and sub-category fields

This change adds two meta-information fields to the processing
queue item structure. Both of them will be used for more
detailed logging and for the human-readable processing
queue description.
This commit is contained in:
Vadim Yanitskiy 2017-09-09 21:44:16 +03:00
parent 408be3638b
commit 459791c488
8 changed files with 37 additions and 0 deletions

View File

@ -53,6 +53,10 @@ struct osmo_gapk_pq_item {
struct llist_head list;
/*! \brief type of item */
enum osmo_gapk_pq_item_type type;
/*! \brief category name (src, format, codec, sink) */
const char *cat_name;
/*! \brief sub-category name (file, rtp-amr, amr, alsa) */
const char *sub_name;
};
#define VAR_BUF_SIZE 320
@ -70,6 +74,7 @@ struct osmo_gapk_pq *osmo_gapk_pq_create(const char *name);
int osmo_gapk_pq_prepare(struct osmo_gapk_pq *pq);
int osmo_gapk_pq_execute(struct osmo_gapk_pq *pq);
void osmo_gapk_pq_destroy(struct osmo_gapk_pq *pq);
char *osmo_gapk_pq_describe(struct osmo_gapk_pq *pq);
/* Processing queue item management */
struct osmo_gapk_pq_item *osmo_gapk_pq_add_item(struct osmo_gapk_pq *pq);

View File

@ -12,6 +12,7 @@ osmo_gapk_pq_create;
osmo_gapk_pq_prepare;
osmo_gapk_pq_execute;
osmo_gapk_pq_destroy;
osmo_gapk_pq_describe;
osmo_gapk_pq_add_item;

View File

@ -142,6 +142,8 @@ pq_queue_alsa_op(struct osmo_gapk_pq *pq, const char *alsa_dev, unsigned int blk
item->type = in_out_n ?
OSMO_GAPK_ITEM_TYPE_SOURCE : OSMO_GAPK_ITEM_TYPE_SINK;
item->cat_name = in_out_n ? "source" : "sink";
item->sub_name = "alsa";
item->len_in = in_out_n ? 0 : blk_len;
item->len_out = in_out_n ? blk_len : 0;

View File

@ -74,6 +74,10 @@ osmo_gapk_pq_queue_codec(struct osmo_gapk_pq *pq, const struct osmo_gapk_codec_d
item->exit = codec->codec_exit;
item->wait = NULL;
/* Meta information */
item->cat_name = "codec";
item->sub_name = codec->name;
LOGPGAPK(LOGL_DEBUG, "PQ: Adding codec %s, %s format %s\n", codec->name,
enc_dec_n ? "encoding to" : "decoding from", fmt->name);

View File

@ -80,6 +80,8 @@ pq_queue_file_op(struct osmo_gapk_pq *pq, FILE *fh, unsigned int blk_len, int in
item->type = in_out_n ?
OSMO_GAPK_ITEM_TYPE_SOURCE : OSMO_GAPK_ITEM_TYPE_SINK;
item->cat_name = in_out_n ? "source" : "sink";
item->sub_name = "file";
item->len_in = in_out_n ? 0 : blk_len;
item->len_out = in_out_n ? blk_len : 0;

View File

@ -73,5 +73,9 @@ 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;
/* Meta information */
item->cat_name = "format";
item->sub_name = fmt->name;
return 0;
}

View File

@ -226,6 +226,8 @@ pq_queue_rtp_op(struct osmo_gapk_pq *pq, int udp_fd, unsigned int blk_len, int i
item->type = in_out_n ?
OSMO_GAPK_ITEM_TYPE_SOURCE : OSMO_GAPK_ITEM_TYPE_SINK;
item->cat_name = in_out_n ? "source" : "sink";
item->sub_name = "rtp";
item->len_in = in_out_n ? 0 : blk_len;
item->len_out = in_out_n ? blk_len : 0;

View File

@ -176,3 +176,20 @@ osmo_gapk_pq_execute(struct osmo_gapk_pq *pq)
return 0;
}
char *
osmo_gapk_pq_describe(struct osmo_gapk_pq *pq)
{
struct osmo_gapk_pq_item *item;
char *result = NULL;
int i = 0;
/* Iterate over all items in queue */
llist_for_each_entry(item, &pq->items, list) {
result = talloc_asprintf_append(result, "%s/%s%s",
item->cat_name, item->sub_name,
++i < pq->n_items ? " -> " : "");
}
return result;
}