vserver 1.9.3
[linux-2.6.git] / sound / core / pcm_timer.c
index 4012197..884eaea 100644 (file)
@@ -25,8 +25,6 @@
 #include <sound/pcm.h>
 #include <sound/timer.h>
 
-#define chip_t snd_pcm_substream_t
-
 /*
  *  Timer functions
  */
@@ -49,7 +47,7 @@ static unsigned long gcd(unsigned long a, unsigned long b)
 
 void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream)
 {
-       unsigned long rate, mult, fsize, l;
+       unsigned long rate, mult, fsize, l, post;
        snd_pcm_runtime_t *runtime = substream->runtime;
        
         mult = 1000000000;
@@ -63,23 +61,24 @@ void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream)
        l = gcd(rate, fsize);
        rate /= l;
        fsize /= l;
+       post = 1;
        while ((mult * fsize) / fsize != mult) {
                mult /= 2;
-               rate /= 2;
+               post *= 2;
        }
        if (rate == 0) {
                snd_printk(KERN_ERR "pcm timer resolution out of range (rate = %u, period_size = %lu)\n", runtime->rate, runtime->period_size);
                runtime->timer_resolution = -1;
                return;
        }
-       runtime->timer_resolution = mult * fsize / rate;
+       runtime->timer_resolution = (mult * fsize / rate) * post;
 }
 
 static unsigned long snd_pcm_timer_resolution(snd_timer_t * timer)
 {
        snd_pcm_substream_t * substream;
        
-       substream = snd_magic_cast(snd_pcm_substream_t, timer->private_data, return -ENXIO);
+       substream = timer->private_data;
        return substream->runtime ? substream->runtime->timer_resolution : 0;
 }
 
@@ -123,7 +122,7 @@ static struct _snd_timer_hardware snd_pcm_timer =
 
 static void snd_pcm_timer_free(snd_timer_t *timer)
 {
-       snd_pcm_substream_t *substream = snd_magic_cast(snd_pcm_substream_t, timer->private_data, return);
+       snd_pcm_substream_t *substream = timer->private_data;
        substream->timer = NULL;
 }