changeset 71892:248ccc534803

* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
author Jan Djärv <jan.h.d@swipnet.se>
date Fri, 14 Jul 2006 09:47:45 +0000
parents 54ec937ab5e4
children bb3316be643e
files src/ChangeLog src/sound.c
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Jul 14 09:32:14 2006 +0000
+++ b/src/ChangeLog	Fri Jul 14 09:47:45 2006 +0000
@@ -1,3 +1,7 @@
+2006-07-14  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* sound.c (alsa_init): Call snd_pcm_close after successful snd_pcm_open.
+
 2006-07-14  Kim F. Storm  <storm@cua.dk>
 
 	* w32.c: Fix high cpu load for server sockets.
--- a/src/sound.c	Fri Jul 14 09:32:14 2006 +0000
+++ b/src/sound.c	Fri Jul 14 09:47:45 2006 +0000
@@ -990,6 +990,7 @@
      struct sound_device *sd;
 {
   int val, err, dir;
+  unsigned uval;
   struct alsa_params *p = (struct alsa_params *) sd->data;
   snd_pcm_uframes_t buffer_size;
 
@@ -1017,8 +1018,8 @@
   if (err < 0) 
     alsa_sound_perror ("Could not set sound format", err);
 
-  val = sd->sample_rate;
-  err = snd_pcm_hw_params_set_rate_near (p->handle, p->hwparams, &val, 0);
+  uval = sd->sample_rate;
+  err = snd_pcm_hw_params_set_rate_near (p->handle, p->hwparams, &uval, 0);
   if (err < 0)
     alsa_sound_perror ("Could not set sample rate", err);
   
@@ -1123,7 +1124,7 @@
         snd_pcm_sw_params_free (p->swparams);
       if (p->handle)
         {
-          snd_pcm_drain(p->handle);
+          snd_pcm_drain (p->handle);
           snd_pcm_close (p->handle);
         }
       free (p);
@@ -1269,7 +1270,8 @@
   err = snd_pcm_open (&handle, file, SND_PCM_STREAM_PLAYBACK, 0);
   snd_lib_error_set_handler (NULL);
   if (err < 0)
-    return 0;
+      return 0;
+  snd_pcm_close (handle);
 
   sd->fd = -1;
   sd->open = alsa_open;