]> err.no Git - linux-2.6/blobdiff - sound/drivers/dummy.c
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6] / sound / drivers / dummy.c
index f67f65829f3e26704658da40b780796b434e9320..4e4c69e6cb4c8e850c66c7a2530eab827d793803 100644 (file)
@@ -230,13 +230,14 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_dummy_pcm *dpcm = runtime->private_data;
-       unsigned int bps;
+       int bps;
+
+       bps = snd_pcm_format_width(runtime->format) * runtime->rate *
+               runtime->channels / 8;
 
-       bps = runtime->rate * runtime->channels;
-       bps *= snd_pcm_format_width(runtime->format);
-       bps /= 8;
        if (bps <= 0)
                return -EINVAL;
+
        dpcm->pcm_bps = bps;
        dpcm->pcm_hz = HZ;
        dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
@@ -259,10 +260,10 @@ static void snd_card_dummy_pcm_timer_function(unsigned long data)
        dpcm->timer.expires = 1 + jiffies;
        add_timer(&dpcm->timer);
        dpcm->pcm_irq_pos += dpcm->pcm_bps;
+       dpcm->pcm_buf_pos += dpcm->pcm_bps;
+       dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz;
        if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
                dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
-               dpcm->pcm_buf_pos += dpcm->pcm_period_size;
-               dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size;
                spin_unlock_irqrestore(&dpcm->lock, flags);
                snd_pcm_period_elapsed(dpcm->substream);
        } else
@@ -274,7 +275,7 @@ static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *su
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_dummy_pcm *dpcm = runtime->private_data;
 
-       return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
+       return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
 }
 
 static struct snd_pcm_hardware snd_card_dummy_playback =