ALSA: pcm: Properly close timer when freeing slaves
PATCH 1/1 ALSA: pcm: Properly close timer when freeing slaves
Hi,
Here's a patch originally from Dan McCombs against alsa-lib.git HEAD fixing a fairly nasty fd leak for timers.
Thanks,
Dan
From f3109e7a1202ca81d545bed45d984926495f6699 Mon Sep 17 00:00:00 2001
From: Daniel T Chen <[email protected]>
Date: Sun, 20 Dec 2009 15:13:39 -0500
Subject: [PATCH] ALSA: pcm: Properly close timer when freeing slaves
Dan McCombs discovered that snd_pcm_close() invocations are not leading to associated timers being closed, which results in successively more timers being created but not freed.
--- src/pcm/pcm_hw.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
src/pcm/pcm_hw.c +9 -8
@@ -338,9 +338,18 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)return 0 ; } +static void snd_pcm_hw_close_timer (snd_pcm_hw_t *hw) +{ +if (hw->period_timer) { +snd_timer_close (hw->period_timer); + hw->period_timer =NULL ; + } +} +static int snd_pcm_hw_hw_free (snd_pcm_t *pcm) {snd_pcm_hw_t *hw = pcm->private_data; +snd_pcm_hw_close_timer (hw);int fd = hw->fd, err;if (ioctl (fd,SNDRV_PCM_IOCTL_HW_FREE ) <0 ) { err = -errno;
@@ -350,14 +359,6 @@ static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)return 0 ; } -static void snd_pcm_hw_close_timer (snd_pcm_hw_t *hw) -{ -if (hw->period_timer) { -snd_timer_close (hw->period_timer); - hw->period_timer =NULL ; - } -} -static int snd_pcm_hw_change_timer (snd_pcm_t *pcm,int enable) {snd_pcm_hw_t *hw = pcm->private_data;
Signature · 1 line
1.6.5
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 4 lines · Daniel Chen
Hi,
Here's a patch originally from Dan McCombs against alsa-lib.git HEAD fixing a fairly nasty fd leak for timers.
Thanks for notice. The patch proposed patch does reset hw->period_event and pcm->fast_ops variables (the application might reuse pcm handle after hw_free call to initialize PCM handle for another parameters). My corrected version is in ALSA GIT now:
http://git.alsa-project.org/?p=alsa-lib.git;a=commitdiff;h=a256766c10c52cb6667de8a65f5cbb332fad4cc7
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.