X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Fpcm_timer.c;h=884eaea31fec8ae15de9c28142b300641e97a5e7;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=40121971ef152f2d2077189bc073b74b8e22d884;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c index 40121971e..884eaea31 100644 --- a/sound/core/pcm_timer.c +++ b/sound/core/pcm_timer.c @@ -25,8 +25,6 @@ #include #include -#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; }