summaryrefslogtreecommitdiffstats
path: root/configfs.c
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-04-01 11:58:08 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-04-01 11:58:59 +1100
commit92c383e87fffd5fd22c553e30b9fc94f2cb5f9c0 (patch)
tree28d2621bb423b302ced5475514f03cb06b917715 /configfs.c
parentc22d65351d533a2077caae117e3baf5558d20963 (diff)
Add 'internal' streams for routing, revamp stream finalisation
Uses the ALSA internal PCM API to create streams purely used for internal routing purposes. Adds the 'try_complete' functions for both streams and routes in an attempt to standardize the finalization of a stream or route object. Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'configfs.c')
-rw-r--r--configfs.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/configfs.c b/configfs.c
index bc10efb..2751d66 100644
--- a/configfs.c
+++ b/configfs.c
@@ -59,6 +59,7 @@
if ((tmp > INT_MAX) || (tmp == 0)) \
return -ERANGE; \
s->channels = tmp; \
+ snd_avirt_##type##_try_complete(s); \
return count; \
} \
CONFIGFS_ATTR(cfg_snd_avirt_##type##_, channels);
@@ -140,12 +141,30 @@ static ssize_t cfg_snd_avirt_stream_map_show(struct config_item *item,
static ssize_t cfg_snd_avirt_stream_map_store(struct config_item *item,
const char *page, size_t count)
{
- char *split;
+ char *map;
+ struct snd_avirt_audiopath *audiopath;
struct snd_avirt_stream *stream =
snd_avirt_stream_from_config_item(item);
- split = strsep((char **)&page, "\n");
- snd_avirt_stream_set_map(stream, split);
+ map = strsep((char **)&page, "\n");
+
+ /* If already sealed, we cannot create the stream */
+ if (snd_avirt_streams_sealed()) {
+ D_ERRORK("Streams already sealed. Cannot set map: '%s'", map);
+ return -EPERM;
+ }
+
+ if (!strcmp(stream->map, map))
+ return -1;
+
+ audiopath = snd_avirt_audiopath_get(map);
+ if (!audiopath) {
+ D_ERRORK("Cannot find Audio Path uid: '%s'!", stream->map);
+ }
+
+ memcpy(stream->map, (char *)map, strlen(map));
+
+ snd_avirt_stream_try_complete(stream);
return count;
}
@@ -304,7 +323,8 @@ static struct config_item_type cfg_snd_avirt_route_type = {
static struct config_item *
cfg_snd_avirt_stream_make_item(struct config_group *group, const char *name)
{
- char *split;
+ char *split, *stream_name;
+ bool internal = false;
int direction;
struct snd_avirt_stream *stream;
@@ -326,16 +346,23 @@ cfg_snd_avirt_stream_make_item(struct config_group *group, const char *name)
}
// Get stream name, and create PCM for stream
- split = strsep((char **)&name, "\n");
- stream = snd_avirt_stream_create(split, direction);
+ stream_name = strsep((char **)&name, "\n");
+
+ // If internal, get internal
+ split = strstr(stream_name, "__internal");
+ if (split) {
+ stream_name = strsep((char **)&stream_name, "__");
+ internal = true;
+ }
+
+ // Finally, create stream
+ stream = snd_avirt_stream_create(stream_name, direction, internal);
if (IS_ERR(stream))
return ERR_PTR(PTR_ERR(stream));
config_item_init_type_name(&stream->item, name,
&cfg_snd_avirt_stream_type);
- D_INFOK("Make stream: %s", stream->name);
-
return &stream->item;
}