aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/drivers/dummy.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index a240eaeb5c6..f67f65829f3 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -181,10 +181,10 @@ struct snd_dummy_pcm {
struct snd_dummy *dummy;
spinlock_t lock;
struct timer_list timer;
- unsigned int pcm_size;
- unsigned int pcm_count;
+ unsigned int pcm_buffer_size;
+ unsigned int pcm_period_size;
unsigned int pcm_bps; /* bytes per second */
- unsigned int pcm_jiffie; /* bytes per one jiffie */
+ unsigned int pcm_hz; /* HZ */
unsigned int pcm_irq_pos; /* IRQ position */
unsigned int pcm_buf_pos; /* position in buffer */
struct snd_pcm_substream *substream;
@@ -238,11 +238,15 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
if (bps <= 0)
return -EINVAL;
dpcm->pcm_bps = bps;
- dpcm->pcm_jiffie = bps / HZ;
- dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
- dpcm->pcm_count = snd_pcm_lib_period_bytes(substream);
+ dpcm->pcm_hz = HZ;
+ dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
+ dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream);
dpcm->pcm_irq_pos = 0;
dpcm->pcm_buf_pos = 0;
+
+ snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
+ bytes_to_samples(runtime, runtime->dma_bytes));
+
return 0;
}
@@ -254,11 +258,11 @@ static void snd_card_dummy_pcm_timer_function(unsigned long data)
spin_lock_irqsave(&dpcm->lock, flags);
dpcm->timer.expires = 1 + jiffies;
add_timer(&dpcm->timer);
- dpcm->pcm_irq_pos += dpcm->pcm_jiffie;
- dpcm->pcm_buf_pos += dpcm->pcm_jiffie;
- dpcm->pcm_buf_pos %= dpcm->pcm_size;
- if (dpcm->pcm_irq_pos >= dpcm->pcm_count) {
- dpcm->pcm_irq_pos %= dpcm->pcm_count;
+ dpcm->pcm_irq_pos += dpcm->pcm_bps;
+ if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
+ dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
+ dpcm->pcm_buf_pos += dpcm->pcm_period_size;
+ dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size;
spin_unlock_irqrestore(&dpcm->lock, flags);
snd_pcm_period_elapsed(dpcm->substream);
} else