diff options
author | 2018-10-11 12:35:30 +1100 | |
---|---|---|
committer | 2018-10-30 13:43:41 +1100 | |
commit | 8a729f8dc2796b6f6b8e38b7e7377f50e2ed6a2d (patch) | |
tree | f6ce0c457a954d39ac5daac50b398e22382ff28b | |
parent | 90ab8dc3b45eb8638b92084225a8ce876e9f5342 (diff) |
Numerous improvements
Add additional card_sealed checks, format braces, add comments
Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
-rw-r--r-- | src/avirt-config.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/avirt-config.c b/src/avirt-config.c index 5056da8..167bcc2 100644 --- a/src/avirt-config.c +++ b/src/avirt-config.c @@ -81,12 +81,22 @@ int AVIRT_CreateStream(const char *name, unsigned int channels, int direction) char path_chans[AVIRT_CONFIGFS_PATH_MAXLEN]; FILE *fd; - if (!configfs_mounted) { + // Check whether the configfs filesystem is mounted + if (!configfs_mounted) + { err = mount_configfs(); if (err < 0) return err; } + // Check if card is already sealed + if (card_sealed) + { + AVIRT_ERROR("Card is already sealed!"); + return -EPERM; + } + + // This indicates to AVIRT the direction of the stream strcpy(path, AVIRT_CONFIGFS_PATH_STREAMS); switch (direction) { case SND_PCM_STREAM_PLAYBACK: @@ -113,6 +123,7 @@ int AVIRT_CreateStream(const char *name, unsigned int channels, int direction) return err; } + // Open file and write to it strcpy(path_chans, path); strcat(path_chans, "/channels"); fd = fopen(path_chans, "w"); @@ -134,13 +145,15 @@ int AVIRT_SealCard() char path_sealed[AVIRT_CONFIGFS_PATH_MAXLEN]; FILE *fd; + // Check if card is already sealed if (card_sealed) { AVIRT_ERROR("Card is already sealed!"); - return -1; + return -EPERM; } - if (!configfs_mounted) { + if (!configfs_mounted) + { err = mount_configfs(); if (err < 0) return err; |