[alsa-devel] [PATCH 5/6] compress: add the core file

Nallasellan, Singaravelan singaravelan.nallasellan at intel.com
Sun Dec 4 09:14:14 CET 2011


> > > +	stream->ops->pointer(stream, tstamp);
> > How to ensure that the caller always checks for NULL pointer?
> Not required, ops will be valid and pointer is mandatory callback

So any buggy driver can cause oops in the compressed core?

> >
> > > +static ssize_t snd_compr_write(struct file *f, const char __user
> > *buf,
> > > +		size_t count, loff_t *offset)
> > > +{
> > > +
> > > +	/* while initiating the stream, write should be called before
> > START
> > > +	 * call, so in setup move state */
> > > +	if (stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
> > > +		stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
> > Can we implement kind of start threshold similar to PCM path here to
> > initiate the playback?
> You already know how much is copied into buffer
You expect the user space to explicitly invoke START. Is it right?
If threshold is implemented, the user space does not require to track the
bytes_written/read.
> >
> > > +		pr_debug("stream prepared, Houston we are good to go\n");
> > > +	}
> > > +
> > > +	mutex_unlock(&stream->device->lock);
> > > +	return retval;
> > > +}
> >
> > > +static int snd_compr_start(struct snd_compr_stream *stream) {
> > > +	int retval;
> > > +
> > > +	if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED)
> > > +		return -EPERM;
> > > +	retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START);
> > > +	stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
> > Set to running state if start is successful.
> read the archives please
Sure, it will not harm if you respond to this. 
> 
> > > +static long snd_compr_ioctl(struct file *f, unsigned int cmd,
> > unsigned
> > > +long arg) {
> > > +	struct snd_compr_file *data = f->private_data;
> > > +	struct snd_compr_stream *stream;
> > > +	int retval = -ENOTTY;
> > > +
> > > +	BUG_ON(!data);
> > > +	stream = &data->stream;
> > > +	BUG_ON(!stream);
> > > +	mutex_lock(&stream->device->lock);
> > Simple structure with ioctl functions will reduce lots of code.
> > It is not anyway doing any specific processing for each ioctl.
> Code readability improves
Not sure other way does not help readability. Try to make it simple.


More information about the Alsa-devel mailing list