Page 1 of 1

Remote Sound with sndiod

Posted: Fri Dec 18, 2020 4:22 pm
by user1111

In respect of this thread viewtopic.php?f=60&t=1484 I've moved my posting over to here, as a more general thread about remote sound options/usability. The following is the original posting, that I've moved over to here ...

====

To clarify

unless sndio comes with "alsa compatibility package"

when sndiod is compiled/running on 'slim' running Fatdog ...
sndiod -dddd -a on -f rsnd/1 -L-
sound sourced from 'Fat' running OpenBSD ...
AUDIODEVICE=snd@slim/0 firefox
then Fat's audio plays fine on Slim

It's when I try to use Fatdog as 'Fat' i.e. source the sound to slim - that no sound is heard on slim. So I don't think its a lack of a alsa-compatibility-package as that's the thin end (just pumping sound out to a port), whilst the 'server' end ('slim' audio reading from a port and outputting via alsa) clearly is working OK when sourced from a OpenBSD system.

That aside, sndiod is much more basic than pulseaudio. There's a interesting post here about using pulseaudio to forward sound to a phone

====

That was in regard to using sndiod as the means to forward sound. sndiod isn't in the Fatdog repo (gslapt) but is relatively easily compiled https://sndio.org/

I'm running Fatdog on my laptop (client), that wifi net connects, and where I use x0vncserver on a desktop PC (server) that is running OpenBSD, has the main TV as its monitor, and is hard wired (ethernet). vnc'ing into that server from my laptop I can run firefox-esr ... with that displayed on the laptop and where the sound is also forwarded to the laptops headphones/speakers.

Basic steps for setting up a session involve :
On fatdog (laptop) set sndiod running to (network) listen for sound using my sound card 1
sndiod -d -a on -f rsnd/1 -L- 2>/dev/null

ssh from laptop into the desktop (openbsd) as user spot and in that ssh session I su to root and run X :1 & to create a X session, whilst in root I also max out the sound level and apply the boost
mixerctl outputs.master=255,255
mixerctl outputs.hp_boost=on

exit root and run
DISPLAY=:0 cwm &
i.e. I use cwm window manager in OpenBSD, that is available as part of the base system, could equally be jwm, but that would have to be installed (pkg_add jwm)

I then kick off x0vncserver (note that is a zero), where a password had already been pre-created by running vncpasswd

DISPLAY=:0 x0vncserver -PasswordFile /home/spot/.vnc/passwd -rfbport 5959 -display :0 &

Finally I set firefox esr running where the sound is forwarded to my laptop's IP (192.168.1.5)

DISPLAY=:0 AUDIODEVICE=snd@192.168.1.5/0 firefox-esr &

With that done the server is ready, so I exit the ssh (and terminal), open tigervnc viewer and open up the servers IP, and as per above port 5959 and up pops the vnc session and where any sounds in firefox are played out of my laptops headphones.

I find x0vncserver to be significantly superior to x11vnc, and even when at the other end of the house to where the wifi router is youtube playbacks/sound is still fine.

I did also try a similar setup but where fatdog was both the client and server, but as per the top/first part of this posting hit problems with that.

Clarity has also mentioned XRDP viewtopic.php?p=12480#p12480 and RDP alternatives. So the intent is that this thread can be used as a more general thread for such discussions/findings. Fundamentally they're all much the same thing, screen display and sound on one device being forwarded to another device. Many of the choices involve having to have pulseaudio installed, this posting outlines one alternative to that i.e. where alsa is still the back-end and where sndiod is used as the sound server for that. Step's thread viewtopic.php?p=10980#p10980 is specifically with regard to testing a pulseaudio setup under Fatdog.


Re: Remote Sound

Posted: Fri Dec 18, 2020 4:28 pm
by user1111

Here's a even earlier posting in Step's thread that I've moved over to here

====

Sorry, diverging some, but for reference ....

step wrote: Thu Dec 10, 2020 8:12 pm

There are ways to transfer sound over LAN with ALSA alone, but I never bothered to learn.

Using sndio/sndiod, basically involves creating a sndiod userid and compiling the sndio package

Code: Select all

mkdir /var/run/sndiod
useradd -r -g audio -s /sbin/nologin -d /var/run/sndiod sndiod
make && make install
ldconfig

https://sndio.org/install.html

https://sndio.org/

For me, with a couple of sound cards, on my Fatdog laptop with that sndio built/installed I run

sndiod -dddd -a on -f rsnd/1 -L-

the rsnd/1 indicates the second sound card being used, for others it may be rsnd/0. The -L- just sets it to listen locally.

On my server, OpenBSD, as user spot (user1/whatever) ...

AUDIODEVICE=snd@192.168.1.5/0 firefox-esr

i.e. where 192.168.1.5 is the IP of my laptop where sound is to be played.

Or

cat /dev/urandom >noisefile ... to dump a load of white noise to a file, ctrl-C break out of that after a second or two ...

AUDIODEVICE=snd@192.168.1.5/0 aucat -i noisefile

and that should result in a load of white noise sound being played on the laptop.

sndio acts as the sound server in this case, with alsa as the backend.

PS wont work as above with OpenBSD chromium ... due to being pledged/unveiled (security measures). Don't know the workaround for that.

EDIT : Nearly works when Fatdog is both the client and server. Creating a noise file and
AUDIODEVICE=snd@192.168.1.5/0 aucat -i noisefile
... has the sound forwarded. Seamonkey, vlc however started with AUDIODEVICE=.... set ... doesn't work. I tried adding that in run-as-spot ...etc. but no joy. Thinking that perhaps something like pcm.!default ... in .asoundrc needs to be set to point sound to sndio rather than alsa ???


Why Remote ?

Posted: Fri Dec 18, 2020 5:08 pm
by user1111

Personally for me using a home setup with a server connected to the main TV, that I can vnc into, means that TV display can be controlled from various devices, even low spec ones. I can also simultaneously vnc in to have many share the same desktop session, or they can individually have their own session. Nice for instance to be able to two finger slide a vnc session (client) on my phone to raise/lower the servers (vnc server/TV) volume level (vlc). Or the kids can vnc in from wherever to share the same desktop, that's visible on the TV.

Also, I like the option of having sites see the servers fingerprints, which could be being controlled by anyone from anywhere, the actual control device and its location are obscured. A ssh tunnel into the server that is basically just carrying screen buffer content and mouse/keyboard movements. I don't bother with the likes of Tor as to me that's largely irrelevant. Most sites require the likes of javascript to be permitted in order to be anywhere near usable, and once you let others run scripts on your device its game-over, the device can be uniquely fingerprinted with a high degree of probability, and in turn more often associated to a particular individual. If you want privacy, primarily you're limited to using just ssh/terminal, and all of the lack of functionality/convenience that involves.

When I can vnc along with having sound all played on the device in my hands, at near as good quality as if I were sitting at the server system, then that's good enough for my purposes. Yes when out and about the quality declines, ssh into the home server and run vnc and the display quality is reasonable, but add sound on top and that can be too much. But nice in that in ssh'ing to your home server that pretty much eliminates man-in-middle and/or eavesdropping, whilst also keeping your actual location (and device being used) obscured. My 'out and about' boot includes setting up a random mac, so not even that can be tracked from location to location.

Whether its vnc with sndiod, or rdp or whatever that is used to provide that functionality doesn't really matter, primary is what works best. And with ever increasing net speeds the situation/functionality is only likely to improve.

It's also nice having low spec devices, or even your phone, running a full gui desktop system, with minimal installation/configuration (install real vnc on a android phone for instance and that's enough, no rooting of the phone required). And/or having multiple OS's all available concurrently (ssh again can be most useful there, i.e. sshfs - that mounts remote systems/folders such that they appear to be just another local filesystem/folder).


Re: Remote Sound with sndiod

Posted: Sat Dec 19, 2020 8:20 am
by wiak

Yes, as you know from my many posts regarding vnc and particularly virtualGL in the past, I am also a fan of remote thinnish client type access, which was never so useful in the past (despite much crowing about the possibility) as it definitely is now. I have also played with sound over the network via pulseaudio though I did find it a bit of a network bandwidth hog and not so easy to keep audio in sync with video - as far as I recall it is using tcp, whereas udp would be a better fit really; perhaps some simpler method via udp will be identified eventually.

Alas, my original plans to keep my family's computers lean and mean with most apps served remotely (via vnc probably) have been temporarily scuppered by my young eight year old son, who insists on using two computers at the same time - one of them being the only machine I have access to that is powerful enough for my server plans. Eventually I plan to take it back though (though may have opportunity to pick up an alternative server-capable machine - just waiting to see if that option is going to occur). I think many of us have probably a collection of computers at home (collectected over the years) some of which could definitely be better and more securely utilised via a remote access networked system such as you describe. Indeed, it would be good to see more people adopt such approaches since that would encourage development geared to that kind of usage, which could result in some very powerful further-ideas/implementations I feel. And you are also spot on with your comment re using mobile devices as part of such a system - no real need to install linux on the mobile - just access the server via vnc client.


Re: Remote Sound with sndiod

Posted: Sat Dec 19, 2020 12:23 pm
by user1111

Hi wiak.

Your VirtualGL thread was most interesting/helpful https://weedoglinux.rockedge.org/viewto ... ?f=24&t=22 .. thanks.

The current setup I'm trying is a Fatdog laptop, slow wifi net connected to a acer desktop running OpenBSD that's hard wired (ethernet). Running x0vncserver along with sndiod. All in the UK, but where firefox-esr is set to use a German based ssh server (as a socks5 proxy). Response times are fantastic, I can watch and listen to youtubes comfortably, just one small niggle is that there is a tiny shift between sound and video, for example not quite lip sync'd when someone is talking. A very minimal delay, but there. I did try setting the sndiod to use a larger buffer as sound is otherwise ahead of video, but that didn't noticeably improve things.

That aside its nice to have fast response speeds whilst 'probes' throw out the totally wrong IP, location and device fingerprint. Simply the laptop (actual device) cannot be seen. A factor with that set up however is that adverts thrown at me, are in German, but in not speaking any German I guess that's a good thing - a anti subliminal mind programming measure :)


Re: Remote Sound with sndiod

Posted: Sun Dec 20, 2020 3:27 am
by wiak

It's a very interesting field of study this, especially when sound over the network also thrown in. There has never been much discussion of setting up Pulse Audio, or Jack for that matter (or alsa loopback methods and so on), on Puppy forum, so not much experience, so really fertile ground for experimentation now. I guess those who do have tons of experience with PulseAudio or Jack know of some sound delay plugin that could be fine tuned - else I'll have to set up a long spring or capacitor/inductor segments via some complicated Fourier Analysis delay calculation between my pre-amp and speakers... At least we are managing to break normal laws of Physics such that sound travels faster than light... albeit no longer in digital form...


Re: Remote Sound with sndiod

Posted: Sun Dec 20, 2020 9:36 am
by step