[alsa-devel] [PATCH TINYCOMPRESS 1/14] compress: Add function to get timestamp in samples
Richard Fitzgerald
rf at opensource.wolfsonmicro.com
Tue Feb 19 18:18:29 CET 2013
>>> The compress_get_hpointer() converts the timestamp into actual
>>> time. But Android needs it in samples. To avoid the inefficiency
>>> of using compress_get_hpointer() and converting into time and then
>>> back into samples, this change adds compress_get_tstamp() which
>>> returns the raw struct snd_compr_tstamp.
>
>the conversion could be handled in tinycompress (user-space)
>rather than adding a new kernel ioctl that everyone will need to implement.
This isn't adding a new ioctl. It's adding a tinycompress function to give
the client a way of calling the existing SNDRV_COMPRESS_TSTAMP ioctl, which
gets the position in samples.
>Loss of efficiency? It's not that bad really
It's silly to get something in the required format, convert it to the
wrong format, then convert it back again, when it's trivial to just
return it in the correct format. And all unnecessary code wastes a little
battery power - if you call it often the waste starts to become measurable.
It's worse if the divide is done in software. Not all ARM processors have
hardware divide so the three divides in compress_get_hpointer are not
necessarily trivial (especially if you're building a low-power embedded
device using a simpler ARM instead of the latest high-end ARM.)
Divide is the most difficult math operation to do in hardware, so any
good programmer that cares about efficiency/speed/power consumption on
embedded platforms should be suspicious of code that needs a divide.
More information about the Alsa-devel
mailing list