GNOME Bugzilla – Bug 770446
pulsesrc, audiosrc: No audio captured with new GStreamer 1.8.2
Last modified: 2016-09-30 07:04:20 UTC
Hi, I developed an ALSA audio driver capture cards and one of my clients recently reported that he cannot capture audio from our cards with gst-launch-1.0 (1.8.2) through pulsesrc. I checked that the capture works with GStreamer 1.4.5 and the same pipeline does not capture any audio with GStreamer 1.8.2 through pulsesrc. The pipeline is started but OK but no audio is captured. With alsasrc the new GStreamer works fine. Can you help me debug further? See details below: 1) Test pipeline: GST_DEBUG=5 gst-launch-1.0 pulsesrc device=alsa_input.pci-0000_04_00.0.analog-stereo.2 ! audio/x-raw,rate=48000,channels=2 ! pulsesink With GStreamer 1.8.2 (NOT WORKING), I get (here are only the print outs which I think are informative regarding this issue): 0:00:00.119632364 [333m 7640[00m 0x221f2d0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1740:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m pointer at 0, sample 0, read from 0-0, to_read 8916, diff 0, segtotal 1, segsize 35664 0:00:00.218069018 [333m 7640[00m 0x221f2d0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1740:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m pointer at 1, sample 0, read from 0-0, to_read 8916, diff 1, segtotal 1, segsize 35664 0:00:00.218125746 [333m 7640[00m 0x221f2d0 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1793:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m Retrieved timestamp 99:99:99.999999999 @ 0 0:00:00.219848465 [333m 7640[00m 0x221f2d0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1740:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m pointer at 1, sample 8916, read from 1-0, to_read 8916, diff 0, segtotal 1, segsize 35664 0:00:00.409910841 [333m 7640[00m 0x221f2d0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1740:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m pointer at 2, sample 8916, read from 1-0, to_read 8916, diff 1, segtotal 1, segsize 35664 0:00:00.409933577 [333m 7640[00m 0x221f2d0 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1793:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m Retrieved timestamp 99:99:99.999999999 @ 0 0:00:00.410155046 [333m 7640[00m 0x221f2d0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1740:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m pointer at 2, sample 17832, read from 2-0, to_read 8916, diff 0, segtotal 1, segsize 35664 0:00:00.601957772 [333m 7640[00m 0x2232320 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1998:gst_audio_ring_buffer_set_timestamp:<audiosrcringbuffer0>[00m Storing timestamp 99:99:99.999999999 @ 0 0:00:00.602058514 [333m 7640[00m 0x221f2d0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1740:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m pointer at 3, sample 17832, read from 2-0, to_read 8916, diff 1, segtotal 1, segsize 35664 0:00:00.602104019 [333m 7640[00m 0x221f2d0 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1793:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m Retrieved timestamp 99:99:99.999999999 @ 0 0:00:00.602336343 [333m 7640[00m 0x221f2d0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1740:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m pointer at 3, sample 26748, read from 3-0, to_read 8916, diff 0, segtotal 1, segsize 35664 As opposed to the WORKING case with GStreamer 1.4.5 - see below: 0:00:00.196115963 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1732:gst_audio_ring_buffer_read:[00m pointer at 0, sample 0, read from 0-0, to_read 8916, diff 0, segtotal 117, segsize 35664 0:00:00.231167577 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1732:gst_audio_ring_buffer_read:[00m pointer at 1, sample 0, read from 0-0, to_read 8916, diff 1, segtotal 117, segsize 35664 0:00:00.231205810 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1757:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m read @0x7fd85c4a2010 seg 0, off 0, sampleslen 8916 0:00:00.231243195 [331m 2142[00m 0x228a9e0 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1785:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m Retrieved timestamp 99:99:99.999999999 @ 0 0:00:00.412533010 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1732:gst_audio_ring_buffer_read:[00m pointer at 1, sample 8916, read from 1-0, to_read 8916, diff 0, segtotal 117, segsize 35664 0:00:00.422950687 [331m 2142[00m 0x7fd840002450 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1990:gst_audio_ring_buffer_set_timestamp:<audiosrcringbuffer0>[00m Storing timestamp 99:99:99.999999999 @ 1 0:00:00.423026720 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1732:gst_audio_ring_buffer_read:[00m pointer at 2, sample 8916, read from 1-0, to_read 8916, diff 1, segtotal 117, segsize 35664 0:00:00.423067387 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1757:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m read @0x7fd85c4aab60 seg 1, off 0, sampleslen 8916 0:00:00.423084599 [331m 2142[00m 0x228a9e0 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1785:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m Retrieved timestamp 99:99:99.999999999 @ 1 0:00:00.626431503 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1732:gst_audio_ring_buffer_read:[00m pointer at 3, sample 17832, read from 2-0, to_read 8916, diff 1, segtotal 117, segsize 35664 0:00:00.626443248 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1757:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m read @0x7fd85c4b36b0 seg 2, off 0, sampleslen 8916 0:00:00.626461789 [331m 2142[00m 0x228a9e0 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1785:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m Retrieved timestamp 99:99:99.999999999 @ 2 0:00:00.840073004 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1732:gst_audio_ring_buffer_read:[00m pointer at 4, sample 26748, read from 3-0, to_read 8916, diff 1, segtotal 117, segsize 35664 0:00:00.840091054 [331m 2142[00m 0x228a9e0 [37mDEBUG [00m [00m ringbuffer gstaudioringbuffer.c:1757:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m read @0x7fd85c4bc200 seg 3, off 0, sampleslen 8916 0:00:00.840118188 [331m 2142[00m 0x228a9e0 [36mINFO [00m [00m ringbuffer gstaudioringbuffer.c:1785:gst_audio_ring_buffer_read:<audiosrcringbuffer0>[00m Retrieved timestamp 99:99:99.999999999 @ 3 I think the above print outs show that data is actually never read for the NOT WORKING case (I never see read @0x7fd85c4a2010 ...). Does it get stuck in the loop in gst_audio_ring_buffer_read()? What do you think: what can be the reason for this failure with the new GStreamer? Mayby there is something I need to change in my driver? Let me know if you need more information or want me to do more tests. Thanks, Przemek Gajos
Can you take a look at verbose logs on the PulseAudio server in both cases when you try to do a capture. The only change in pulsesrc between those two releases is: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/ext/pulse/pulsesrc.c?id=8e236fa2e1a5873b664401342a026a943d482bfe
(In reply to Arun Raghavan from comment #1) > Can you take a look at verbose logs on the PulseAudio server in both cases > when you try to do a capture. The only change in pulsesrc between those two > releases is: > > > https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/ext/pulse/ > pulsesrc.c?id=8e236fa2e1a5873b664401342a026a943d482bfe Hello, Here are verbose logs (max verbosity level: 4) from pulseaudio server: capture command: gst-launch-0.10 pulsesrc device=alsa_input.pci-0000_04_00.0.analog-stereo.2 ! audio/x-raw-int,channels=2,rate=48000 ! fakesink (I already checked that the problem occurs in the capture path so no need for sink here). WORKING CASE - GStreamer 1.4.5, pulseaudio 1:6.0: I: [pulseaudio] client.c: Created 6 "Native client (UNIX socket client)" D: [pulseaudio] protocol-native.c: Protocol version: remote 30, local 30 I: [pulseaudio] protocol-native.c: Got credentials: uid=1000 gid=1000 success=1 D: [pulseaudio] protocol-native.c: SHM possible: yes D: [pulseaudio] protocol-native.c: Negotiated SHM: yes D: [pulseaudio] protocol-native.c: Disabling srbchannel, reason: Must be enabled by module parameter D: [pulseaudio] module-augment-properties.c: Looking for .desktop file for gst-launch-1.0 D: [pulseaudio] module-stream-restore.c: Not restoring device for stream source-output-by-application-name:gst-launch-1.0, because already set D: [pulseaudio] module-intended-roles.c: Not setting device for stream Record Stream, because already set. D: [pulseaudio] source-output.c: Negotiated format: pcm, format.sample_format = "\"s16le\"" format.rate = "48000" format.channels = "2" format.channel_map = "\"front-left,front-right\"" D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes busy, resuming. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes idle, timeout in 5 seconds. D: [pulseaudio] memblockq.c: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0 D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0 I: [pulseaudio] source-output.c: Created output 2 "Record Stream" on alsa_input.pci-0000_04_00.0.analog-stereo.2 with sample spec s16le 2ch 48000Hz and channel map front-left,front-right I: [pulseaudio] source-output.c: media.name = "Record Stream" I: [pulseaudio] source-output.c: application.name = "gst-launch-1.0" I: [pulseaudio] source-output.c: native-protocol.peer = "UNIX socket client" I: [pulseaudio] source-output.c: native-protocol.version = "30" I: [pulseaudio] source-output.c: application.process.id = "2624" I: [pulseaudio] source-output.c: application.process.user = "przemek" I: [pulseaudio] source-output.c: application.process.host = "przemek-ubuntu-15" I: [pulseaudio] source-output.c: application.process.binary = "gst-launch-1.0" I: [pulseaudio] source-output.c: application.language = "en_GB.UTF-8" I: [pulseaudio] source-output.c: window.x11.display = ":0" I: [pulseaudio] source-output.c: application.process.machine_id = "c4a193064ce1428a95aae542a1e1e689" I: [pulseaudio] source-output.c: application.process.session_id = "c1" I: [pulseaudio] source-output.c: module-stream-restore.id = "source-output-by-application-name:gst-launch-1.0" D: [pulseaudio] memblockq.c: memblockq requested: maxlength=4194304, tlength=0, base=4, prebuf=1, minreq=0 maxrewind=0 D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=4194304, tlength=4194304, base=4, prebuf=4, minreq=4 maxrewind=0 I: [pulseaudio] protocol-native.c: Final latency 371.51 ms = 185.75 ms + 185.76 ms D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes busy, resuming. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes idle, timeout in 5 seconds. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes idle, timeout in 5 seconds. D: [pulseaudio] core.c: Hmm, no streams around, trying to vacuum. I: [pulseaudio] source-output.c: Freeing output 2 "Record Stream" I: [pulseaudio] client.c: Freed 6 "gst-launch-1.0" I: [pulseaudio] protocol-native.c: Connection died. NON-WORKING CASE - GStreamer 1.8.2, pulseaudio 1:8.0: I: [pulseaudio] client.c: Created 9 "Native client (UNIX socket client)" D: [pulseaudio] protocol-native.c: Protocol version: remote 30, local 30 I: [pulseaudio] protocol-native.c: Got credentials: uid=1000 gid=1000 success=1 D: [pulseaudio] protocol-native.c: SHM possible: yes D: [pulseaudio] protocol-native.c: Negotiated SHM: yes D: [pulseaudio] srbchannel.c: SHM block is 65472 bytes, ringbuffer capacity is 2 * 32712 bytes D: [pulseaudio] protocol-native.c: Enabling srbchannel... D: [pulseaudio] module-augment-properties.c: Looking for .desktop file for gst-launch-1.0 D: [pulseaudio] protocol-native.c: Client enabled srbchannel. D: [pulseaudio] module-stream-restore.c: Not restoring device for stream source-output-by-application-name:gst-launch-1.0, because already set D: [pulseaudio] module-intended-roles.c: Not setting device for stream Record Stream, because already set. D: [pulseaudio] source-output.c: Negotiated format: pcm, format.sample_format = "\"s16le\"" format.rate = "48000" format.channels = "2" format.channel_map = "\"front-left,front-right\"" I: [pulseaudio] module-stream-restore.c: Restoring volume for source output source-output-by-application-name:gst-launch-1.0. I: [pulseaudio] module-stream-restore.c: Restoring mute state for source output source-output-by-application-name:gst-launch-1.0. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes busy, resuming. D: [pulseaudio] source.c: Suspend cause of source alsa_input.pci-0000_04_00.0.analog-stereo.2 is 0x0000, resuming D: [pulseaudio] reserve-wrap.c: Successfully acquired reservation lock on device 'Audio1' I: [alsa-source-Audio Capture] alsa-source.c: Trying resume... D: [alsa-source-Audio Capture] alsa-util.c: Maximum hw buffer size is 170 ms D: [alsa-source-Audio Capture] alsa-util.c: Set buffer size first (to 8192 samples), period size second (to 4096 samples). D: [alsa-source-Audio Capture] alsa-source.c: hwbuf_unused=0 D: [alsa-source-Audio Capture] alsa-source.c: setting avail_min=1 I: [alsa-source-Audio Capture] alsa-source.c: Resumed successfully... I: [alsa-source-Audio Capture] alsa-source.c: Starting capture. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes idle, timeout in 5 seconds. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes idle, timeout in 5 seconds. D: [pulseaudio] memblockq.c: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0 D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0 I: [pulseaudio] source-output.c: Created output 2 "Record Stream" on alsa_input.pci-0000_04_00.0.analog-stereo.2 with sample spec s16le 2ch 48000Hz and channel map front-left,front-right I: [pulseaudio] source-output.c: media.name = "Record Stream" I: [pulseaudio] source-output.c: application.name = "gst-launch-1.0" I: [pulseaudio] source-output.c: native-protocol.peer = "UNIX socket client" I: [pulseaudio] source-output.c: native-protocol.version = "30" I: [pulseaudio] source-output.c: application.process.id = "4135" I: [pulseaudio] source-output.c: application.process.user = "przemek" I: [pulseaudio] source-output.c: application.process.host = "ubuntu-16" I: [pulseaudio] source-output.c: application.process.binary = "gst-launch-1.0" I: [pulseaudio] source-output.c: application.language = "en_GB.UTF-8" I: [pulseaudio] source-output.c: window.x11.display = ":0" I: [pulseaudio] source-output.c: application.process.machine_id = "9dc27c52943046aa829eaaa82da2041b" I: [pulseaudio] source-output.c: application.process.session_id = "c2" I: [pulseaudio] source-output.c: module-stream-restore.id = "source-output-by-application-name:gst-launch-1.0" D: [pulseaudio] memblockq.c: memblockq requested: maxlength=38400, tlength=0, base=4, prebuf=1, minreq=0 maxrewind=0 D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=38400, tlength=38400, base=4, prebuf=4, minreq=4 maxrewind=0 I: [pulseaudio] protocol-native.c: Final latency 371.51 ms = 185.75 ms + 185.76 ms D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes busy, resuming. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes idle, timeout in 5 seconds. D: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 becomes idle, timeout in 5 seconds. D: [pulseaudio] core.c: Hmm, no streams around, trying to vacuum. I: [pulseaudio] source-output.c: Freeing output 2 "Record Stream" I: [pulseaudio] client.c: Freed 9 "gst-launch-1.0" I: [pulseaudio] protocol-native.c: Connection died. I: [pulseaudio] module-suspend-on-idle.c: Source alsa_input.pci-0000_04_00.0.analog-stereo.2 idle for too long, suspending ... D: [pulseaudio] source.c: Suspend cause of source alsa_input.pci-0000_04_00.0.analog-stereo.2 is 0x0004, suspending I: [alsa-source-Audio Capture] alsa-source.c: Device suspended... D: [pulseaudio] core.c: Hmm, no streams around, trying to vacuum. D: [pulseaudio] module-udev-detect.c: /dev/snd/controlC1 is accessible: yes D: [pulseaudio] module-udev-detect.c: Resuming all sinks and sources of card alsa_card.pci-0000_04_00.0. Can you see anything suspicious in the above logs for the non-working case? I noticed difference in size (buffer?) in memblockq.c... Thanks, Przemek
I think the best way to proceed is to try to eliminate GStreamer from the mix. Try using the buffer_attr parameters that pulsesrc uses (GST_DEBUG=pulse*:5 in your pipeline will give you the values). You can then directly use those in a PA application (or modify parec in the PA sources), and set the attrs accordingly. Mainly check if specifying maxlength to some value vs. setting it to -1 changes behaviour in the same way that you see here.
(In reply to Arun Raghavan from comment #3) > I think the best way to proceed is to try to eliminate GStreamer from the > mix. Try using the buffer_attr parameters that pulsesrc uses > (GST_DEBUG=pulse*:5 in your pipeline will give you the values). > > You can then directly use those in a PA application (or modify parec in the > PA sources), and set the attrs accordingly. Mainly check if specifying > maxlength to some value vs. setting it to -1 changes behaviour in the same > way that you see here. Hi Arun, Thank you for helping with this. I tested the capture through PULSEAUDIO with both the app which comes with ALSA and the PULSEAUDIO app not involving GStreamer. These 2 both work OK: $ parec --device=alsa_input.pci-0000_04_00.0.analog-stereo.2 --format=s16le --rate=48000 --channels=2 | parec -p $ PULSE_SOURCE=alsa_input.pci-0000_04_00.0.analog-stereo.2 arecord --format=S16_LE --rate=48000 --channels=2 | aplay -D hw:2,0 I will now try tweaking the parameters as you suggested. Best regards, Przemek
Hi, I tested pacat (PA record and playback app) compiled from source with buffer attributes tweaked as you suggested. These values are from my NON-WORKING case with GStreamer above: 1) Set maxlength=33554432 From pacat logs record path: maxlength=4194304, fragsize=384000 (the same as when maxlength=-1) => audio capture working fine 2) Set maxlength=38400 From pacat logs record path: maxlength=38400, fragsize=38400 => audio capture working fine What could I check next? Thx, Przemek
Hello Arun, I did another test with GStreamer 1.8.2 and I was able to make the capture work by modifying pulsesrc.c in gst-plugins-good to revert this change: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/ext/pulse/pulsesrc.c?id=8e236fa2e1a5873b664401342a026a943d482bfe I used such tweaked & built libgstpulse.so and the capture works fine with new GStreamer. Tomorrow I will to debug further which bit in this change: pulsesrc: Fix mapping of latency parameters to buffer attributes is making my captures work / not work but later I would appreciate help in understanding why it is not working with the change in. Thanks, Przemek
Hello Arun, Investigating further, I found that if I revert this single change pulsesrc.c my captures work again: - wanted.maxlength = -1; + wanted.maxlength = spec->segsize * spec->segtotal; The change appeared in this changelog as you know: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/ext/pulse/pulsesrc.c?id=8e236fa2e1a5873b664401342a026a943d482bfe From the logs I can see that the above change (wanted.maxlength = ...) affects buffer size, am I right? Look at values for maxlength: NOT-WORKING case (wanted.maxlength = spec->segsize * spec->segtotal): 0:00:00.129593794 11833 0x1ab3b20 ERROR pulse pulsesrc.c:1533:gst_pulsesrc_prepare:<pulsesrc0> spec->segsize(1920) * spec->segtotal(20) = (38400) 0:00:00.132835948 11833 0x1ab3b20 ERROR pulse pulsesrc.c:1591:gst_pulsesrc_prepare:<pulsesrc0> maxlength: 38400 ... 0:00:00.132925502 11833 0x1ab3b20 ERROR pulse pulsesrc.c:1598:gst_pulsesrc_prepare:<pulsesrc0> fragsize: 35664 (wanted 1920) WORKING case (wanted.maxlength = -1): 0:00:00.144276433 9290 0xee9320 ERROR pulse pulsesrc.c:1533:gst_pulsesrc_prepare:<pulsesrc0> spec->segsize(1920) * spec->segtotal(20) = (38400) 0:00:00.146496320 9290 0xee9320 ERROR pulse pulsesrc.c:1591:gst_pulsesrc_prepare:<pulsesrc0> maxlength: 4194304 ... 0:00:00.146629552 9290 0xee9320 ERROR pulse pulsesrc.c:1598:gst_pulsesrc_prepare:<pulsesrc0> fragsize: 35664 (wanted 1920) It looks like in the non-working case fragsize (35664 ) is almost the size of the buffer (38400) while in the working case buffer size is not limited (-1) and hence ends up much bigger. What do you think about that? Also, my understanding of pulseaudio / GStreamer nomenclature is limited but I know about ALSA. In ALSA buffer is split into periods and each period is a chunk of data to read / write at once. What is the equivalent of ALSA's period here: fragsize or segsize? Thanks, Przemek
Hello, I have further debugged this issue and now I know better why audio stopped working with our capture cards since this change: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/ext/pulse/pulsesrc.c?id=8e236fa2e1a5873b664401342a026a943d482bfe I think the above change in gst-plugins-good introduced a limitation which may break audio capture not only for our cards but with any hardware. See the explanation below (apologies for shortcuts taken and please correct me where I may be wrong - this was my first delve into GStreamer sources). For my case, this happens when audio is started: 1) Initially, default buffer_time is used for pulsesrc: 200000 usec = 200 msec. With 48000 samples/sec, 2 bytes/sample, 2 channels we have 192000 bytes/sec. Taking above into account, 200 msec translates into buffer size of 38400 bytes as initial spec. 2) Source is created (note that "hardware" (kernel) buffer in our audio driver is fixed to 32768 bytes): Our hardware buffer's size 32768 bytes is retrieved from ALSA and used to set latency by Pulseaudio: pa_alsa_source_new -> pa_source_set_fixed_latency(32768) PulseAudio default rate is 44100 which with 2 channels, 2 bytes per sample makes it 185.758 msec. 3) Taking a shortcut now: 185.758 msec is used to set buffer_attr.fragsize 185.758 msec is translated back into bytes, this time rate 48000 is used as requested by GStreamer so there is a mismatch between initial Pulse's 44100 and Gstreamer's 48000 in this calculation but it is not that relevant to the problem we are experiencing (or in other words, the mismatch is not the cause of the problem). Continuing, 185.758 msec (48000 Hz, 4 bytes per frame) is translated into 35664 bytes and this is set as: s->buffer_attr.fragsize = 35664; 4) gst_audio_src_ring_buffer_acquire calls gst_pulsesrc_prepare and because: actual->fragsize(35664) > spec->segsize(1920) segment size is set as: spec->segsize = actual->fragsize(35664) So in GStreamer we end up with: buffer of size 38400 segment of size 35664 And gst_audio_ring_buffer_read fails to read in such configuration! (If we look into gst_audio_ring_buffer_read, we can see that it cannot work with only 1 segment within the buffer! It needs at least 2) To sum up, it looks that the way it works is that when source is created, PulseAudio retrieves hardware buffer size from ALSA (in my example: 35664) and uses it to set to fragsize. Then GStreamer uses that fragsize(35664) as segment size. Now, why the capture does not work? Because gst_audio_ring_buffer_read needs >= 2 segments within a buffer to work properly. I noticed that capture works if I revert this change in gst_pulsesrc_prepare: wanted.maxlength = spec->segsize * spec->segtotal; to: wanted.maxlength = -1; Note that with new GStreamer my buffer size is 38400 (it is limited in gst_pulsesrc_prepare to wanted.maxlength = spec->segsize(1920) * spec->segtotal(20) = 38400). If I use wanted.maxlength = -1 in gst_pulsesrc_prepare, I end up with much bigger buffer which consists of many segments of size 35664 and then reading audio with gst_audio_ring_buffer_read works fine. Therefore I think in new GStreamer in gst_pulsesrc_prepare: wanted.maxlength = spec->segsize * spec->segtotal; limits the size of the buffer to some value (by default it is the equivalent of 200 ms). Because segment size is always set to the hardware_buffer size as retrieved from ALSA by PulseAudio: if the segment size (~ hardware buffer on the card) is big enough so that the GStreamer buffer only accommodates 1 such segment, audio capture gets broken which happens in my case. But I think it can happen for any hardware with a reasonably big audio buffer. Could you do something to not limit the size of the buffer to the initial spec but instead make it choose something reasonable based on the segment size (hardware buf size) got from ALSA. I think it was working in such way before this change: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/ext/pulse/pulsesrc.c?id=8e236fa2e1a5873b664401342a026a943d482bfe Or is there any other solution? I need the audio capture to be working for our audio buffer of size 32768 with default gst-launch-1.0 pipelines. I am looking forward for a fix for this as at the moment audio capture from our cards is broken for one of our customers. Thanks for your help, Przemek
Created attachment 335093 [details] [review] pulsesrc: Don't negotiate to less than two segments GstAudioRingBuffer doesn't needs us to have at least 2 segments. We make sure that if our buffer parameters are such that the maxlength is not at least 2x fragsize, we still request the ringbuffer to keep that much space so it continues to work.
Could you see if the attached patch fixes things for you?
Hi Arun, Thank you - yes, the patch fixes the issue and I am now able to capture audio again. Can you write what the process of applying it will be now? I mean, how would my customer be able to use that change? Thanks, Przemek
Might be nice to get this in for the 1.10 release, and then this will filter through to people via releases.
*via distributions.
Ok thanks, Would you know when it will be released roughly?
I believe we're looking at a September release.