All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Cc: Jeff Chua <jeff.chua.linux@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Bagas Sanjaya <bagasdotme@gmail.com>,
	ALSA development <alsa-devel@alsa-project.org>
Subject: Re: linux-6.4 alsa sound broken
Date: Thu, 04 May 2023 08:15:09 +0200	[thread overview]
Message-ID: <87ttwsmxle.wl-tiwai@suse.de> (raw)
In-Reply-To: <ZFK9ZSm34Z3hQPF4@ugly>

On Wed, 03 May 2023 22:00:37 +0200,
Oswald Buddenhagen wrote:
> 
> On Wed, May 03, 2023 at 09:32:02PM +0200, Jaroslav Kysela wrote:
> > On 03. 05. 23 18:10, Takashi Iwai wrote:
> >> The dmix uses the silence_size=boundary as a fill-all operation, and
> >> it's a free-wheel mode, so supposedly something was overlooked in your
> >> code refactoring.
> >> 
> >> Could you check it and address quickly?  I'd like to fix it before
> >> 6.4-rc1 release, so if no fix comes up in a couple of days, I'll have
> >> to revert the change for 6.4-rc1.
> > 
> > I would revert this patch.
> 
> > It seems that this "do silence right after the playback is finished"
> > mechanism is not handled in the updated code (and I overlooked that,
> > too):
> > 
> no, there is nothing wrong with the code _per se_.
>
> what's happening is that the dmix plugin doesn't update the
> application pointer, and somehow gets away with it.
> 
> that means that it would have never worked with thresholded silencing
> mode, either, but, well, it uses top-up mode.

Well, the code made just a wrong interpretation for the behavior with
silence_size == boundary.  This mode is actually a kind of tailored
operation for dmix.

In the description of alsa-lib snd_pcm_sw_params_set_silence_size(),
you can find it:

/**
 * \brief Set silence size inside a software configuration container
 * \param pcm PCM handle
 * \param params Software configuration container
 * \param val Silence size in frames (0 for disabled)
 * \return 0 otherwise a negative error code
 *
 * A portion of playback buffer is overwritten with silence when playback
 * underrun is nearer than silence threshold (see 
 * #snd_pcm_sw_params_set_silence_threshold)
 *
 * The special case is when silence size value is equal or greater than
 * boundary. The unused portion of the ring buffer (initial written samples
 * are untouched) is filled with silence at start. Later, only just processed
 * sample area is filled with silence. Note: silence_threshold must be set to zero.
 */

So, the "top-up" silencing happens only at start, but not after that.
In the code path of hw_ptr update, it doesn't check the appl_ptr any
longer, but fills the processed area by the hw_ptr update with
silence.  That's the intended behavior for use cases of free-wheel
mode without appl_ptr updates like dmix.


Takashi

WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Cc: Jaroslav Kysela <perex@perex.cz>,
	Jeff Chua <jeff.chua.linux@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Bagas Sanjaya <bagasdotme@gmail.com>,
	ALSA development <alsa-devel@alsa-project.org>
Subject: Re: linux-6.4 alsa sound broken
Date: Thu, 04 May 2023 08:15:09 +0200	[thread overview]
Message-ID: <87ttwsmxle.wl-tiwai@suse.de> (raw)
In-Reply-To: <ZFK9ZSm34Z3hQPF4@ugly>

On Wed, 03 May 2023 22:00:37 +0200,
Oswald Buddenhagen wrote:
> 
> On Wed, May 03, 2023 at 09:32:02PM +0200, Jaroslav Kysela wrote:
> > On 03. 05. 23 18:10, Takashi Iwai wrote:
> >> The dmix uses the silence_size=boundary as a fill-all operation, and
> >> it's a free-wheel mode, so supposedly something was overlooked in your
> >> code refactoring.
> >> 
> >> Could you check it and address quickly?  I'd like to fix it before
> >> 6.4-rc1 release, so if no fix comes up in a couple of days, I'll have
> >> to revert the change for 6.4-rc1.
> > 
> > I would revert this patch.
> 
> > It seems that this "do silence right after the playback is finished"
> > mechanism is not handled in the updated code (and I overlooked that,
> > too):
> > 
> no, there is nothing wrong with the code _per se_.
>
> what's happening is that the dmix plugin doesn't update the
> application pointer, and somehow gets away with it.
> 
> that means that it would have never worked with thresholded silencing
> mode, either, but, well, it uses top-up mode.

Well, the code made just a wrong interpretation for the behavior with
silence_size == boundary.  This mode is actually a kind of tailored
operation for dmix.

In the description of alsa-lib snd_pcm_sw_params_set_silence_size(),
you can find it:

/**
 * \brief Set silence size inside a software configuration container
 * \param pcm PCM handle
 * \param params Software configuration container
 * \param val Silence size in frames (0 for disabled)
 * \return 0 otherwise a negative error code
 *
 * A portion of playback buffer is overwritten with silence when playback
 * underrun is nearer than silence threshold (see 
 * #snd_pcm_sw_params_set_silence_threshold)
 *
 * The special case is when silence size value is equal or greater than
 * boundary. The unused portion of the ring buffer (initial written samples
 * are untouched) is filled with silence at start. Later, only just processed
 * sample area is filled with silence. Note: silence_threshold must be set to zero.
 */

So, the "top-up" silencing happens only at start, but not after that.
In the code path of hw_ptr update, it doesn't check the appl_ptr any
longer, but fills the processed area by the hw_ptr update with
silence.  That's the intended behavior for use cases of free-wheel
mode without appl_ptr updates like dmix.


Takashi

  parent reply	other threads:[~2023-05-04  6:16 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01  3:59 linux-6.4 alsa sound broken Jeff Chua
2023-05-01  4:36 ` Bagas Sanjaya
2023-05-01  6:35   ` Takashi Iwai
2023-05-01  6:35     ` Takashi Iwai
2023-05-01 13:16     ` Jeff Chua
2023-05-01 13:16       ` Jeff Chua
2023-05-01 14:52       ` Takashi Iwai
2023-05-01 14:52         ` Takashi Iwai
2023-05-01 15:03         ` Jeff Chua
2023-05-01 15:03           ` Jeff Chua
2023-05-03  4:40           ` Bagas Sanjaya
2023-05-03  4:40             ` Bagas Sanjaya
2023-05-03  5:42             ` Jeff Chua
2023-05-03  5:42               ` Jeff Chua
2023-05-01 13:08   ` Jeff Chua
2023-05-01 13:08     ` Jeff Chua
2023-05-01  7:17 ` Oswald Buddenhagen
2023-05-01 15:05   ` Jeff Chua
2023-05-03  4:34     ` Bagas Sanjaya
2023-05-03  4:37       ` Bagas Sanjaya
2023-05-03  6:06         ` Takashi Iwai
2023-05-03 12:19           ` Jeff Chua
2023-05-03 13:44             ` Takashi Iwai
2023-05-03 15:06               ` Jeff Chua
2023-05-03 15:47                 ` Takashi Iwai
2023-05-03 16:10   ` Takashi Iwai
2023-05-03 19:32     ` Jaroslav Kysela
2023-05-03 20:00       ` Oswald Buddenhagen
2023-05-03 20:17         ` Jaroslav Kysela
2023-05-04  6:15         ` Takashi Iwai [this message]
2023-05-04  6:15           ` 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=87ttwsmxle.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=bagasdotme@gmail.com \
    --cc=jeff.chua.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oswald.buddenhagen@gmx.de \
    /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.