[ALSA] soc - 0.13 ASoC DAPM bug fix for unnamed streams
[powerpc.git] / sound / core / pcm_lib.c
index a21aa00..9fefcaa 100644 (file)
@@ -79,19 +79,17 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
                        runtime->silence_filled -= frames;
                        if ((snd_pcm_sframes_t)runtime->silence_filled < 0) {
                                runtime->silence_filled = 0;
-                               runtime->silence_start = (ofs + frames) - runtime->buffer_size;
+                               runtime->silence_start = new_hw_ptr;
                        } else {
-                               runtime->silence_start = ofs - runtime->silence_filled;
+                               runtime->silence_start = ofs;
                        }
-                       if ((snd_pcm_sframes_t)runtime->silence_start < 0)
-                               runtime->silence_start += runtime->boundary;
                }
                frames = runtime->buffer_size - runtime->silence_filled;
        }
        snd_assert(frames <= runtime->buffer_size, return);
        if (frames == 0)
                return;
-       ofs = (runtime->silence_start + runtime->silence_filled) % runtime->buffer_size;
+       ofs = runtime->silence_start % runtime->buffer_size;
        while (frames > 0) {
                transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames;
                if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||
@@ -783,6 +781,11 @@ int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *
 {
         unsigned int k;
        int changed = 0;
+
+       if (!count) {
+               i->empty = 1;
+               return -EINVAL;
+       }
         for (k = 0; k < count; k++) {
                if (mask && !(mask & (1 << k)))
                        continue;
@@ -1782,7 +1785,7 @@ snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const v
        if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
                return -EBADFD;
 
-       nonblock = !!(substream->ffile->f_flags & O_NONBLOCK);
+       nonblock = !!(substream->f_flags & O_NONBLOCK);
 
        if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED &&
            runtime->channels > 1)
@@ -1847,7 +1850,7 @@ snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream,
        if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
                return -EBADFD;
 
-       nonblock = !!(substream->ffile->f_flags & O_NONBLOCK);
+       nonblock = !!(substream->f_flags & O_NONBLOCK);
 
        if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
                return -EINVAL;
@@ -2059,7 +2062,7 @@ snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream, void __u
        if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
                return -EBADFD;
 
-       nonblock = !!(substream->ffile->f_flags & O_NONBLOCK);
+       nonblock = !!(substream->f_flags & O_NONBLOCK);
        if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED)
                return -EINVAL;
        return snd_pcm_lib_read1(substream, (unsigned long)buf, size, nonblock, snd_pcm_lib_read_transfer);
@@ -2118,7 +2121,7 @@ snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream,
        if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
                return -EBADFD;
 
-       nonblock = !!(substream->ffile->f_flags & O_NONBLOCK);
+       nonblock = !!(substream->f_flags & O_NONBLOCK);
        if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
                return -EINVAL;
        return snd_pcm_lib_read1(substream, (unsigned long)bufs, frames, nonblock, snd_pcm_lib_readv_transfer);