Linux Sound subsystem development
 help / color / mirror / Atom feed
From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Jaroslav Kysela <perex@perex.cz>, linux-sound@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>, Takashi Sakamoto <takaswie@kernel.org>
Subject: Re: [PATCH v5 1/2] ALSA: pcm: reinvent the stream synchronization ID API
Date: Mon, 24 Jun 2024 15:38:48 +0200	[thread overview]
Message-ID: <28a5fde3-a02a-45c1-b3d7-25ae3fcfcfcc@linux.intel.com> (raw)
In-Reply-To: <20240624131127.498605-2-perex@perex.cz>

On 6/24/2024 3:07 PM, Jaroslav Kysela wrote:
> Until the commit e11f0f90a626 ("ALSA: pcm: remove SNDRV_PCM_IOCTL1_INFO
> internal command"), there was a possibility to pass information
> about the synchronized streams to the user space. The mentioned
> commit removed blindly the appropriate code with an irrelevant comment.
> 
> The revert may be appropriate, but since this API was lost for several
> years without any complains, it's time to improve it. The hardware
> parameters may change the used stream clock source (e.g. USB hardware)
> so move this synchronization ID to hw_params as read-only field.
> 
> It seems that pipewire can benefit from this API (disable adaptive
> resampling for perfectly synchronized PCM streams) now.
> 
> Note that the contents of ID is not supposed to be used for direct
> comparison with a specific byte sequence. The "empty" case is when
> all bytes are zero (driver does not offer this information)
> and all other cases must be only used for equal comparison among
> PCM streams (including different sound cards) if they are using
> identical hardware clock.
> 
> Cc: Takashi Sakamoto <takaswie@kernel.org>
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
> ---

(...)

>   
> @@ -420,7 +420,8 @@ struct snd_pcm_hw_params {
>   	unsigned int rate_num;		/* R: rate numerator */
>   	unsigned int rate_den;		/* R: rate denominator */
>   	snd_pcm_uframes_t fifo_size;	/* R: chip FIFO size in frames */
> -	unsigned char reserved[64];	/* reserved for future */
> +	unsigned char sync[16];		/* R: synchronization ID (perfect sync - one clock source) */

If it is introduced as new API, can't this be done better? Maybe like:
struct sync {
	char cardnum[4];
	char id[12];
};
or maybe just:
struct sync {
	u32 cardnum;
	char id[12];
};
or something like that? It is bit hard to follow in next patch all this 
params->sync + 4 and memset/strncpy. And having named fields would help.

Thanks,
Amadeusz

  reply	other threads:[~2024-06-24 13:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 13:07 [PATCH v5 0/2] ALSA: pcm: reinvent the stream synchronization ID API Jaroslav Kysela
2024-06-24 13:07 ` [PATCH v5 1/2] " Jaroslav Kysela
2024-06-24 13:38   ` Amadeusz Sławiński [this message]
2024-06-24 13:56     ` Jaroslav Kysela
2024-06-24 14:10       ` Amadeusz Sławiński
2024-06-24 13:07 ` [PATCH v5 2/2] ALSA: pcm: optimize and clarify stream sychronization " Jaroslav Kysela
2024-06-24 14:10   ` Amadeusz Sławiński
2024-06-24 14:20     ` Jaroslav Kysela

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=28a5fde3-a02a-45c1-b3d7-25ae3fcfcfcc@linux.intel.com \
    --to=amadeuszx.slawinski@linux.intel.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=takaswie@kernel.org \
    --cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox