Alexander E. Patrakov
2014-Nov-19 16:20 UTC
[Speex-dev] Feature request: rewindable resampler
Hello. As you probably know, PulseAudio uses the resampler from libspeexdsp by default. As a PulseAudio contributor, I have a feature request. As you can see from old publications [1,2] by Lennart Poettering, PulseAudio has a "timer-based scheduling" feature which is now active by default. PulseAudio attempts to use as high latency as possible (sometimes up to 2 seconds) in order to save power and reduce the chance of dropouts. However, in order to stay responsive to events such as software-volume changes or a new stream appearing, PulseAudio relies on the ability to rewind over already-buffered but not-yet-played sound data and replace them with a new version. Also I must say that PulseAudio client API includes rewinds - i.e. any client can say "please forget N samples that I wrote before, here is an updated version". Unfortunately, we cannot pass such rewind requests through a resampler, simply because no open-source resampler library has an API to do this. I.e. there is no way to forget N last input samples, replace them, and figure out which output samples should be replaced with what. Currently, in this situation, we just reset the resampler, which is wrong. Also there are situations where it ends up wanting to reask for N last output samples corresponding to a modified input where the input modification can be produced on-demand and logically extends to negative infinity in time. Usually, this happens when software-volume is applied before the resampler and a volume-change event occurs. The same kind of bug then happens: we cannot do anything better than resetting the resampler. End result: users complain, see e.g. [3]. Could you please consider designing and implementing new speexdsp API functions that would allow PulseAudio to get rid of these bugs? In fact, because this request is, in my opinion, specific to PulseAudio and ALSA (in ALSA - because of the need to implement snd_pcm_rewind() for the rate plugin), I considered writing a new resampler from scratch with this feature. However, I will almost certainly not start within the next 3 months due to my dayjob and because of other TODO items, and David Henningsson has hinted me to talk to you as an upstream of speex, because, in his opinion, this "rewind" feature might be useful for other applications. Hence this email :) [1] http://0pointer.de/blog/projects/pulse-glitch-free.html [2] http://lac.linuxaudio.org/2010/download/lennarts-talk-auf-der-lac-2010.pdf [3] https://bugs.freedesktop.org/show_bug.cgi?id=50113 -- Alexander E. Patrakov