The sittuation:
Melanie's computer (running Linux Mint / Ubuntu) is about 6 meters (accross the family room) away from the hi-fi / amplifier, so the problem exists on how to get the music to play on the amp, but use her pc as the control interface. The simplest solution would be to put a cable from her pc to the amps aux input, but due to practical reasons for not being able to do this, I had to come up with other solutions.
This has been an on going project, to find the right solution, and I have learnt quite a bout concerning linux and sound. To be frank, I now realise that I had over thinked the issue. In the end, the simplest solution was the one that worked.
Also note that I have a dual core atom based mini-pc sitting next to the amp / tv, which is used to run XBMC as a media centre. This box gave me access to the amp over the network form other machines, and was the basis of all the ideas.
Some history, before I get to the solution that worked:
Attempt 1:
This was quite a complex solution, but it was the first one that came to mind. It was a bit of an overkill, and nearly nearly worked. At least I got a new imrpoved wireless-N network out of this :)
It went something like this:
I ran pulseaudio server on the atom-box. Mel's machine then connected using pulseaudio sinks to the atom pulse server, and music was played over the wireless. This used A LOT OF BANDWIDTH, and I had to upgrade my wireless to network-N, getting around 250 mb/s througput between the machines.
This solution allowed the actual music data hard drive (extern terrabyte drive) to be connected directly to Mel's pc, thus allowing her quick direct edit of files.
This nearly worked, but at times music started to stutter, and also a big issue was that XBMC and pulseaudio server did not gel well, so each time music was to be played, XBMC had to be stopped, and pulseaudio server started, and vice versa for when we wanted to use XBMC.
After a few months of dissatisfaction from Mel (the system was hap-hazard, and broke fairly often, and my constant tweaking to get it smoothed out did not help), I decided to look for a new solution, and thus we moved onto MPD
Attempt 2:
I moved the music hard drive to be connected directly on the the atom-box, and shared this via nfs to Mel's machine. I then installed MPD (Music Player Daemon) on the atom-box, and installed GMPC (Gnome Music Player Client) on Mel's machine. This worked, as it allowed the music to play uninterupted, It no longer had to stream over the network. This had major advantages, but the client let me down. Mel just used it once and rejected it outright. I do have to aggree: it was very very lacking in functionality, compared to exaile, which was our prefered player.
I looked at a couple of other clients, but they are all lacking. I momentarally considered the idea of creating my own, or enhancing GMPC, but I just don't have the time to take on such a project.
Thus back to searching for a new solution...
The Soluton:
Finally I hit the spot!
Originally my idea was to use vnc, to remote connect to the atom-box, and run exaile remotely.
This idea quickly changed to just using the built in xorg means of running an application locally, but pushing the display to a remote machine using the DISPLAY variable. This worked like a DREAM.
I follwed the guide found on http://www.faqs.org/docs/Linux-mini/Remote-X-Apps.html ssh acccess between the two machines were already password-less, making use of keys.
On Mel's machine I created an application launcher with the following as the command: ssh user@pygmy.local "DISPLAY=jessy.local:0 exaile &"
Very soon, I also found that I could use 'ssh -Y' to achieve the same result, and no need to muck about with DISPLAy and xhost etc, but I wanted to check which of the two methods give me the best throughput.
Bandwidth testing:
To test the wireless throughput, I have to run the tests at the atom machine, since Mels machine is wired to the router.
I installed 'bmon' on the atom machine.
On avarage I see a RX rate of 80 k/bits and a TX rate of 6 k/bits (when idle, no interaction from me) and I see a RX rate of 130 k/bits and a TX rate of 30 k/bits (when I move and manipulate exaile locally)
Seemed a bit high, so I need to try and compress the data. Don't want the interface slow. Mel works her pc fast, and will get irretated if the display lags.
Looking at my Howto, to get remote XHOST working, I see there are two potential solutions : LBX and DXPC
I first looked at LBX, and when it started to say stuff like
'There is unfortunately no "broken out" distribution of lbxproxy, so you will have to either (a) get and build most, if not all, of X11R6.3 for the remote system, or (b) find someplace to get a pre-compiled lbxproxy binary for your system. The latter is much simpler of course.'
I immediately checked out DXPC.
DXPC looked simpler to install (it is in apt), so it won my choice award :)
I installed this on both the atom and Mels machines.
sudo aptitude install dxpc
Potentially issue would be that the atom machine is running Ubuntu Karmic server edition, and Mels machine is Linux Mint 7 (Ubuntu Jaunty), but that was ok, both had the same version of the app.
On the atom machine (where the program is going to actually run), I start the process as such: ( Mel's machine is called 'jessy' )
export DISPLAY=jessy.local:0.0 && dxpc -s1 -f && export DISPLAY=:0
and on Mel's machine as such:
dxpc pygmy.local -s1 -f &
This creates the proxied display connection. WIth this setup, and program I push to display of unix:8 will appear on Mel's machine.
On the atom machine I then run the command
DISPLAY=unix:8 exaile
to start exaile and the display appears on Mel's screen. The music then plays nice a stutter free.
I set those commands into each machines /etc/rc.local, but found that if either machine reboots, or losses the network, the process needs to be restarted on both.
This was a bother, so what I am doing now is to run a bash script on Mel's machine, which does remote comands via ssh to start the process as it is needed. For this to work without passwords you need to setup ssh keys between the machines.
I also found that xbmc is intefering. (no sound when it is running) I will try and solve this later, got other things to do, so for now the script also kills and resatrts xbmc as required. We don't play music and watch movies at the same time.
The script I use:
#!/bin/bash zenity --info --text \ "Clisk OK to start exaile on remote server.\nMelanie, \ Please wait a few seconds while this happens! (after OK is clicked)" \ ssh user@pygmy.local "dxpc -k" ssh user@pygmy.local "export DISPLAY=jessy.local:0.0 && dxpc -s1 -f && export DISPLAY=:0" & ssh user@pygmy.local "killall xbmc" ssh user@pygmy.local "sudo /etc/init.d/alsa restart" sleep 2 dxpc pygmy.local -s1 -f & ssh user@pygmy.local "DISPLAY=unix:8 exaile" ssh user@pygmy.local "dxpc -k" ssh user@pygmy.local "startx"
It is now 3 weeks later, and this method is working great. The only issue I have had was to restart Mel's machine, as it woudl not make the connection. Not sure what was up with that.
I now use the same method, with a slightly adjusted script, to remote run K3b, thus writing cd's easier on the htpc. I used to do it via ssh. Much simpler to gui that.
|