All of lore.kernel.org
 help / color / mirror / Atom feed
* Correct stopping capture and playback substreams?
@ 2021-12-23  8:18 Pavel Hofman
  2022-01-03  8:22   ` Pavel Hofman
  0 siblings, 1 reply; 21+ messages in thread
From: Pavel Hofman @ 2021-12-23  8:18 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, John Keeping

Hi Takashi,

I am working on stopping alsa streams of audio USB gadget when USB host 
stops capture/playback/USB cable unplugged.

For capture I used code from AK4114 SPDIF receiver 
https://elixir.bootlin.com/linux/latest/source/sound/i2c/other/ak4114.c#L590:

static void stop_substream(struct uac_rtd_params *prm)
{
	unsigned long _flags;
	struct snd_pcm_substream *substream;

	substream = prm->ss;
	if (substream) {
		snd_pcm_stream_lock_irqsave(substream, _flags);
		if (snd_pcm_running(substream))
			// TODO - correct handling for playback substream?
			snd_pcm_stop(substream, SNDRV_PCM_STATE_DRAINING);
		snd_pcm_stream_unlock_irqrestore(substream, _flags);
	}
}

For setup I found calling snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP) 
(https://elixir.bootlin.com/linux/latest/source/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c#L63) 
  Or for both capture and playback using SNDRV_PCM_STATE_DISCONNECTED 
(https://elixir.bootlin.com/linux/latest/source/sound/core/pcm.c#L1103).

Or perhaps using snd_pcm_dev_disconnect(dev) or snd_pcm_drop(substream)?

Please what is the recommended way?

Thanks a lot,

Pavel.

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-01-05 12:08 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23  8:18 Correct stopping capture and playback substreams? Pavel Hofman
2022-01-03  8:22 ` Pavel Hofman
2022-01-03  8:22   ` Pavel Hofman
2022-01-03  9:10   ` Jaroslav Kysela
2022-01-03 11:32     ` Pavel Hofman
2022-01-03 12:15       ` Takashi Iwai
2022-01-03 12:15         ` Takashi Iwai
2022-01-03 12:28         ` Jaroslav Kysela
2022-01-03 12:28           ` Jaroslav Kysela
2022-01-03 12:36           ` Takashi Iwai
2022-01-03 12:36             ` Takashi Iwai
2022-01-03 12:54           ` Pavel Hofman
2022-01-03 12:54             ` Pavel Hofman
2022-01-04 15:57             ` John Keeping
2022-01-04 15:57               ` John Keeping
2022-01-04 16:21               ` John Keeping
2022-01-04 16:21                 ` John Keeping
2022-01-05 12:07                 ` Pavel Hofman
2022-01-05 12:07                   ` Pavel Hofman
2022-01-03 12:44         ` Pavel Hofman
2022-01-03 12:44           ` Pavel Hofman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.