alsasrc / audioresample : does not negociate caps properly
I have this webcam (Logitech Brio) which apparently only supports 48000 Hz. I'm confused why the following does not work
# GST_DEBUG=alsa*:7 gst-launch-1.0 alsasrc name=alsasrc0 device=hw:2,0 num-buffers=-1 buffer-time=1000000 ! audioconvert ! audioresample ! "audio/x-raw, format=(string)S16LE, rate=(int)44100, channels=(int)2" ! fakesink -v
0:00:00.014565883 25052 0x55c231208ac0 DEBUG alsa gstalsaplugin.c:78:plugin_init: binding text domain gst-plugins-base-1.0 to locale dir /usr/share/locale
0:00:00.014795041 25052 0x55c231208ac0 DEBUG alsa gstalsasrc.c:271:gst_alsasrc_init:<GstAlsaSrc@0x55c231214200> initializing
0:00:00.015645913 25052 0x55c231208ac0 DEBUG alsa gstalsasrc.c:298:gst_alsasrc_getcaps:<alsasrc0> device not open, using template caps
0:00:00.015705279 25052 0x55c231208ac0 DEBUG alsa gstalsasrc.c:298:gst_alsasrc_getcaps:<alsasrc0> device not open, using template caps
0:00:00.015748207 25052 0x55c231208ac0 DEBUG alsa gstalsasrc.c:298:gst_alsasrc_getcaps:<alsasrc0> device not open, using template caps
0:00:00.015956051 25052 0x55c231208ac0 DEBUG alsa gstalsasrc.c:298:gst_alsasrc_getcaps:<alsasrc0> device not open, using template caps
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
0:00:00.017364905 25052 0x55c23118b4a0 INFO alsa gstalsasrc.c:316:gst_alsasrc_getcaps:<alsasrc0> template caps audio/x-raw, format=(string){ S8, U8, S16LE, S16BE, U16LE, U16BE, S24_32LE, S24_32BE, U24_32LE, U24_32BE, S32LE, S32BE, U32LE, U32BE, S24LE, S24BE, U24LE, U24BE, S20LE, S20BE, U20LE, U20BE, S18LE, S18BE, U18LE, U18BE, F32LE, F32BE, F64LE, F64BE }, layout=(string)interleaved, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]
0:00:00.017433390 25052 0x55c23118b4a0 LOG alsa gstalsa.c:30:gst_alsa_detect_rates:<alsasrc0> probing sample rates ...
0:00:00.017442722 25052 0x55c23118b4a0 DEBUG alsa gstalsa.c:49:gst_alsa_detect_rates:<alsasrc0> Min. rate = 16000 (16000)
0:00:00.017451081 25052 0x55c23118b4a0 DEBUG alsa gstalsa.c:50:gst_alsa_detect_rates:<alsasrc0> Max. rate = 48000 (48000)
0:00:00.017461372 25052 0x55c23118b4a0 LOG alsa gstalsa.c:348:gst_alsa_detect_channels:<alsasrc0> probing channels ...
0:00:00.017469283 25052 0x55c23118b4a0 DEBUG alsa gstalsa.c:392:gst_alsa_detect_channels:<alsasrc0> Min. channels = 2 (2)
0:00:00.017477006 25052 0x55c23118b4a0 DEBUG alsa gstalsa.c:393:gst_alsa_detect_channels:<alsasrc0> Max. channels = 2 (2)
0:00:00.017494336 25052 0x55c23118b4a0 INFO alsa gstalsasrc.c:326:gst_alsasrc_getcaps:<alsasrc0> returning caps audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)[ 16000, 48000 ], channels=(int)2, channel-mask=(bitmask)0x0000000000000003
0:00:00.017740771 25052 0x55c23118b4a0 WARN alsa gstalsasrc.c:469:set_hwparams:<alsasrc0> error: Rate doesn't match (requested 44100Hz, get 0Hz)
0:00:00.017777260 25052 0x55c23118b4a0 WARN alsa gstalsasrc.c:814:gst_alsasrc_prepare:<alsasrc0> error: Setting of hwparams failed: Invalid argument
ERROR: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Could not get/set settings from/on resource.
Additional debug info:
../../../git/ext/alsa/gstalsasrc.c(469): set_hwparams (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0:
Rate doesn't match (requested 44100Hz, get 0Hz)
While this works:
# GST_DEBUG=alsa*:7 gst-launch-1.0 alsasrc name=alsasrc0 device=hw:2,0 num-buffers=-1 buffer-time=1000000 ! audioconvert ! audioresample ! "audio/x-raw, format=(string)S16LE, rate=(int)48000, channels=(int)2" ! fakesink -v
I was expecting the above pipeline to detect that the source only supports 48000 Hz, and that the samplerate conversion would downrate it to 44100.
arecord
seems to detect that the requested rate won't work, and falls back to 48 Khz
# lsusb
Bus 002 Device 003: ID 046d:086b Logitech, Inc.
# arecord -f cd -r 44100 -D hw:0 test.wav -v
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Warning: rate is not accurate (requested = 44100Hz, got = 48000Hz)
please, try the plug plugin
Hardware PCM card 0 'Seneca USB Capture HDMI' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 24000
period_size : 6000
period_time : 125000
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 6000
period_event : 0
start_threshold : 1
stop_threshold : 24000
silence_threshold: 0
silence_size : 0
boundary : 6755399441055744000
appl_ptr : 0
hw_ptr : 0