Linux BIG GUIDE: Bit Perfect, Remote Controlled XBMC Machine From Scratch
#1
!! This guide is based on Linux Mint 17 MATE. !!

Q: What's the purpose of this guide ?
A: I will show you how to set up a fresh Ubuntu based installation to run XBMC with bit perfect sound, which can be controlled 100% using Android devices. You can execute anything on your remote device, that means start / kill programms ! Very usefull, since "Bit Perfect" means it will lock your sound to ONE application - using this, you can switch to whatever programm you want and still have it bit perfect ! You ARE NOT LIMITED TO XMBC !

You should know some Linux basics, this is not a Linux first timers guide.
Let's begin, I will try to focus on important things to keep it short as possible.

1. REQUIREMENTS:
Up and running fresh Linux install.
You will need "sudo" rights, so add your account to that group if you don't use the account which boots up after install.
Check "auto login" on setup (or later) and disable password after screensaver.
I suggest you create 3 partitions when installing:
  1. System mounted to "/"
  2. Home mounted to "/home" (config files go here, can be carried over between Linux installs)
  3. SWAP (used for suspend etc.)

Install XBMC:
Code:
sudo apt-get install python-software-properties pkg-config
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install xbmc

2. REMOTE DESKTOP CONTROL:

Since I hate to sit in front of my TV for hours, this is the first thing to do. I use XRDP to make it easier to connect from Windows.
After you can use Microsofts built in Remotedesktop tool (the one for Android works too) or any VNC compatible viewer (TightVNC etc.) to control it.
You can even stream XBMC UI and go through the menus (arrow keys) ! There will only be 1 login, you control what you see on TV !

vino: our server, this is what allows you to see your desktop
xrdp: communicates with vino and your remote PC
dconf-tools: allows you to edit hidden settings - maybe you won't need it but it won't hurt

Hint: you can replace gedit with any text editor you like, won't allow you to copy&paste the terminal lines in here ;)
Type in terminal, line by line:
Code:
sudo apt-get install vino xrdp dconf-tools gedit
gsettings set org.gnome.Vino require-encryption false
vino-preferences

Sharing: tick both options, "allow users to control / view your desktop"
Security: disable all. You can tick the password option if you want a password check before it connects
Notification Icon: As you like

Close it. Now type :

Code:
sudo gedit /etc/xrdp/xrdp.ini

Leave the [global] section and delete the rest. Then add my [xrdp1] section to it.
If you did not set a password in vino-preferences change "password=ask" to "password="
It should stop showing you a login box. xrdp.ini should look like this:

Code:
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=low
channel_code=1
max_bpp=24
#black=000000
#grey=d6d3ce
#dark_grey=808080
#blue=08246b
#dark_blue=08246b
#white=ffffff
#red=ff0000
#green=00ff00
#background=626c72

[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=
password=ask
ip=127.0.0.1
port=5900

Save and close the window, reboot. Now you can try to connect to your server.
DONE. Remove your keyboard and mouse, they are obsolete now ;)

If it fails, go to your start menu and launch "dconf Editor".
Navigate to: org -> gnome -> desktop -> remote-access
Uncheck "require-encryption", now it should connect !


3. BIT PERFECT SOUND aka PASSTROUGH
There are few options you can use. But let me explain few things first.
There is Pulseaudio and ALSA in Linux. Pulseaudio is dirty, it manipulates your sound, does conversions to it and merges your sound sourcest.
There is also ALSA. It's exclusive to ONE sound source at a time. Programms will LOCK a device when you use ALSA, so it won't be available to other programms. For example, you use ALSA in a media player, then start XBMC - it won't show the audio device to you since it's locked.
You can tune Pulseaudio quality (see Google) - I never used it and won't use it :)

Choose ONLY ONE Option !

1. Pulseaudio and passthrough to ALSA:

This mode is nice to have if you use multiple applications which need sound output at the same time !
You are limited to 2.0 Stereo sound, ELSE passthrough WON'T work !
You can still have limited "bit perfect" sound, excluding few options like DTS or TrueHD !

Go to your start menu and search for "Sounds". Start it. Set up your sound as you like then close it.
Now install this:
Code:
sudo apt-get install pavucontrol
sudo pavucontrol
See that "Advanced" option in there, there is a arrow to press to show few hidden options.
Do it and check all sound types which should use passthrough (DTS, AC3 etc.).
All other, missing options will not be bit perfect ! Close it. Configure XMBC audio to use your Stereo 2.0 Adapter you set in your "Sounds" config window.

2. Mixed Mode:
We will use Pulseaudio for background applications and ALSA for XBMC. This one is good if your AV Receiver lacks sound formats like DTS.
THEY can interfere and cause rubbish sound. If this happens, try to change audio settings in XBMC a bit, it may help you out.
But this will allow you to have bit perfect sound in XBMC ! The trick is to start XMBC usin: AE_SINK=ALSA xmbc in terminal / scripts.

You CAN extend this to two devices for bit perfect, if you use HDMI + OPTICAL and your hardware supports it !
But it will require you to switch channels on your AV Receiver.

Set up your other desktop applications to use Pulseaudio as your output device and see in XBMC audio options, there should be new entries !
Don't forget to switch XBMC to "expert view" (bottom left corner).

The second device entry in XBMC Sound options is the one used for bit perfect / passthrough. It directly below the "passthrough" radio button.
Tick the formats your AV Receiver supports. All non supported formats will use the device entry at top.
While watching movies, you can call the on screen menu (Mouse/ESC) and enable/disable passthrough.

Example script, used in "Remote Launcher" section:
Code:
sudo touch /usr/bin/xbmc.sh
sudo chmod +X /usr/bin/xbmc.sh
sudo gedit /usr/bin/xbmc.sh

#----xbmc.sh file ----

#!/bin/bash
AE_SINK=ALSA xbmc

3. ALSA only, the real thing !

Good for only a limited amount of sound sources, or if you use some kind of remote launcher to start / quit applications so they won't lock out each other. I will show you how to do this later. First, we need to prevent Pulseaudio from starting on boot. Run:
Code:
sudo gedit /etc/pulse/client.conf

Find "; autospawn = yes" and uncomment it and change to "autospawn = no".
Now you can start XBMC the usual way, it will find your ALSA devices.
Choose them, set up audio as you like - similar to Option 2 above.

If, for some reason you need Pulseaudio, you can use this in terminal to call / kill it:

Code:
pulseaudio --start
pulseaudio --kill

4. GRAPHIC DRIVERS
They are needed. For some reasons there are no proper drivers included (I use the Asrock Q1900DC mainboard with J1900 CPU).
Without those drivers, you may have massive frame drops on weaker CPUs !
For AMD / Nvidia CPU / GPUs combinations use the installer on their website.

For Intel, they have an open source installer which will setup your repos for updates etc.: https://01.org/linuxgraphics/
BUT there are some difficulties. To make the installer install do this (Ubunut based distributions!):

Code:
sudo cp /etc/lsb-release /etc/lsb-release.bak
sudo gedit /etc/lsb-release

delete all in there, copy this into it and save, close editor:

Code:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="We fooled you, Intel !"

Now start the installer, simply double click the .deb file. Let it finish and it will install an INSTALLER only !
Then go into your start menu and you will find a "Intel Graphics Installer..." entry.
Choose it, this one will install the drivers. Let it finish then close.

Restore lsb-release:
Code:
sudo mv /etc/lsb-release.bak /etc/lsb-release
Done. If the installer / updates fail later on, you may need to edit lsb-release again.

5. REMOTE APPLICATION LAUNCHER & AUTOSTART
To have applications start on launch, go into menu -> "Startup Applications".
Make a new entry, name it and point to "/etc/rc.local". We will use rc.local to put all the things we want to start at launch.
Ending the line with " &" will not wait for the launched application to finish, it will execute the next line directly.

Hint: older Linux versions auto run rc.local on start but this was removed. Now we can use it again, easiest method.

Code:
sudo gedit /etc/rc.local

If you want XBMC to start at launch and are not interested into remote launching applications, add this line to rc.local and skip the rest of this guide:
Code:
/usr/bin/xbmc &

If you want remote launching, add one more line:
Code:
java -jar /usr/share/remotelauncherserver/Remote\ Launcher.jar &

Remote launching works by having a tool runnign on server and have an Android app which connects to it !
Your Android app can execute any command / script.sh with a single button press. AWESOME !

Let's setup server first:
You can find the files here: http://owtroid.com/remotelauncher/mediaw...e_Launcher
Download the file, double click and extract the folder into your /home/user/Downloads folder
Navigate in terminal into that folder and:

Code:
sudo ./install.sh
remote-launcher-server

Go into options and allow to connect, edit launchers and set up ports however you want.
You can also add launchers (applications to start). There are few example configs, XBMC kill won't work, see below.
BUT to prevent some trouble, I suggest you create scripts in /usr/bin and point your launchers to them.

Create scripts & edit scripts:
Code:
sudo touch /usr/bin/xbmc.sh
sudo chmod +X /usr/bin/xbmc.sh
sudo gedit /usr/bin/xbmc.sh

Example content:
Code:
#!/bin/bash
/usr/bin/killall -9 xbmc.bin

Reboot to make it launch.

Now go to GooglePlay and install "Remote Launcher" on your Android device:
https://play.google.com/store/apps/detai...cher&hl=en

Free version CAN'T setup launchers remotely, you have to do it on your server!
It's worth the money, at least for me ;)

Search / add your server to your Android App and connect.
You should see the launchers you added on server, also options to make new launchers.
Tap & Hold one entry, it will offer create a shortcut to your Android desktop - you can change Icons in Android after.
Tap those shortcuts and voila. Done.

6. SOME HINTS

To control XMBC I suggest using "Music Pump" for Android. In my oppinion it's superior to YATSE.

You can install "wine" and use "Spotiamp". Using Spotify on your mobile device, you can hook it up in options (Spotify connect) to remote control Spotiamp and play songs. Your server plays all those songs, it's not a stream ! Set up a que and turn your Tablet / Phone off if you like !
Currently Spotify desktop versions don't have Spotif connect ! This is the only way for now ! BUT it's glitchy using wine, you need to have songs running on your Android device before you connect, else Spotiamp will crash. Works better under Windows.

You can launch emulator games, add a file sync server with Unison and transfer files between desktop <> server <> notebook with a simple .bashrc macro.
This will require SSH setup etc. - so there is some work to do.

You can share folders, easily done by choosing "Menu -> Shared Folders". Give Windows some time to detect your server.
Win8 fails for me completly to autofind it but you can call your server by name in Windows explorer adress bar: \\htpc\
Reply
#2
Quote:BIT PERFECT SOUND aka PASSTROUGH

this statement is wrong. bit perfection is not related to passthrough.
Reply
#3
Guides should go eventually on the WIKI. Forums are useless for that
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply

Logout Mark Read Team Forum Stats Members Help
BIG GUIDE: Bit Perfect, Remote Controlled XBMC Machine From Scratch0