Skip to content

Commit 00a399c

Browse files
committed
ALSA: pcm: Revert capture stream behavior change in blocking mode
In the commit 62ba568 ("ALSA: pcm: Return 0 when size < start_threshold in capture"), we changed the behavior of __snd_pcm_lib_xfer() to return immediately with 0 when a capture stream has a high start_threshold. This was intended to be a correction of the behavior consistency and looked harmless, but this was the culprit of the recent breakage reported by syzkaller, which was fixed by the commit e190161 ("ALSA: pcm: Fix tight loop of OSS capture stream"). At the time for the OSS fix, I didn't touch the behavior for ALSA native API, as assuming that this behavior actually is good. But this turned out to be also broken actually for a similar deployment, e.g. one thread goes to a write loop in blocking mode while another thread controls the start/stop of the stream manually. Overall, the original commit is harmful, and it brings less merit to keep that behavior. Let's revert it. Fixes: 62ba568 ("ALSA: pcm: Return 0 when size < start_threshold in capture") Fixes: e190161 ("ALSA: pcm: Fix tight loop of OSS capture stream") Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 0a5cf9e commit 00a399c

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

sound/core/pcm_lib.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,13 +2112,6 @@ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
21122112
return 0;
21132113
}
21142114

2115-
/* allow waiting for a capture stream that hasn't been started */
2116-
#if IS_ENABLED(CONFIG_SND_PCM_OSS)
2117-
#define wait_capture_start(substream) ((substream)->oss.oss)
2118-
#else
2119-
#define wait_capture_start(substream) false
2120-
#endif
2121-
21222115
/* the common loop for read/write data */
21232116
snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
21242117
void *data, bool interleaved,
@@ -2184,16 +2177,11 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
21842177
snd_pcm_update_hw_ptr(substream);
21852178

21862179
if (!is_playback &&
2187-
runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
2188-
if (size >= runtime->start_threshold) {
2189-
err = snd_pcm_start(substream);
2190-
if (err < 0)
2191-
goto _end_unlock;
2192-
} else if (!wait_capture_start(substream)) {
2193-
/* nothing to do */
2194-
err = 0;
2180+
runtime->status->state == SNDRV_PCM_STATE_PREPARED &&
2181+
size >= runtime->start_threshold) {
2182+
err = snd_pcm_start(substream);
2183+
if (err < 0)
21952184
goto _end_unlock;
2196-
}
21972185
}
21982186

21992187
avail = snd_pcm_avail(substream);

0 commit comments

Comments
 (0)