From: Takashi Iwai Subject: Re: [PATCH 0/5] RFC for snd-usb: rework usb endpoint logic Date: Tue, 01 Nov 2011 17:19:27 +0100 Message-ID: References: <1320063030-3502-1-git-send-email-zonque@gmail.com> <4EAE96BC.6060605@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 344D92446D for ; Tue, 1 Nov 2011 17:19:30 +0100 (CET) In-Reply-To: <4EAE96BC.6060605@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Daniel Mack Cc: blablack@gmail.com, alsa-devel@alsa-project.org, clemens@ladisch.de, gdiffey@gmail.com, linuxaudio@showlabor.de List-Id: alsa-devel@alsa-project.org At Mon, 31 Oct 2011 13:38:20 +0100, Daniel Mack wrote: > > On 10/31/2011 01:10 PM, Daniel Mack wrote: > > I didn't sign-off the patches on purpose, as I would really like to > > get them reviewed before they go in. Can people have a look and state > > whether the whole idea is at all sane? > > To briefly state the idea as such: the new implementation defines a > model (snd_usb_endpoint) that handles everything that is related to an > USB endpoint and its streaming. There are functions to activate and > deactivate an endpoint (which call usb_set_interface()), and to start > and stop its URBs. It also has function pointers to be called when data > was received or is about to be sent, and pointer to a sync slave > (another snd_usb_endpoint) that is informed when data has been received. > A snd_usb_endpoint knows about its state and implements a refcounting, > so only the first user will actually start the URBs and only the last > one to stop it will tear them down again. > > With this sort of abstraction, the actual streaming is decoupled from > the pcm handling, which makes the "implicit feedback" mechanisms easy to > implement. All the code that actually handles the payload of a stream's > packets is now implemented in pcm.c, which is were it belongs to. > > But I'm sure there are some unresolved corner cases which need attention. The overall design looks good to me. Nice work! A few nitpicking: - No need for check of activated flags at starting streams? - Better to clear subs->data_endpoint & co at closing. - There might be unbalances when deactivate_endpoints() isn't called in prepare callback before activate_endpoints(). The apps may call like open -> hw_params -> prepare -> hw_params -> prepare -> trigger and trigger (stop) -> prepare -> trigger (start) So, be careful about refcounting and active flags. And, yes, the protection for snd_usb_add_endpoint() would be really needed for concurrent access. The card-global mutex would be enough. thanks, Takashi