static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream,
snd_pcm_state_t state)
{
- struct snd_pcm_runtime *runtime = substream->runtime;
+ snd_pcm_state_t cur_state = snd_pcm_get_state(substream);
int f_flags = (__force int)state;
- if (runtime->state == SNDRV_PCM_STATE_OPEN ||
- runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
+ if (cur_state == SNDRV_PCM_STATE_OPEN ||
+ cur_state == SNDRV_PCM_STATE_DISCONNECTED)
return -EBADFD;
- if (snd_pcm_running(substream))
+ if (cur_state == SNDRV_PCM_STATE_RUNNING ||
+ (cur_state == SNDRV_PCM_STATE_DRAINING &&
+ substream->stream == SNDRV_PCM_STREAM_PLAYBACK))
return -EBUSY;
substream->f_flags = f_flags;
return 0;
card = substream->pcm->card;
runtime = substream->runtime;
- if (runtime->state == SNDRV_PCM_STATE_OPEN)
+ if (snd_pcm_get_state(substream) == SNDRV_PCM_STATE_OPEN)
return -EBADFD;
if (file) {
snd_pcm_uframes_t *frames = arg;
snd_pcm_sframes_t result;
- if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
+ if (snd_pcm_get_state(substream) == SNDRV_PCM_STATE_DISCONNECTED)
return -EBADFD;
switch (cmd) {