public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Ivan Orlov <ivan.orlov0322@gmail.com>
Cc: perex@perex.cz, tiwai@suse.com, corbet@lwn.net,
	broonie@kernel.org, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	christophe.jaillet@wanadoo.fr, aholzinger@gmx.de
Subject: Re: [PATCH v5 0/4] Introduce userspace-driven ALSA timers
Date: Sun, 18 Aug 2024 10:02:52 +0200	[thread overview]
Message-ID: <87a5ha1cnn.wl-tiwai@suse.de> (raw)
In-Reply-To: <20240813120701.171743-1-ivan.orlov0322@gmail.com>

On Tue, 13 Aug 2024 14:06:57 +0200,
Ivan Orlov wrote:
> 
> There are multiple possible timer sources which could be useful for
> the sound stream synchronization: hrtimers, hardware clocks (e.g. PTP),
> timer wheels (jiffies). Currently, using one of them to synchronize
> the audio stream of snd-aloop module would require writing a
> kernel-space driver which exports an ALSA timer through the
> snd_timer interface.
> 
> However, it is not really convenient for application developers, who may
> want to define their custom timer sources for audio synchronization.
> 
> For instance, we could have a network application which receives frames
> and sends them to snd-aloop pcm device, and another application
> listening on the other end of snd-aloop. It makes sense to transfer a
> new period of data only when certain amount of frames is received
> through the network, but definitely not when a certain amount of jiffies
> on a local system elapses. Since all of the devices are purely virtual
> it won't introduce any glitches and will help the application developers
> to avoid using sample-rate conversion.
> 
> This patch series introduces userspace-driven ALSA timers: virtual
> timers which are created and controlled from userspace. The timer can
> be created from the userspace using the new ioctl SNDRV_TIMER_IOCTL_CREATE.
> After creating a timer, it becomes available for use system-wide, so it
> can be passed to snd-aloop as a timer source (timer_source parameter
> would be "-1.SNDRV_TIMER_GLOBAL_UDRIVEN.{timer_id}"). When the userspace
> app decides to trigger a timer, it calls another ioctl
> SNDRV_TIMER_IOCTL_TRIGGER on the file descriptor of a timer. It
> initiates a transfer of a new period of data.
> 
> Userspace-driven timers are associated with file descriptors. If the
> application wishes to destroy the timer, it can simply release the file
> descriptor of a virtual timer.
> 
> I believe introducing new ioctl calls is quite inconvenient (as we have
> a limited amount of them), but other possible ways of app <-> kernel
> communication (like virtual FS) seem completely inappropriate for this
> task (but I'd love to discuss alternative solutions).
> 
> This patch series also updates the snd-aloop module so the global timers
> can be used as a timer_source for it (it allows using userspace-driven
> timers as timer source).
> 
> V1 -> V2:
> - Fix some problems found by Christophe Jaillet
> <christophe.jaillet@wanadoo.fr>
> V2 -> V3:
> - Add improvements suggested by Takashi Iwai <tiwai@suse.de>
> V3 -> V4:
> - Address comments from Jaroslav Kysela <perex@perex.cz> and Mark Brown
> <broonie@kernel.org>
> V4 -> V5:
> - Add missing error processing noticed by Takashi Iwai <tiwai@suse.de>
> - Return timer file descriptor as part of the snd_timer_uinfo structure.
> This is a more standard way of using ioctl interface, where the return
> value of the ioctl is either 0 or an error code.
> 
> Please, find the patch-specific changelog in the following patches.
> 
> Ivan Orlov (4):
>   ALSA: aloop: Allow using global timers
>   Docs/sound: Add documentation for userspace-driven ALSA timers
>   ALSA: timer: Introduce virtual userspace-driven timers
>   selftests: ALSA: Cover userspace-driven timers with test

Now applied to for-next branch.


thanks,

Takashi

      parent reply	other threads:[~2024-08-18  8:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13 12:06 [PATCH v5 0/4] Introduce userspace-driven ALSA timers Ivan Orlov
2024-08-13 12:06 ` [PATCH v5 1/4] ALSA: aloop: Allow using global timers Ivan Orlov
2024-08-13 12:06 ` [PATCH v5 2/4] Docs/sound: Add documentation for userspace-driven ALSA timers Ivan Orlov
2024-08-13 12:07 ` [PATCH v5 3/4] ALSA: timer: Introduce virtual userspace-driven timers Ivan Orlov
2024-08-13 12:07 ` [PATCH v5 4/4] selftests: ALSA: Cover userspace-driven timers with test Ivan Orlov
2024-08-18  8:02 ` Takashi Iwai [this message]

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=87a5ha1cnn.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=aholzinger@gmx.de \
    --cc=broonie@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=corbet@lwn.net \
    --cc=ivan.orlov0322@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=shuah@kernel.org \
    --cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox