Skip to contentSkip to conversation

ALSA: pcm: Return 0 when size < start_threshold in capture

PATCH Superseded Ricardo Biehl Pasquali 2 participants 2 messages Aug 21, 2018 – Aug 22, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: Return 0 when size < start_threshold in capture

In __snd_pcm_lib_xfer(), when capture, if state is PREPARED and size is less than start_threshold nothing can be done. As there is no error, 0 is returned.

Am I missing something?

Cheers!

pasquali

pcm_lib.c renamed from pcm_lib.c.orig +9 -5
@@ -2125,7 +2125,7 @@
 	pcm_transfer_f transfer;
 	bool nonblock;
 	bool is_playback;
-	int err;
+	int err = 0;
 
 	err = pcm_sanity_check(substream);
 	if (err < 0)
@@ -2173,11 +2173,15 @@
 		goto _end_unlock;
 
 	if (!is_playback &&
-	    runtime->status->state == SNDRV_PCM_STATE_PREPARED &&
-	    size >= runtime->start_threshold) {
-		err = snd_pcm_start(substream);
-		if (err < 0)
+	    runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
+		if (size >= runtime->start_threshold) {
+			err = snd_pcm_start(substream);
+			if (err < 0)
+				goto _end_unlock;
+		} else {
+			/* nothing to do */
 			goto _end_unlock;
+		}
 	}
 
 	runtime->twake = runtime->control->avail_min ? : 1;
#1 lore raw
Quoted 6 lines · Ricardo Biehl Pasquali

In __snd_pcm_lib_xfer(), when capture, if state is PREPARED and size is less than start_threshold nothing can be done. As there is no error, 0 is returned.

Am I missing something?

Not really :)
It's just an undefined behavior, so far, and yes, the suggested behavior makes more sense.

Could you resubmit a proper patch for merging? Please follow Documentation/process/submitting-patches.rst.

thanks,

Takashi