aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-05-21 05:59:57 -0400
committerTakashi Iwai <tiwai@suse.de>2012-05-21 06:03:54 -0400
commit4f7c39dc557cabdbc932ae83432cc225c480133c (patch)
tree4441b85e8a0c4301eff132131b82bb6ff615a3c3 /sound/core
parentd4c6983859a82422640c727d2426b435dfff56f4 (diff)
ALSA: pcm - Add proper state checks to snd_pcm_drain()
The handling for some PCM states is missing for snd_pcm_drain(). At least, XRUN streams should be simply dropped to SETUP, and a few initial invalid states should be rejected. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_native.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 3fe99e644eb8..53b5ada8f7c3 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1360,7 +1360,14 @@ static int snd_pcm_prepare(struct snd_pcm_substream *substream,
1360 1360
1361static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) 1361static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state)
1362{ 1362{
1363 substream->runtime->trigger_master = substream; 1363 struct snd_pcm_runtime *runtime = substream->runtime;
1364 switch (runtime->status->state) {
1365 case SNDRV_PCM_STATE_OPEN:
1366 case SNDRV_PCM_STATE_DISCONNECTED:
1367 case SNDRV_PCM_STATE_SUSPENDED:
1368 return -EBADFD;
1369 }
1370 runtime->trigger_master = substream;
1364 return 0; 1371 return 0;
1365} 1372}
1366 1373
@@ -1379,6 +1386,9 @@ static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state)
1379 case SNDRV_PCM_STATE_RUNNING: 1386 case SNDRV_PCM_STATE_RUNNING:
1380 runtime->status->state = SNDRV_PCM_STATE_DRAINING; 1387 runtime->status->state = SNDRV_PCM_STATE_DRAINING;
1381 break; 1388 break;
1389 case SNDRV_PCM_STATE_XRUN:
1390 runtime->status->state = SNDRV_PCM_STATE_SETUP;
1391 break;
1382 default: 1392 default:
1383 break; 1393 break;
1384 } 1394 }