Ignore:
Timestamp:
Jul 16, 2008, 11:53:49 AM (17 years ago)
Author:
Paul Smedley
Message:

Update uniaud32-2.0 branch to ALSA 1.0.17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-2.0/alsa-kernel/drivers/dummy.c

    r339 r358  
    182182        spinlock_t lock;
    183183        struct timer_list timer;
    184         unsigned int pcm_size;
    185         unsigned int pcm_count;
     184        unsigned int pcm_buffer_size;
     185        unsigned int pcm_period_size;
    186186        unsigned int pcm_bps;           /* bytes per second */
    187         unsigned int pcm_jiffie;        /* bytes per one jiffie */
     187        unsigned int pcm_hz;            /* HZ */
    188188        unsigned int pcm_irq_pos;       /* IRQ position */
    189189        unsigned int pcm_buf_pos;       /* position in buffer */
     
    231231        struct snd_pcm_runtime *runtime = substream->runtime;
    232232        struct snd_dummy_pcm *dpcm = runtime->private_data;
    233         unsigned int bps;
    234 
    235         bps = runtime->rate * runtime->channels;
    236         bps *= snd_pcm_format_width(runtime->format);
    237         bps /= 8;
     233        int bps;
     234
     235        bps = snd_pcm_format_width(runtime->format) * runtime->rate *
     236                runtime->channels / 8;
     237
    238238        if (bps <= 0)
    239239                return -EINVAL;
     240
    240241        dpcm->pcm_bps = bps;
    241         dpcm->pcm_jiffie = bps / HZ;
    242         dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
    243         dpcm->pcm_count = snd_pcm_lib_period_bytes(substream);
     242        dpcm->pcm_hz = HZ;
     243        dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
     244        dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream);
    244245        dpcm->pcm_irq_pos = 0;
    245246        dpcm->pcm_buf_pos = 0;
     247
     248        snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
     249                        bytes_to_samples(runtime, runtime->dma_bytes));
     250
    246251        return 0;
    247252}
     
    255260        dpcm->timer.expires = 1 + jiffies;
    256261        add_timer(&dpcm->timer);
    257         dpcm->pcm_irq_pos += dpcm->pcm_jiffie;
    258         dpcm->pcm_buf_pos += dpcm->pcm_jiffie;
    259         dpcm->pcm_buf_pos %= dpcm->pcm_size;
    260         if (dpcm->pcm_irq_pos >= dpcm->pcm_count) {
    261                 dpcm->pcm_irq_pos %= dpcm->pcm_count;
     262        dpcm->pcm_irq_pos += dpcm->pcm_bps;
     263        dpcm->pcm_buf_pos += dpcm->pcm_bps;
     264        dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz;
     265        if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
     266                dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
    262267                spin_unlock_irqrestore(&dpcm->lock, flags);
    263268                snd_pcm_period_elapsed(dpcm->substream);
     
    271276        struct snd_dummy_pcm *dpcm = runtime->private_data;
    272277
    273         return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
     278        return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
    274279}
    275280
Note: See TracChangeset for help on using the changeset viewer.