Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e647f5a5 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: pcm: Use snd_pcm_stop_xrun() for xrun injection



Basically the xrun injection routine can simply call the standard
helper snd_pcm_stop_xrun(), but with one exception: it may be called
even when the stream is closed.

Make snd_pcm_stop_xrun() more robust and check the NULL runtime state,
and simplify xrun injection code by calling it.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9cd641ed
Loading
Loading
Loading
Loading
+1 −6
Original line number Original line Diff line number Diff line
@@ -492,13 +492,8 @@ static void snd_pcm_xrun_injection_write(struct snd_info_entry *entry,
					 struct snd_info_buffer *buffer)
					 struct snd_info_buffer *buffer)
{
{
	struct snd_pcm_substream *substream = entry->private_data;
	struct snd_pcm_substream *substream = entry->private_data;
	struct snd_pcm_runtime *runtime;


	snd_pcm_stream_lock_irq(substream);
	snd_pcm_stop_xrun(substream);
	runtime = substream->runtime;
	if (runtime && runtime->status->state == SNDRV_PCM_STATE_RUNNING)
		__snd_pcm_xrun(substream);
	snd_pcm_stream_unlock_irq(substream);
}
}


static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry,
static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry,
+1 −1
Original line number Original line Diff line number Diff line
@@ -1339,7 +1339,7 @@ int snd_pcm_stop_xrun(struct snd_pcm_substream *substream)
	unsigned long flags;
	unsigned long flags;


	snd_pcm_stream_lock_irqsave(substream, flags);
	snd_pcm_stream_lock_irqsave(substream, flags);
	if (snd_pcm_running(substream))
	if (substream->runtime && snd_pcm_running(substream))
		__snd_pcm_xrun(substream);
		__snd_pcm_xrun(substream);
	snd_pcm_stream_unlock_irqrestore(substream, flags);
	snd_pcm_stream_unlock_irqrestore(substream, flags);
	return 0;
	return 0;