After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 627263 - [pulsesrc] add property to use native format without any conversions
[pulsesrc] add property to use native format without any conversions
Status: RESOLVED WONTFIX
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
unspecified
Other Linux
: Normal enhancement
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 564957
 
 
Reported: 2010-08-18 14:00 UTC by Oleksij Rempel
Modified: 2016-05-22 16:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Oleksij Rempel 2010-08-18 14:00:23 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
Comment 1 Sebastian Dröge (slomo) 2010-08-18 14:15:30 UTC
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.
Comment 2 Oleksij Rempel 2010-08-18 16:53:24 UTC
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.
Comment 3 Wim Taymans 2010-08-18 16:58:02 UTC
(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.
Comment 4 Wim Taymans 2010-08-19 09:06:18 UTC
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.
Comment 5 Oleksij Rempel 2010-09-03 09:09:01 UTC
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.
Comment 6 Arun Raghavan 2011-04-19 07:05:26 UTC
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.
Comment 7 Edward Hervey 2013-08-13 18:44:54 UTC
This bug has an assigned developer but has not received activity in almost a year.

Is the assigned person still working on this ?