Skip to content

Commit

Permalink
ALSA: pcm: Update hardware pointer before start capture
Browse files Browse the repository at this point in the history
This ensures the transfer loop won't waste a run to read
the few frames (if any) between start and hw_ptr update.
It will wait for the next interrupt with wait_for_avail().

Signed-off-by: Ricardo Biehl Pasquali <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
psqli authored and tiwai committed Sep 10, 2018
1 parent 70f7922 commit 64b6acf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sound/core/pcm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,10 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
if (err < 0)
goto _end_unlock;

runtime->twake = runtime->control->avail_min ? : 1;
if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
snd_pcm_update_hw_ptr(substream);

if (!is_playback &&
runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
if (size >= runtime->start_threshold) {
Expand All @@ -2185,10 +2189,8 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
}
}

runtime->twake = runtime->control->avail_min ? : 1;
if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
snd_pcm_update_hw_ptr(substream);
avail = snd_pcm_avail(substream);

while (size > 0) {
snd_pcm_uframes_t frames, appl_ptr, appl_ofs;
snd_pcm_uframes_t cont;
Expand Down

0 comments on commit 64b6acf

Please sign in to comment.