diff options
| author | Jaroslav Kysela <perex@perex.cz> | 2010-10-20 03:33:03 -0400 |
|---|---|---|
| committer | Jaroslav Kysela <perex@perex.cz> | 2010-10-20 03:35:43 -0400 |
| commit | 5de9e45fcfccdf8151a82fc1a521e7042cbe482a (patch) | |
| tree | 2b11c4589947b68575fdbffc0252bf52a21db03f | |
| parent | dd04bb12d047a4d4461772093472a40dbe171e5f (diff) | |
ALSA: snd-aloop - add pause support
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
| -rw-r--r-- | sound/drivers/aloop.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 38e8351e935d..12b44b0b6777 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c | |||
| @@ -77,6 +77,7 @@ struct loopback_cable { | |||
| 77 | /* flags */ | 77 | /* flags */ |
| 78 | unsigned int valid; | 78 | unsigned int valid; |
| 79 | unsigned int running; | 79 | unsigned int running; |
| 80 | unsigned int pause; | ||
| 80 | }; | 81 | }; |
| 81 | 82 | ||
| 82 | struct loopback_setup { | 83 | struct loopback_setup { |
| @@ -254,7 +255,7 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
| 254 | struct snd_pcm_runtime *runtime = substream->runtime; | 255 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 255 | struct loopback_pcm *dpcm = runtime->private_data; | 256 | struct loopback_pcm *dpcm = runtime->private_data; |
| 256 | struct loopback_cable *cable = dpcm->cable; | 257 | struct loopback_cable *cable = dpcm->cable; |
| 257 | int err; | 258 | int err, stream = 1 << substream->stream; |
| 258 | 259 | ||
| 259 | switch (cmd) { | 260 | switch (cmd) { |
| 260 | case SNDRV_PCM_TRIGGER_START: | 261 | case SNDRV_PCM_TRIGGER_START: |
| @@ -264,7 +265,8 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
| 264 | dpcm->last_jiffies = jiffies; | 265 | dpcm->last_jiffies = jiffies; |
| 265 | dpcm->pcm_rate_shift = 0; | 266 | dpcm->pcm_rate_shift = 0; |
| 266 | spin_lock(&cable->lock); | 267 | spin_lock(&cable->lock); |
| 267 | cable->running |= (1 << substream->stream); | 268 | cable->running |= stream; |
| 269 | cable->pause &= ~stream; | ||
| 268 | spin_unlock(&cable->lock); | 270 | spin_unlock(&cable->lock); |
| 269 | loopback_timer_start(dpcm); | 271 | loopback_timer_start(dpcm); |
| 270 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 272 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| @@ -272,12 +274,26 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
| 272 | break; | 274 | break; |
| 273 | case SNDRV_PCM_TRIGGER_STOP: | 275 | case SNDRV_PCM_TRIGGER_STOP: |
| 274 | spin_lock(&cable->lock); | 276 | spin_lock(&cable->lock); |
| 275 | cable->running &= ~(1 << substream->stream); | 277 | cable->running &= ~stream; |
| 278 | cable->pause &= ~stream; | ||
| 276 | spin_unlock(&cable->lock); | 279 | spin_unlock(&cable->lock); |
| 277 | loopback_timer_stop(dpcm); | 280 | loopback_timer_stop(dpcm); |
| 278 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 281 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 279 | loopback_active_notify(dpcm); | 282 | loopback_active_notify(dpcm); |
| 280 | break; | 283 | break; |
| 284 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
| 285 | spin_lock(&cable->lock); | ||
| 286 | cable->pause |= stream; | ||
| 287 | spin_unlock(&cable->lock); | ||
| 288 | loopback_timer_stop(dpcm); | ||
| 289 | break; | ||
| 290 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
| 291 | spin_lock(&cable->lock); | ||
| 292 | dpcm->last_jiffies = jiffies; | ||
| 293 | cable->pause &= ~stream; | ||
| 294 | spin_unlock(&cable->lock); | ||
| 295 | loopback_timer_start(dpcm); | ||
| 296 | break; | ||
| 281 | default: | 297 | default: |
| 282 | return -EINVAL; | 298 | return -EINVAL; |
| 283 | } | 299 | } |
| @@ -468,7 +484,7 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable) | |||
| 468 | unsigned int running; | 484 | unsigned int running; |
| 469 | 485 | ||
| 470 | spin_lock(&cable->lock); | 486 | spin_lock(&cable->lock); |
| 471 | running = cable->running; | 487 | running = cable->running ^ cable->pause; |
| 472 | if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { | 488 | if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { |
| 473 | delta_play = jiffies - dpcm_play->last_jiffies; | 489 | delta_play = jiffies - dpcm_play->last_jiffies; |
| 474 | dpcm_play->last_jiffies += delta_play; | 490 | dpcm_play->last_jiffies += delta_play; |
| @@ -532,7 +548,7 @@ static snd_pcm_uframes_t loopback_pointer(struct snd_pcm_substream *substream) | |||
| 532 | static struct snd_pcm_hardware loopback_pcm_hardware = | 548 | static struct snd_pcm_hardware loopback_pcm_hardware = |
| 533 | { | 549 | { |
| 534 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | | 550 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | |
| 535 | SNDRV_PCM_INFO_MMAP_VALID), | 551 | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), |
| 536 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | | 552 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | |
| 537 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE | | 553 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE | |
| 538 | SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE), | 554 | SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE), |
| @@ -1060,6 +1076,7 @@ static void print_substream_info(struct snd_info_buffer *buffer, | |||
| 1060 | } | 1076 | } |
| 1061 | snd_iprintf(buffer, " valid: %u\n", cable->valid); | 1077 | snd_iprintf(buffer, " valid: %u\n", cable->valid); |
| 1062 | snd_iprintf(buffer, " running: %u\n", cable->running); | 1078 | snd_iprintf(buffer, " running: %u\n", cable->running); |
| 1079 | snd_iprintf(buffer, " pause: %u\n", cable->pause); | ||
| 1063 | print_dpcm_info(buffer, cable->streams[0], "Playback"); | 1080 | print_dpcm_info(buffer, cable->streams[0], "Playback"); |
| 1064 | print_dpcm_info(buffer, cable->streams[1], "Capture"); | 1081 | print_dpcm_info(buffer, cable->streams[1], "Capture"); |
| 1065 | } | 1082 | } |
