From 1dc5921082d48dc53e48e88ae2f9a24b9737307d Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Wed, 12 Jun 2019 17:44:08 +0900 Subject: ALSA: fireworks: unify substream counter This commit is a part of preparation to perform allocation/release of isochronous resources in pcm.hw_params/hw_free callbacks. It's inconvenient to handle two isochronous context separately each other. This commit unifies the counters to handle the two at the same time. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/fireworks/fireworks_stream.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'sound/firewire/fireworks/fireworks_stream.c') diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 74e122e6e68a..2df39befcde0 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -194,9 +194,9 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) unsigned int curr_rate; int err = 0; - /* Need no substreams */ - if (efw->playback_substreams == 0 && efw->capture_substreams == 0) - goto end; + // Need no substreams. + if (efw->substreams_counter == 0) + return -EIO; /* * Considering JACK/FFADO streaming: @@ -206,19 +206,15 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) if (err < 0) goto end; - /* packet queueing error */ - if (amdtp_streaming_error(&efw->tx_stream)) - stop_stream(efw, &efw->tx_stream); - if (amdtp_streaming_error(&efw->rx_stream)) - stop_stream(efw, &efw->rx_stream); - /* stop streams if rate is different */ err = snd_efw_command_get_sampling_rate(efw, &curr_rate); if (err < 0) goto end; if (rate == 0) rate = curr_rate; - if (rate != curr_rate) { + if (rate != curr_rate || + amdtp_streaming_error(&efw->tx_stream) || + amdtp_streaming_error(&efw->rx_stream)) { stop_stream(efw, &efw->tx_stream); stop_stream(efw, &efw->rx_stream); } @@ -237,13 +233,12 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) } } - /* start slave if needed */ - if (efw->capture_substreams > 0 && - !amdtp_stream_running(&efw->tx_stream)) { + if (!amdtp_stream_running(&efw->tx_stream)) { err = start_stream(efw, &efw->tx_stream, rate); if (err < 0) { dev_err(&efw->unit->device, "fail to start AMDTP slave stream:%d\n", err); + stop_stream(efw, &efw->tx_stream); stop_stream(efw, &efw->rx_stream); } } @@ -253,11 +248,9 @@ end: void snd_efw_stream_stop_duplex(struct snd_efw *efw) { - if (efw->capture_substreams == 0) { + if (efw->substreams_counter == 0) { stop_stream(efw, &efw->tx_stream); - - if (efw->playback_substreams == 0) - stop_stream(efw, &efw->rx_stream); + stop_stream(efw, &efw->rx_stream); } } -- cgit