summaryrefslogtreecommitdiffstats
path: root/core.c
diff options
context:
space:
mode:
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;
}