gstreamer guru needed.

Currently I have a NAS>DLNA/UPNP server.>control point>renderer.
software=(OMV>MoOde>upplay>gmediarender gstreamer 1.0)
hardware=(HP Thin client>RPi3>Ubuntu desktop>another HP Thin client running Ubuntu server with RME HDSPe AIO soundcard)

Playback is working well excepting one small problem...the RME HDSPe AIO has to be set in alsamixer for the hardware rate to match the rate of the file sent and I am lost trying to find a way to have the card (preferably) or file changed to match automatically as different files are played.

Using aplay I can acheive this by putting this in my asoundrc but it doesn't work for gmediarender output.

Code:
pcm.device{
        format S32_LE
        rate 96000
        type hw
        card 0
        device 0
}

pcm.!default{
    type plug
    slave.pcm "device"
}

If I leave the card rate set at 96kHz via ALSA and play a 44.1kHz file I get a gstreamer error..

Code:
ERROR [2022-04-05 12:57:30.360094 | gstreamer] source: Error: Internal data stream error. (Debug: ../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPlayBin:play/GstURIDecodeBin:uridecodebin0/GstSoupHTTPSrc:source:
streaming stopped, reason not-negotiated (-4)

Seems there needs to be some thing in the gstreamer pipeline or a flag to set the card rate..???
 
Hi Pavel,
This is the command I use to start gmediarender and its output. This is the working version where both card rate and file rate match.
Code:
gmediarender --gstout-audiosink=alsasink --gstout-audiodevice=sysdefault
gmediarender 0.0.9 started [ gmediarender 0.0.9_git2021-03-14_4ac7d89 (libupnp-1.8.4; glib-2.66.8; gstreamer-1.18.4) ].
Logging switched off. Enable with --logfile=<filename> (or --logfile=stdout for console)
Ready for rendering.

I asked over at the RME forums about the alsa rate plugin but had no replies. That was the only option I could find that worked. If there is another I would like to try it.

Thanks,
Bob.
 
OK. IIUC the RME card does not switch samplerate automatically in the hdspe driver due to some internal complexities, and the rate must be switched manually via alsa controls.

Therefore you have the card fixed at 96k and want to resample everything to 96k.

Your asoundrc configures the resampling. But I am not sure your locally-defined "default" device is being used as you configure device "sysdefault" with --gstout-audiodevice=sysdefault - see https://github.com/alsa-project/alsa-plugins/blob/master/doc/README-pulse#L45 .

Also gstreamer can resample - see https://gstreamer.freedesktop.org/documentation/audioresample/index.html?gi-language=c . The sink pipeline should be configurable with --gstout-audiopipe https://github.com/hzeller/gmrender-resurrect/blob/master/src/output_gstreamer.c#L387 . You would have to play with the params to get correct format, it's always a bit of fight in gstreamer. Charlie Laub is the gst guru here.

As of switching the rate on demand - vast majority of alsa drivers does that, based on required hw_params by the player app. Your device is quite unusual. I am not aware of any way to configure the pipeline to call an external action at samplerate change. Such feature would be possible to add to gmediarender as it works with the gstreamer internals directly - handling some rate change gstreamer message or something like that. But it's coding in C and learning the quite complex GST API.
 
  • Like
Reactions: DRONE7
Thanks Pavel..🙂
Yes, the card is problematic...(but if it didn't resolve so absolutely amazingly lusciously wonderfully I would have been reinstalling one of my M-Audio cards)
I really want to see if it can be configured but if not...it sounds so damn good that I will just have to manually adjust ALSA for individual files or resample all files to a rate for the card .
Thanks for the links! I will investigate.
Yes I was hoping Charlie might have some insights 🙂 awaiting the sun and moon to cycle and his return...🙂

Thanks again!
Bob.
 
Hi Bob, you can always PM me to get my attention faster. Just saw this now.

So if I am understanding this correctly, the Gstreamer pipeline in GMediaRenderer throws an error when there is a file played that is not at the rate of the alsasink because the sink rate is fixed?

One approach might be to set up a custom alsa plugin that does resampling to the fixed rate that you need for your RME card. You could configure that to forward audio to the alsa loopback device, and then use alsaloop to send it on to the card. Gmediarenderer would send audio to the resampler plugin instead of to the RME card directly. Pavel can chime in on that kind of scheme.

The other possibility is to supply pipeline elements that perform resampling to Gmediarenderer. According to the code that Pavel pointed to, gstout-audiopipe takes a string. It would depend on what the code does with the string you supply it. If it just appends it to the pipeline you could include resampling as part of the string, like this:

gstout-audiopipe = audioresample quality=10 ! audio/x-raw, rate=XXX ! alsasink device=YYY

You might need to enclose the string in single or double quotes. Substitute the desired rate for XXX and the appropriate alsa device name or hw:x,y specification for YYY.
 
Thanks Charlie. I have been wrestling with the Gstreamer audiopipe and resampler but the documentation is rather daunting.
I almost had the configuration correct but not quite having now seen your suggested configuration above.
I will give it a try today.

@phofman
OK. IIUC the RME card does not switch samplerate automatically in the hdspe driver due to some internal complexities, and the rate must be switched manually via alsa controls.
From what I have gleaned from reading the RME forums it appears that their cards only autorate-change if using 32-bit files. I guess that makes some sense for Pro-studio recording devices.
That is with Windows and there is no official Linux support from RME.
Interestingly, using alsmixer while the card is in use and playing a 44.1kHz file the rate can be manually changed one step either way in realtime without any hiccough...up to 48kHz (audio plays faster) or down to 32kHz (audio plays slower)
 
Last edited:
Working !! smoother than butter. Thanks Charlie and Pavel

Code:
gmediarender gstout-audiopipe = audioresample quality=10 ! audio/x-raw, rate=96000 format=S32LE ! alsasink device=sysdefault

Code:
top - 08:50:28 up 24 min,  3 users,  load average: 0.08, 0.04, 0.00
 
Working !! smoother than butter. Thanks Charlie and Pavel

Code:
gmediarender gstout-audiopipe = audioresample quality=10 ! audio/x-raw, rate=96000 format=S32LE ! alsasink device=sysdefault

Code:
top - 08:50:28 up 24 min,  3 users,  load average: 0.08, 0.04, 0.00
I noticed that you missed a comma in the format section after the rate=96000 and before the format=S32LE. The format=S32LE is probably just being ignored here.

Glad it is working for you now.