diff options
author | Mark Farrugia <mark.farrugia@fiberdyne.com.au> | 2019-04-01 11:58:08 +1100 |
---|---|---|
committer | Mark Farrugia <mark.farrugia@fiberdyne.com.au> | 2019-04-01 11:58:33 +1100 |
commit | 9e19ac94121963f26f85df1685ac346cc698fe4b (patch) | |
tree | 84a3ed7c35bc70d0b04795e01d9710c5218452b0 /configfs.c | |
parent | 382476f00747316ee01dcc410a31cc27830c18ca (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.c | 43 |
1 files changed, 35 insertions, 8 deletions
@@ -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; } |