From: Takashi Iwai Subject: Re: [PATCH - IOPLUG 1/1] pcm: ioplug: update Prepare and draining state correctly Date: Fri, 16 Mar 2018 11:08:44 +0100 Message-ID: References: <1521194574-20196-1-git-send-email-twischer@de.adit-jv.com> <1521194574-20196-2-git-send-email-twischer@de.adit-jv.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 1E150267380 for ; Fri, 16 Mar 2018 11:08:45 +0100 (CET) In-Reply-To: <1521194574-20196-2-git-send-email-twischer@de.adit-jv.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: twischer@de.adit-jv.com Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Fri, 16 Mar 2018 11:02:54 +0100, wrote: > > From: Timo Wischer > > PREPARED should only be set when it is done and it was successfully. > > DRAINING should be signalled when starting to drain. There is no need to > check if draining was successfully because it will change to drop (SETUP) > in any case. > > Signed-off-by: Timo Wischer > > diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c > index af223a1..e60b688 100644 > --- a/src/pcm/pcm_ioplug.c > +++ b/src/pcm/pcm_ioplug.c > @@ -146,13 +146,18 @@ static int snd_pcm_ioplug_prepare(snd_pcm_t *pcm) > ioplug_priv_t *io = pcm->private_data; > int err = 0; > > - io->data->state = SND_PCM_STATE_PREPARED; > snd_pcm_ioplug_reset(pcm); > if (io->data->callback->prepare) { > snd_pcm_unlock(pcm); /* to avoid deadlock */ > err = io->data->callback->prepare(io->data); > snd_pcm_lock(pcm); > } > + if (err < 0) > + return err; > + > + gettimestamp(&io->trigger_tstamp, pcm->tstamp_type); The trigger_tstamp is updated only when triggered (START, STOP, PAUSE, etc). And this change wasn't even documented in the changelog. > + io->data->state = SND_PCM_STATE_PREPARED; > + > return err; > } > > @@ -493,6 +498,10 @@ static int snd_pcm_ioplug_drain(snd_pcm_t *pcm) > > if (io->data->state == SND_PCM_STATE_OPEN) > return -EBADFD; > + > + gettimestamp(&io->trigger_tstamp, pcm->tstamp_type); Ditto. thanks, Takashi > + io->data->state = SND_PCM_STATE_DRAINING; > + > if (io->data->callback->drain) > io->data->callback->drain(io->data); > snd_pcm_lock(pcm); > -- > 2.7.4 >