X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Fpcm_timer.c;h=d94ed16d21ea9dac3e93d776b116f8c25b8def6c;hb=16c70f8c1b54b61c3b951b6fb220df250fe09b32;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..d94ed16d2 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 */ @@ -47,10 +45,10 @@ static unsigned long gcd(unsigned long a, unsigned long b) return b; } -void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream) +void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) { - unsigned long rate, mult, fsize, l; - snd_pcm_runtime_t *runtime = substream->runtime; + unsigned long rate, mult, fsize, l, post; + struct snd_pcm_runtime *runtime = substream->runtime; mult = 1000000000; rate = runtime->rate; @@ -63,30 +61,31 @@ 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) +static unsigned long snd_pcm_timer_resolution(struct snd_timer * timer) { - snd_pcm_substream_t * substream; + struct snd_pcm_substream *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; } -static int snd_pcm_timer_start(snd_timer_t * timer) +static int snd_pcm_timer_start(struct snd_timer * timer) { unsigned long flags; - snd_pcm_substream_t * substream; + struct snd_pcm_substream *substream; substream = snd_timer_chip(timer); spin_lock_irqsave(&substream->timer_lock, flags); @@ -95,10 +94,10 @@ static int snd_pcm_timer_start(snd_timer_t * timer) return 0; } -static int snd_pcm_timer_stop(snd_timer_t * timer) +static int snd_pcm_timer_stop(struct snd_timer * timer) { unsigned long flags; - snd_pcm_substream_t * substream; + struct snd_pcm_substream *substream; substream = snd_timer_chip(timer); spin_lock_irqsave(&substream->timer_lock, flags); @@ -107,7 +106,7 @@ static int snd_pcm_timer_stop(snd_timer_t * timer) return 0; } -static struct _snd_timer_hardware snd_pcm_timer = +static struct snd_timer_hardware snd_pcm_timer = { .flags = SNDRV_TIMER_HW_AUTO | SNDRV_TIMER_HW_SLAVE, .resolution = 0, @@ -121,16 +120,16 @@ static struct _snd_timer_hardware snd_pcm_timer = * Init functions */ -static void snd_pcm_timer_free(snd_timer_t *timer) +static void snd_pcm_timer_free(struct snd_timer *timer) { - snd_pcm_substream_t *substream = snd_magic_cast(snd_pcm_substream_t, timer->private_data, return); + struct snd_pcm_substream *substream = timer->private_data; substream->timer = NULL; } -void snd_pcm_timer_init(snd_pcm_substream_t *substream) +void snd_pcm_timer_init(struct snd_pcm_substream *substream) { - snd_timer_id_t tid; - snd_timer_t *timer; + struct snd_timer_id tid; + struct snd_timer *timer; tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE; tid.dev_class = SNDRV_TIMER_CLASS_PCM; @@ -153,7 +152,7 @@ void snd_pcm_timer_init(snd_pcm_substream_t *substream) substream->timer = timer; } -void snd_pcm_timer_done(snd_pcm_substream_t *substream) +void snd_pcm_timer_done(struct snd_pcm_substream *substream) { if (substream->timer) { snd_device_free(substream->pcm->card, substream->timer);