summaryrefslogtreecommitdiffstats
path: root/core.c
diff options
context:
space:
mode:
authorJames O'Shannessy <james.oshannessy@fiberdyne.com.au>2018-11-08 10:25:17 +1100
committerJames O'Shannessy <james.oshannessy@fiberdyne.com.au>2018-11-08 10:25:17 +1100
commit26fd635bbae7fbf5f139830fca84b58d4bddec3a (patch)
tree9f45790201d9c505455e6c2706f30775939ab2de /core.c
parent932491f75629ab2e3f4acbfd1a7e16d42f8bc351 (diff)
Add private data structure to PCM for audio path management
Expand upon the private data structure currently used by avirt to allow audio paths to store own user data to PCM implementation. Signed-off-by: James O'Shannessy <james.oshannessy@fiberdyne.com.au>
Diffstat (limited to 'core.c')
-rw-r--r--core.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/core.c b/core.c
index 41cc555..6698a9e 100644
--- a/core.c
+++ b/core.c
@@ -198,8 +198,26 @@ static void destroy_snd_avirt_audiopath_obj(struct snd_avirt_audiopath_obj *p)
kobject_put(&p->kobj);
}
+/**
+ * pcm_private_data_free - callback function to free private data allocated to pcm
+ * @pcm: the PCM with private data
+ */
+void pcm_private_data_free(struct snd_pcm *pcm)
+{
+ struct snd_avirt_private_data *avirt_private_data;
+ D_PRINTK("Issuing free to private data struct");
+ if(pcm->private_data){
+ avirt_private_data = pcm->private_data;
+ if(avirt_private_data->ap_userdata)
+ avirt_private_data->private_free(pcm);
+ }
+
+ kfree(pcm->private_data);
+}
+
static struct snd_pcm *pcm_create(struct snd_avirt_stream *stream)
{
+ struct snd_avirt_private_data *avirt_private_data;
bool playback = false, capture = false;
struct snd_pcm *pcm;
int err;
@@ -230,6 +248,11 @@ static struct snd_pcm *pcm_create(struct snd_avirt_stream *stream)
pcm->info_flags = 0;
strcpy(pcm->name, stream->name);
+ avirt_private_data = kzalloc(sizeof(*avirt_private_data), GFP_KERNEL);
+ pcm->private_data = avirt_private_data;
+ // Set the private free function for the private user data
+ pcm->private_free = pcm_private_data_free;
+
return pcm;
}