linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Jiada Wang <jiada_wang@mentor.com>, perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, apape@de.adit-jv.com,
	linux-kernel@vger.kernel.org, Mark_Craske@mentor.com
Subject: Re: [PATCH 2/3 v2] ALSA: usb-audio: avoid setting of sample rate multiple times on bus
Date: Thu, 1 Dec 2016 07:19:52 +0900	[thread overview]
Message-ID: <3e73cbb9-e19e-97d7-3ca0-fe7a8f018270@sakamocchi.jp> (raw)
In-Reply-To: <c4579c3f-4798-7096-2c05-b0670ccbad08@sakamocchi.jp>

On Nov 30 2016 19:45, Takashi Sakamoto wrote:
> Hi Jiada,
>
> I don't oppose this patch. Nevertheless, your description is not
> necessarily correct.
>
> On Nov 30 2016 16:59, Jiada Wang wrote:
>> From: Daniel Girnus <dgirnus@de.adit-jv.com>
>>
>> ALSA usually calls the prepare function twice before starting the
>> playback:
>> 1. On hw_params call from userland and
>> 2. internally when starting the stream.
>
> ALSA PCM core in kernel land doesn't perform like this.
>
> In alsa-lib, 'snd_pcm_hw_params()' calls 'snd_pcm_hw_params_internal()'
> and 'snd_pcm_prepare()' sequentially.
> http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm.c;h=cd87bc759ded95953e332b7e8d56b0f2d5b4185d;hb=HEAD#l853
>
>
> In system call level (e.g. see by strace(1)), this looks like two
> ioctl(2)s with 'SNDRV_PCM_IOCTL_HW_PARAMS' and 'SNDRV_PCM_IOCTL_PREPARE'.
>
> Well, when applications are written to execute 'snd_pcm_hw_params()' and
> 'snd_pcm_hw_prepare()' sequentially, additional ioctl(2) with
> 'SNDRV_PCM_IOCTL_PREPARE' appears. PulseAudio is this kind of
> application. I indicated the useless in 2014, but it still remains:
> https://lists.freedesktop.org/archives/pulseaudio-discuss/2014-January/019773.html
>
>
> You have the misunderstanding due to a nature of alsa-lib and tendency
> of major applications, from my point of view.

So here you should mention that current USB Audio device class driver 
somewhat ignores state machine of ALSA PCM runtime.

In ALSA PCM core, state of the runtime is described in 'struct 
snd_pcm_runtime.status.state' with macros of 'SNDRV_PCM_STATE_XXX'. 
Applications are allowed to handle the runtime according to the state.

In your issue, the driver is programmed ignoring a case that double 
calls of snd_pcm_prepare(), in short, ioctl(PREPARE) is called in 
'PREPARED' state. This is not only an issue for snd-usb-audio, but also 
for snd-usb-hiface.
http://mailman.alsa-project.org/pipermail/alsa-devel/2016-November/115174.html

For these issue, I have no patch proposals because I have few test 
devices, sorry.


Regards

Takashi Sakamoto

  reply	other threads:[~2016-11-30 22:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30  7:59 [PATCH 0/3 v1] usb-misc fix Jiada Wang
2016-11-30  7:59 ` [PATCH 1/3 v1] ALSA: usb-audio: more tolerant packetsize Jiada Wang
2016-11-30  8:54   ` Takashi Iwai
2016-12-01  7:04     ` Jiada Wang
2016-12-01  7:41   ` [alsa-devel] " Clemens Ladisch
2016-12-01  8:58     ` Takashi Iwai
2016-12-01 11:16       ` Clemens Ladisch
2016-12-01 11:23         ` Takashi Iwai
2016-12-01 11:50           ` Clemens Ladisch
     [not found]     ` <58400B3A.7080806@mentor.com>
2016-12-01 12:15       ` Clemens Ladisch
2016-11-30  7:59 ` [PATCH 2/3 v2] ALSA: usb-audio: avoid setting of sample rate multiple times on bus Jiada Wang
2016-11-30  8:51   ` Takashi Iwai
2016-12-01  7:07     ` Jiada Wang
2016-11-30 10:45   ` Takashi Sakamoto
2016-11-30 22:19     ` Takashi Sakamoto [this message]
2016-12-05  7:32     ` Jiada Wang
2016-12-05  9:58       ` Takashi Sakamoto
2016-11-30  7:59 ` [PATCH 3/3 v3] ALSA: usb-audio: fix race in snd_usb_endpoint_stop Jiada Wang
2016-11-30  9:00   ` Takashi Iwai
2016-12-05 10:10     ` Jiada Wang
2016-12-05 10:30       ` 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=3e73cbb9-e19e-97d7-3ca0-fe7a8f018270@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=Mark_Craske@mentor.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=apape@de.adit-jv.com \
    --cc=jiada_wang@mentor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --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;
as well as URLs for NNTP newsgroup(s).