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