Skip to content

Commit fb51f1c

Browse files
committed
ALSA: pcm: Workaround for weird PulseAudio behavior on rewind error
The commit 9027c46 ("ALSA: pcm: Call ack() whenever appl_ptr is updated") introduced the possible error code returned from the PCM rewind ioctl. Basically the change was for handling the indirect PCM more correctly, but ironically, it caused rather a side-effect: PulseAudio gets pissed off when receiving an error from rewind, throws everything away and stops processing further, resulting in the silence. It's clearly a failure in the application side, so the best would be to fix that bug in PA. OTOH, PA is mostly the only user of the rewind feature, so it's not good to slap the sole customer. This patch tries to mitigate the situation: instead of returning an error, now the rewind ioctl returns zero when the driver can't rewind. It indicates that no rewind was performed, so the behavior is consistent, at least. Fixes: 9027c46 ("ALSA: pcm: Call ack() whenever appl_ptr is updated") Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 6708913 commit fb51f1c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sound/core/pcm_native.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,7 +2580,7 @@ static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream,
25802580
return ret < 0 ? ret : frames;
25812581
}
25822582

2583-
/* decrease the appl_ptr; returns the processed frames or a negative error */
2583+
/* decrease the appl_ptr; returns the processed frames or zero for error */
25842584
static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream,
25852585
snd_pcm_uframes_t frames,
25862586
snd_pcm_sframes_t avail)
@@ -2597,7 +2597,12 @@ static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream,
25972597
if (appl_ptr < 0)
25982598
appl_ptr += runtime->boundary;
25992599
ret = pcm_lib_apply_appl_ptr(substream, appl_ptr);
2600-
return ret < 0 ? ret : frames;
2600+
/* NOTE: we return zero for errors because PulseAudio gets depressed
2601+
* upon receiving an error from rewind ioctl and stops processing
2602+
* any longer. Returning zero means that no rewind is done, so
2603+
* it's not absolutely wrong to answer like that.
2604+
*/
2605+
return ret < 0 ? 0 : frames;
26012606
}
26022607

26032608
static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *substream,

0 commit comments

Comments
 (0)