Changeset 358 for GPL/branches/uniaud32-2.0/alsa-kernel/drivers/dummy.c
- Timestamp:
- Jul 16, 2008, 11:53:49 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-2.0/alsa-kernel/drivers/dummy.c
r339 r358 182 182 spinlock_t lock; 183 183 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; 186 186 unsigned int pcm_bps; /* bytes per second */ 187 unsigned int pcm_ jiffie; /* bytes per one jiffie*/187 unsigned int pcm_hz; /* HZ */ 188 188 unsigned int pcm_irq_pos; /* IRQ position */ 189 189 unsigned int pcm_buf_pos; /* position in buffer */ … … 231 231 struct snd_pcm_runtime *runtime = substream->runtime; 232 232 struct snd_dummy_pcm *dpcm = runtime->private_data; 233 unsignedint 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 238 238 if (bps <= 0) 239 239 return -EINVAL; 240 240 241 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); 244 245 dpcm->pcm_irq_pos = 0; 245 246 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 246 251 return 0; 247 252 } … … 255 260 dpcm->timer.expires = 1 + jiffies; 256 261 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; 262 267 spin_unlock_irqrestore(&dpcm->lock, flags); 263 268 snd_pcm_period_elapsed(dpcm->substream); … … 271 276 struct snd_dummy_pcm *dpcm = runtime->private_data; 272 277 273 return bytes_to_frames(runtime, dpcm->pcm_buf_pos );278 return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz); 274 279 } 275 280
Note:
See TracChangeset
for help on using the changeset viewer.