Skip to content

Commit 1da681e

Browse files
Chancel Liubroonie
authored andcommitted
ASoC: soc-pcm.c: Clear DAIs parameters after stream_active is updated
DAIs parameters should be cleared if there's no active stream. Before, we implemented it in soc_pcm_hw_free() by detecting stream_active. If the running stream is the last active stream, we're going to clear parameters. However it will cause DAIs parameters never be cleared if there're more than one stream. For example, we have stream1 and stream2 about to stop. stream2 executes soc_pcm_hw_free() before stream1 executes soc_pcm_close(). At the moment, stream2 should clear DAIs parameters. Since stream_active is not yet updated by stream1 in soc_pcm_close(), stream2 will not clear DAIs parameters. In result both stream1 and stream2 don't clear the parameters. This patch moves DAIs parameters cleanup after stream_active is updated. Signed-off-by: Chancel Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 81ed7d9 commit 1da681e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

sound/soc/soc-pcm.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,17 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
709709

710710
snd_soc_dpcm_mutex_assert_held(rtd);
711711

712-
if (!rollback)
712+
if (!rollback) {
713713
snd_soc_runtime_deactivate(rtd, substream->stream);
714+
/* clear the corresponding DAIs parameters when going to be inactive */
715+
for_each_rtd_dais(rtd, i, dai) {
716+
if (snd_soc_dai_active(dai) == 0)
717+
soc_pcm_set_dai_params(dai, NULL);
718+
719+
if (snd_soc_dai_stream_active(dai, substream->stream) == 0)
720+
snd_soc_dai_digital_mute(dai, 1, substream->stream);
721+
}
722+
}
714723

715724
for_each_rtd_dais(rtd, i, dai)
716725
snd_soc_dai_shutdown(dai, substream, rollback);
@@ -940,15 +949,6 @@ static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
940949

941950
snd_soc_dpcm_mutex_assert_held(rtd);
942951

943-
/* clear the corresponding DAIs parameters when going to be inactive */
944-
for_each_rtd_dais(rtd, i, dai) {
945-
if (snd_soc_dai_active(dai) == 1)
946-
soc_pcm_set_dai_params(dai, NULL);
947-
948-
if (snd_soc_dai_stream_active(dai, substream->stream) == 1)
949-
snd_soc_dai_digital_mute(dai, 1, substream->stream);
950-
}
951-
952952
/* run the stream event */
953953
snd_soc_dapm_stream_stop(rtd, substream->stream);
954954

0 commit comments

Comments
 (0)