]> git.alsa-project.org Git - alsa-oss.git/commitdiff
- avoid the assert in snd_pcm_drain().
authorTakashi Iwai <tiwai@suse.de>
Mon, 1 Dec 2003 14:06:23 +0000 (14:06 +0000)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Dec 2003 14:06:23 +0000 (14:06 +0000)
- fixed the possible segfault at the wrong release of resources.
- more debug messages.

alsa-oss.c

index d0afb83dd814c439bb28b9c4e6b5e62e9ff544a4..85d8c98fe293e8159cc33dd6856863431cdfa0d7 100644 (file)
@@ -219,7 +219,8 @@ static int oss_dsp_hw_params(oss_dsp_t *dsp)
                        return err;
                rate = dsp->rate;
                err = snd_pcm_hw_params_set_rate_near(pcm, hw, &rate, 0);
-               assert(err >= 0);
+               if (err < 0)
+                       return err;
 
                if (str->mmap_buffer) {
                        snd_pcm_access_mask_t *mask;
@@ -269,8 +270,6 @@ static int oss_dsp_hw_params(oss_dsp_t *dsp)
                }
 
                err = snd_pcm_hw_params(pcm, hw);
-               if (err < 0)
-                       return err;
 #if 0
                if (debug)
                        snd_pcm_dump_setup(pcm, stderr);
@@ -365,8 +364,10 @@ static int oss_dsp_close(int fd)
                oss_dsp_stream_t *str = &dsp->streams[k];
                if (!str->pcm)
                        continue;
-               if (k == SND_PCM_STREAM_PLAYBACK)
-                       snd_pcm_drain(str->pcm);
+               if (k == SND_PCM_STREAM_PLAYBACK) {
+                       if (snd_pcm_state(str->pcm) != SND_PCM_STATE_OPEN)
+                               snd_pcm_drain(str->pcm);
+               }
                err = snd_pcm_close(str->pcm);
                if (err < 0)
                        result = err;
@@ -435,7 +436,9 @@ static int oss_dsp_open(int card, int device, int oflag, mode_t mode)
        fds[fd]->class = FD_OSS_DSP;
        dsp = calloc(1, sizeof(oss_dsp_t));
        if (!dsp) {
-               errno = -ENOMEM;
+               free(fds[fd]);
+               fds[fd] = NULL;
+               errno = ENOMEM;
                return -1;
        }
        fds[fd]->private = dsp;
@@ -1266,6 +1269,7 @@ static int oss_dsp_ioctl(int fd, unsigned long cmd, ...)
        }
        if (err >= 0)
                return 0;
+       DEBUG("dsp ioctl error = %d\n", err);
        errno = -err;
        return -1;
 }