All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Robert Lee <lerobert@google.com>
Cc: Jaroslav Kysela <perex@perex.cz>,
	vkoul@kernel.org, tiwai@suse.com, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org, carterhsu@google.com,
	zxinhui@google.com, bubblefang@google.com
Subject: Re: [Patch v2] ALSA: compress: allow to leave draining state when pausing in draining
Date: Fri, 09 Jul 2021 09:47:36 +0200	[thread overview]
Message-ID: <s5hsg0o3p47.wl-tiwai@suse.de> (raw)
In-Reply-To: <CAOM6g_D4dkwDcQza9fVXn9=uXSYTBThNVHqWb0YjLWkc_eBwog@mail.gmail.com>

On Fri, 09 Jul 2021 04:08:29 +0200,
Robert Lee wrote:
> 
> Jaroslav Kysela <perex@perex.cz> 於 2021年7月8日 週四 下午10:53寫道:
> >
> > On 08. 07. 21 15:47, Robert Lee wrote:
> > > Hi Takashi,
> > >
> > > It is a little complex to describe the design in detail, but try to
> > > explain simply
> > > what issue we meet.
> > >
> > > If w/o the change,  after user resumes from the pause, our system would call
> > > snd_compr_drain() or snd_compr_partial_drain() again after it returns from
> > > previous drain (when EOF reaches). Then it will block in this drain and no one
> > > wake it up because EOF has already reached. I add this change to return from
> > > the previous drain.
> >
> > It looks like that the driver does not call snd_compr_drain_notify() so the
> > state is not updated to SETUP on EOF.
> >
> We indeed call snd_compr_drain_notify() on EOF, but after return from
> wait_for _drain there is another drain again immediately.
> Looks like the system queue some states change on user space and need
> to drain again after resume from pause.
> I suppose there is different design on user space so I add the hook to
> handle diffent usage.

Right, the previous drain-in-pause implementation was purely in the
kernel side, and user-space didn't change much; after resuming from
the pause, the driver resumes exactly to the same state before the
pause (i.e. start draining again).

The difference sounds similar like the suspend/resume scheme; some
does resume by itself to the previous state while some requires the
explicit action.

> > > Actually, I am wondering how the pause-during-drain can keep the state in
> > > DRAINING. It should have a different design. :)
> >
> > I already proposed to add a new state (because it's a new state), but the
> > conservative way was elected to avoid user space changes.

Yes, the primary concern is that the compress API uses the very same
state like PCM, and if we extend PCM state, it'll be a much larger
problem.  And, even if we change the state to compress-only, it's
still an ABI incompatibility, and it has to be carefully handled not
to break the existing application (e.g. expose the new state only when
the application is really ready to handle -- introducing a new ioctl
for state or introduce a new ioctl like SNDRV_PCM_IOCTL_USER_PVERSION
that informs the ABI version the user-space understands).


Takashi

WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Robert Lee <lerobert@google.com>
Cc: alsa-devel@alsa-project.org, zxinhui@google.com,
	carterhsu@google.com, linux-kernel@vger.kernel.org,
	tiwai@suse.com, vkoul@kernel.org, bubblefang@google.com
Subject: Re: [Patch v2] ALSA: compress: allow to leave draining state when pausing in draining
Date: Fri, 09 Jul 2021 09:47:36 +0200	[thread overview]
Message-ID: <s5hsg0o3p47.wl-tiwai@suse.de> (raw)
In-Reply-To: <CAOM6g_D4dkwDcQza9fVXn9=uXSYTBThNVHqWb0YjLWkc_eBwog@mail.gmail.com>

On Fri, 09 Jul 2021 04:08:29 +0200,
Robert Lee wrote:
> 
> Jaroslav Kysela <perex@perex.cz> 於 2021年7月8日 週四 下午10:53寫道:
> >
> > On 08. 07. 21 15:47, Robert Lee wrote:
> > > Hi Takashi,
> > >
> > > It is a little complex to describe the design in detail, but try to
> > > explain simply
> > > what issue we meet.
> > >
> > > If w/o the change,  after user resumes from the pause, our system would call
> > > snd_compr_drain() or snd_compr_partial_drain() again after it returns from
> > > previous drain (when EOF reaches). Then it will block in this drain and no one
> > > wake it up because EOF has already reached. I add this change to return from
> > > the previous drain.
> >
> > It looks like that the driver does not call snd_compr_drain_notify() so the
> > state is not updated to SETUP on EOF.
> >
> We indeed call snd_compr_drain_notify() on EOF, but after return from
> wait_for _drain there is another drain again immediately.
> Looks like the system queue some states change on user space and need
> to drain again after resume from pause.
> I suppose there is different design on user space so I add the hook to
> handle diffent usage.

Right, the previous drain-in-pause implementation was purely in the
kernel side, and user-space didn't change much; after resuming from
the pause, the driver resumes exactly to the same state before the
pause (i.e. start draining again).

The difference sounds similar like the suspend/resume scheme; some
does resume by itself to the previous state while some requires the
explicit action.

> > > Actually, I am wondering how the pause-during-drain can keep the state in
> > > DRAINING. It should have a different design. :)
> >
> > I already proposed to add a new state (because it's a new state), but the
> > conservative way was elected to avoid user space changes.

Yes, the primary concern is that the compress API uses the very same
state like PCM, and if we extend PCM state, it'll be a much larger
problem.  And, even if we change the state to compress-only, it's
still an ABI incompatibility, and it has to be carefully handled not
to break the existing application (e.g. expose the new state only when
the application is really ready to handle -- introducing a new ioctl
for state or introduce a new ioctl like SNDRV_PCM_IOCTL_USER_PVERSION
that informs the ABI version the user-space understands).


Takashi

  reply	other threads:[~2021-07-09  7:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  2:08 [Patch v2] ALSA: compress: allow to leave draining state when pausing in draining Robert Lee
2021-07-08  2:08 ` Robert Lee
2021-07-08 11:24 ` Takashi Iwai
2021-07-08 11:24   ` Takashi Iwai
2021-07-08 13:47   ` Robert Lee
2021-07-08 13:47     ` Robert Lee
2021-07-08 14:53     ` Jaroslav Kysela
2021-07-08 14:53       ` Jaroslav Kysela
2021-07-09  2:08       ` Robert Lee
2021-07-09  2:08         ` Robert Lee
2021-07-09  7:47         ` Takashi Iwai [this message]
2021-07-09  7:47           ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hsg0o3p47.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=bubblefang@google.com \
    --cc=carterhsu@google.com \
    --cc=lerobert@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    --cc=zxinhui@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.