aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-11-20 18:23:46 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-11-20 18:24:49 +1100
commitaf54a3dd7c7581a3039838591aec14720e854684 (patch)
treed5025ababebf77f2cabf7804b5e5675dcc24b83e
parent4ff37d576bc43e4655e5ed02bc8016e266c9893d (diff)
Fix missing 'close' PCM callback
We need to have to close PCM callback set, otherwise we get a kernel crash when the PCM middle layer attempts to dereference a NULL pointer. Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
-rw-r--r--pcm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/pcm.c b/pcm.c
index 411db40..0c6afa9 100644
--- a/pcm.c
+++ b/pcm.c
@@ -92,6 +92,22 @@ static int pcm_open(struct snd_pcm_substream *substream)
}
/**
+ * pcm_close - Implements 'close' callback for PCM middle layer
+ * @substream: pointer to ALSA PCM substream
+ *
+ * This is called when a PCM substream is closed.
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int pcm_close(struct snd_pcm_substream *substream)
+{
+ // Do additional Audio Path 'close' callback
+ return DO_AUDIOPATH_CB(
+ (struct snd_avirt_audiopath *)PRIVATE_DATA(substream)->audiopath,
+ close, substream);
+}
+
+/**
* pcm_hw_params - Implements 'hw_params' callback for PCM middle layer
* @substream: pointer to ALSA PCM substream
* @hw_params: contains the hardware parameters for the PCM
@@ -154,6 +170,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
*/
struct snd_pcm_ops pcm_ops_avirt = {
.open = pcm_open,
+ .close = pcm_close,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = pcm_hw_params,
.hw_free = pcm_hw_free,