aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-01-15 00:25:44 +0600
committerVadim Yanitskiy <axilirator@gmail.com>2018-01-15 00:25:44 +0600
commit6f34c8f3017629ea4865543e901b61ac893e0356 (patch)
tree6d2b2bb04c12deb839a27bba03030c28030302d2
parent2254861efb0216b55d04926b339220ecf9e31aa5 (diff)
procqueue: introduce and use shared cat_name definitions
Let's use the common string representation for item category names, defined in the shared header, instead of defining them in every file. Change-Id: Ie0c449d77fa383cad27f67b8ce902bd071342dbb
-rw-r--r--include/osmocom/gapk/procqueue.h4
-rw-r--r--src/pq_alsa.c3
-rw-r--r--src/pq_file.c3
-rw-r--r--src/pq_rtp.c3
-rw-r--r--tests/io/pq_rtp_test.c4
-rw-r--r--tests/procqueue/pq_test.c12
6 files changed, 19 insertions, 10 deletions
diff --git a/include/osmocom/gapk/procqueue.h b/include/osmocom/gapk/procqueue.h
index e73f73e..6b929d7 100644
--- a/include/osmocom/gapk/procqueue.h
+++ b/include/osmocom/gapk/procqueue.h
@@ -30,6 +30,10 @@ enum osmo_gapk_pq_item_type {
OSMO_GAPK_ITEM_TYPE_PROC,
};
+#define OSMO_GAPK_CAT_NAME_SOURCE "source"
+#define OSMO_GAPK_CAT_NAME_SINK "sink"
+#define OSMO_GAPK_CAT_NAME_PROC "proc"
+
struct osmo_gapk_pq_item {
/*! input frame size (in bytes). '0' in case of variable frames */
unsigned int len_in;
diff --git a/src/pq_alsa.c b/src/pq_alsa.c
index 676e8e7..3550221 100644
--- a/src/pq_alsa.c
+++ b/src/pq_alsa.c
@@ -143,7 +143,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->cat_name = in_out_n ?
+ OSMO_GAPK_CAT_NAME_SOURCE : OSMO_GAPK_CAT_NAME_SINK;
item->sub_name = "alsa";
item->len_in = in_out_n ? 0 : blk_len;
diff --git a/src/pq_file.c b/src/pq_file.c
index 8ad26d5..22dc9cd 100644
--- a/src/pq_file.c
+++ b/src/pq_file.c
@@ -80,7 +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->cat_name = in_out_n ?
+ OSMO_GAPK_CAT_NAME_SOURCE : OSMO_GAPK_CAT_NAME_SINK;
item->sub_name = "file";
item->len_in = in_out_n ? 0 : blk_len;
diff --git a/src/pq_rtp.c b/src/pq_rtp.c
index c1d9ffb..a50013a 100644
--- a/src/pq_rtp.c
+++ b/src/pq_rtp.c
@@ -226,7 +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->cat_name = in_out_n ?
+ OSMO_GAPK_CAT_NAME_SOURCE : OSMO_GAPK_CAT_NAME_SINK;
item->sub_name = "rtp";
item->len_in = in_out_n ? 0 : blk_len;
diff --git a/tests/io/pq_rtp_test.c b/tests/io/pq_rtp_test.c
index cf6e2a6..f4070b7 100644
--- a/tests/io/pq_rtp_test.c
+++ b/tests/io/pq_rtp_test.c
@@ -151,7 +151,7 @@ static int init_gen_queue(struct osmo_gapk_pq *pq,
/* Fill in meta information */
src_rand->type = OSMO_GAPK_ITEM_TYPE_SOURCE;
- src_rand->cat_name = "source";
+ src_rand->cat_name = OSMO_GAPK_CAT_NAME_SOURCE;
src_rand->sub_name = "random";
/* Set I/O buffer lengths */
@@ -237,7 +237,7 @@ static int init_chk_queue(struct osmo_gapk_pq *pq,
/* Fill in meta information */
sink_chk->type = OSMO_GAPK_ITEM_TYPE_SINK;
- sink_chk->cat_name = "sink";
+ sink_chk->cat_name = OSMO_GAPK_CAT_NAME_SINK;
sink_chk->sub_name = "checker";
/* Set I/O buffer lengths */
diff --git a/tests/procqueue/pq_test.c b/tests/procqueue/pq_test.c
index d0d6670..198108d 100644
--- a/tests/procqueue/pq_test.c
+++ b/tests/procqueue/pq_test.c
@@ -283,16 +283,18 @@ int main(int argc, char **argv)
assert(queue_desc == NULL);
/* Fill in some data */
- q3_i0->cat_name = "source";
+ q3_i0->cat_name = OSMO_GAPK_CAT_NAME_SOURCE;
q3_i0->sub_name = "file";
- q3_i1->cat_name = "proc";
+
+ q3_i1->cat_name = OSMO_GAPK_CAT_NAME_PROC;
q3_i1->sub_name = "dummy";
- q3_i2->cat_name = "sink";
+
+ q3_i2->cat_name = OSMO_GAPK_CAT_NAME_SINK;
q3_i2->sub_name = "alsa";
- q2_i0->cat_name = "source";
+ q2_i0->cat_name = OSMO_GAPK_CAT_NAME_SOURCE;
q2_i0->sub_name = "dummy";
- q2_i1->cat_name = "sink";
+ q2_i1->cat_name = OSMO_GAPK_CAT_NAME_SINK;
q2_i1->sub_name = "dummy";
q1_i0->cat_name = "dummy";