From: Takashi Iwai Subject: Re: [PATCH] compress: add support for gapless playback Date: Wed, 13 Feb 2013 18:15:49 +0100 Message-ID: References: <1360771234-13006-1-git-send-email-vinod.koul@intel.com> <20130213170322.GA7777@intel.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 CB4AC26524F for ; Wed, 13 Feb 2013 18:15:49 +0100 (CET) In-Reply-To: <20130213170322.GA7777@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Vinod Koul Cc: Jeeja KP , alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com, liam.r.girdwood@intel.com List-Id: alsa-devel@alsa-project.org At Wed, 13 Feb 2013 22:33:22 +0530, Vinod Koul wrote: > > On Wed, Feb 13, 2013 at 05:40:11PM +0100, Takashi Iwai wrote: > > At Wed, 13 Feb 2013 08:00:34 -0800, > > Vinod Koul wrote: > > > > > > +static int > > > +snd_compr_get_metadata(struct snd_compr_stream *stream, unsigned long arg) > > > +{ > > > + struct snd_compr_metadata *metadata; > > > + int retval; > > > + > > > + if (!stream->ops->get_metadata) > > > + return -ENXIO; > > > + > > > + metadata = kmalloc(sizeof(*metadata), GFP_KERNEL); > > > > There is no merit to use kmalloc just for two integers at all. > > Simply put on stack: > > struct snd_compr_metadata metdata; > > if (copy_from_user(&metadata, (void __user *)arg, sizeof(metadata))) > > ... > while doing this I had thought on this, but my laziness got better of me :( > > > > Ditto for snd_compr_set_metadata(). > > > > > +static int snd_compr_partial_drain(struct snd_compr_stream *stream) > > > +{ > > > + int retval; > > > + if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || > > > + stream->runtime->state == SNDRV_PCM_STATE_SETUP) > > > + return -EPERM; > > > + /* stream can be drained only when next track has been signalled */ > > > + if (stream->next_track == false) > > > + return -EPERM; > > > + > > > + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); > > > + if (retval) > > > + pr_err("Partial drain returned failure\n"); > > > > I don't think it's good to spew errors. > ok > > > > Also, the initialization of new stream fields is missing in other > > places like prepare callback? Otherwise the values will retain. > The stream is created at open. Since it used kzalloc, these variables would be > init to false. But you can restart the stream after stopping it without closing the device, right? Takashi