GNOME Bugzilla – Bug 627263
[pulsesrc] add property to use native format without any conversions
Last modified: 2016-05-22 16:42:21 UTC
Pleas add option to pulsesrc to use same format in source. For example: i have webcam which provide "s16le 1ch 16000Hz" pulsesrc will take "float32le 1ch 44100Hz". In this case pulse will convert it. At end point we have bigger file with 44100Hz even if we used source with 16000Hz and more CPU load. Solution is to use flags when creating the stream: PA_STREAM_FIX_FORMAT, PA_STREAM_FIX_RATE and PA_STREAM_FIX_CHANNELS. here is patch what i used to hard code this flags, it work fine for me: --- gst-plugins-good0.10-0.10.24.3.orig/ext/pulse/pulsesrc.c +++ gst-plugins-good0.10-0.10.24.3/ext/pulse/pulsesrc.c @@ -963,6 +963,8 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc #ifdef HAVE_PULSE_0_9_11 PA_STREAM_ADJUST_LATENCY | #endif + PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | + PA_STREAM_FIX_CHANNELS | PA_STREAM_START_CORKED) < 0) { GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("Failed to connect stream: %s", Take a loot to this discussion: http://comments.gmane.org/gmane.comp.video.gstreamer.devel/30839?set_blog_all=yes
The best would be to not restrict to the native format but to have the native format(s) at the beginning of the caps and all the other formats below.
Is it possible to do with gstreamer maximal rate filtering? For example: i wont to have maximal rate 44100 but i we have source 16000, so we continue without resampling. The output will have 16000 too.
(In reply to comment #2) > Is it possible to do with gstreamer maximal rate filtering? For example: i > wont to have maximal rate 44100 but i we have source 16000, so we continue > without resampling. The output will have 16000 too. You can put a capsfilter with a rate=[1, 44100] range after the source.
PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | PA_STREAM_FIX_CHANNELS is not a good option because these are parameters used for connecting the stream *after* negotiation happens. The result of using these parameters is that the negotiated format is simply ignored and the stream (silently) uses a different format than what the caps say. It's also not very trivial to figure out what format the stream will use natively because of the various modules in pulseaudio that can restore or redirect streams to different devices. In general, to know the native format of a stream, you need to connect the stream with the FIX flags and then see what format you got. This needs to be done before negotiation so that the format can be put first in the caps. Then when the negotiation fixates a format, we might need to reconnect the stream again when the format is different. The reconnection bit is a bit ugly because pulseaudio would quickly see a stream come and go.
What about adding enhancement to pulseaudo,sort of "purpose" flag? For example for music let pulse choice best resampler (if it needed), For voice it will choice cheaper resampler... less quality (sample rate) and less cpu load. Or powersave flag - will choice cheaper resapler too.
Summarising some discussion on IRC, the resampler is a global PulseAudio setting - if you're system is not able to keep up, you should use a lower complexity resampler in your configuration. It'd be nice to be able to pick the best resampler for a system/load in PA, but we're not there yet. The problem of minimising the number of times format/rate conversion happen is orthogonal to this, but would also help decrease system load.
This bug has an assigned developer but has not received activity in almost a year. Is the assigned person still working on this ?