]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
ALSA: Fix SNDCTL_DSP_RESET ioctl for OSS emulation
authorTakashi Iwai <tiwai@suse.de>
Tue, 30 Nov 2010 07:14:21 +0000 (08:14 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 30 Nov 2010 07:18:58 +0000 (08:18 +0100)
In OSS emulation, SNDCTL_DSP_RESET ioctl needs the reset of the internal
buffer state in addition to drop of the running streams.  Otherwise the
succeeding access becomes inconsistent.

Tested-by: Amit Nagal <helloin.amit@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/oss/pcm_oss.c

index 5c8c7dff8ede8a3989301ce083319e75cbffe808..b753ec661fcfd149d079f530e05729d8d0cc524b 100644 (file)
@@ -1510,16 +1510,19 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
 static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file)
 {
        struct snd_pcm_substream *substream;
+       struct snd_pcm_runtime *runtime;
+       int i;
 
-       substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
-       if (substream != NULL) {
-               snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
-               substream->runtime->oss.prepare = 1;
-       }
-       substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
-       if (substream != NULL) {
+       for (i = 0; i < 2; i++) { 
+               substream = pcm_oss_file->streams[i];
+               if (!substream)
+                       continue;
+               runtime = substream->runtime;
                snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
-               substream->runtime->oss.prepare = 1;
+               runtime->oss.prepare = 1;
+               runtime->oss.buffer_used = 0;
+               runtime->oss.prev_hw_ptr_period = 0;
+               runtime->oss.period_ptr = 0;
        }
        return 0;
 }