perex 5bf394
From a256766c10c52cb6667de8a65f5cbb332fad4cc7 Mon Sep 17 00:00:00 2001
perex 5bf394
From: Jaroslav Kysela <perex@perex.cz>
perex 5bf394
Date: Mon, 21 Dec 2009 09:09:42 +0100
perex 5bf394
Subject: [PATCH] pcm: Close event timer in pcm_hw plugin
perex 5bf394
perex 5bf394
Dan McCombs discovered that snd_pcm_close() invocations are not leading
perex 5bf394
to associated timers being closed, which results in successively more
perex 5bf394
timers being created but not freed.
perex 5bf394
perex 5bf394
Original patch from Daniel T Chen <crimsun@ubuntu.com>.
perex 5bf394
perex 5bf394
BugLink: https://bugs.launchpad.net/bugs/451893
perex 5bf394
perex 5bf394
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
perex 5bf394
---
perex 5bf394
 src/pcm/pcm_hw.c |   26 ++++++++++++++------------
perex 5bf394
 1 files changed, 14 insertions(+), 12 deletions(-)
perex 5bf394
perex 5bf394
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
perex 5bf394
index 2095b01..b557912 100644
perex 5bf394
--- a/src/pcm/pcm_hw.c
perex 5bf394
+++ b/src/pcm/pcm_hw.c
perex 5bf394
@@ -338,18 +338,6 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
perex 5bf394
 	return 0;
perex 5bf394
 }
perex 5bf394
 
perex 5bf394
-static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
perex 5bf394
-{
perex 5bf394
-	snd_pcm_hw_t *hw = pcm->private_data;
perex 5bf394
-	int fd = hw->fd, err;
perex 5bf394
-	if (ioctl(fd, SNDRV_PCM_IOCTL_HW_FREE) < 0) {
perex 5bf394
-		err = -errno;
perex 5bf394
-		SYSMSG("SNDRV_PCM_IOCTL_HW_FREE failed");
perex 5bf394
-		return err;
perex 5bf394
-	}
perex 5bf394
-	return 0;
perex 5bf394
-}
perex 5bf394
-
perex 5bf394
 static void snd_pcm_hw_close_timer(snd_pcm_hw_t *hw)
perex 5bf394
 {
perex 5bf394
 	if (hw->period_timer) {
perex 5bf394
@@ -421,6 +409,20 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable)
perex 5bf394
 	} else {
perex 5bf394
 		snd_pcm_hw_close_timer(hw);
perex 5bf394
 		pcm->fast_ops = &snd_pcm_hw_fast_ops;
perex 5bf394
+		hw->period_event = 0;
perex 5bf394
+	}
perex 5bf394
+	return 0;
perex 5bf394
+}
perex 5bf394
+
perex 5bf394
+static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
perex 5bf394
+{
perex 5bf394
+	snd_pcm_hw_t *hw = pcm->private_data;
perex 5bf394
+	int fd = hw->fd, err;
perex 5bf394
+	snd_pcm_hw_change_timer(pcm, 0);
perex 5bf394
+	if (ioctl(fd, SNDRV_PCM_IOCTL_HW_FREE) < 0) {
perex 5bf394
+		err = -errno;
perex 5bf394
+		SYSMSG("SNDRV_PCM_IOCTL_HW_FREE failed");
perex 5bf394
+		return err;
perex 5bf394
 	}
perex 5bf394
 	return 0;
perex 5bf394
 }
perex 5bf394
-- 
perex 5bf394
1.5.5.1
perex 5bf394