XBMC

From miki
Jump to navigation Jump to search

References

Install

The reference instructions are found on XBMC website.

Since Ubuntu Natty

sudo add-apt-repository ppa:nathan-renniewaldock/xbmc-stable
sudo apt-get update
sudo apt-get install xbmc

Since Ubuntu Karmic

Since Ubuntu Karmic, there is no need to add the XBMC Repository nor the PPA Keys. To install XBMC:

sudo add-apt-repository ppa:team-xbmc
sudo apt-get update
sudo apt-get install xbmc xbmc-standalone

Older version of Ubuntu

To install through command-line:

  • Add XBMC repository
sudo su
echo "# XBMC Repositories" >>/etc/apt/sources.list
echo >>/etc/apt/sources.list
echo "deb http://ppa.launchpad.net/team-xbmc/ppa/ubuntu karmic main" >>/etc/apt/sources.list 
echo "deb-src http://ppa.launchpad.net/team-xbmc/ppa/ubuntu karmic main" >>/etc/apt/sources.list
  • Add repository authentication key:
gpg --keyserver keyserver.ubuntu.com --recv 91E7EE5E  # Get the key from keyserver. If not available see below
gpg --export --armor 91E7EE5E | sudo apt-key add -    # Add the key to apt key list
# If Ubuntu keyserver is down, one can also the MIT one
gpg --keyserver pgpkeys.mit.edu --recv 91E7EE5E
gpg --export --armor 91E7EE5E | sudo apt-key add -
  • Install XBMC
sudo apt-get update
sudo apt-get install xbmc xbmc-standalone

XBMC key is usually available here, but sometimes this server is down. If so copy [{{#filelink: xbmc-key.gpg}} the file below], and copy-paste after typing the command cat | sudo apt-key add - (end with <ctrl-D>). {{#fileanchor: xbmc-key.gpg}}

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.0.10

mI0ESXWBBAEEAM5zE6qzPJ0Xn8KQQCB14OD9EyCieF5yjpt7PlLDUXkojjguVGgZ+skcklbF
my0eIOWYvMNmMIstqDoGYZQQGE3Sc4Dq2M0msc28uIrey2aBtYvKHXLaZ+JG42TU2q5CDLfN
vUxIOyWD2Yr4zq/sjg44pUodrUZGRPUFR50T0lPHABEBAAG0IExhdW5jaHBhZCBQUEEgZm9y
IFhCTUMgZm9yIExpbnV4iEYEEBECAAYFAknyZLgACgkQTJjLBcbOX94S7wCeKFyFk3v15Uy3
T17wvmCPaVIdE5YAni9juCXYgBGdXyZQYqgc5oh6/dXfiLYEEwECACAFAkl1gQQCGwMGCwkI
BwMCBBUCCAMEFgIDAQIeAQIXgAAKCRBtl1xHkefuXnryBAChrSStywXdJOrmjKqq4BrZ2Isk
BYqak7pD0JDaGy9HatChgJH/D30AhU74C9ReqkXvw8UohuVhQUH0lKBZWVzisSjJo4lmT/un
qqNeFpUivvz8RzPQf0S+zE2MHjDPIwjiz6ns97VdQtc2upbW6zd3BitE70P7gpCqvOyOFCnc
ow==
=Mur8
-----END PGP PUBLIC KEY BLOCK-----

Remote and Keyboard Control

Links and References

Some handy links:

Also contain keymapping when watching videos, listening to musics...

Keymapping specific to the installation are in file Keymap.xml (System folder).

An excellent page on Gyration remote in MythTV: http://www.mythtv.org/wiki/Gyration-based_MCE_Remotes

Tools

Here a list of tools and software that can be handy when setting up a remote/keyboard and troubleshooting issues:

xev
Print content of X events. Drawback is that it is fully dependent on X, and does not show event that X doesn't see, and also some events are not correctly reported because they are already fully (like the Power key) or partially (like VolUp or VolDown keys) intercepted by the graphical environment (Gnome...)
showkey
Examine the codes sent by the keyboard. This is a pure console program (so does not work properly under X because keys will already be pre-processed by X), but in a tty console (like those opened with Ctrl-Alt-F1) it shows all events that the kernel sees.
lirc (package), irrecord, irw
Provides infra-red remote control support. However it can also support multimedia keyboard. irw can be used to print the events generated by lirc. irrecord can be used to create new /etc/lirc/lircd.conf files.
evrouter
evtest
keytouch, keytouch-editor, getscancode
Creates keyboard file for new keyboard. At launch, the program asks to which USB event (as listed in /dev/input/by-id/) to connect to, and can detect keys pressed on the remote/keyboard and assign an action to that key.
dmesg
acpi_listen
ACPI event listener. Print events generated by the ACPI daemon. I could not make it work (Ubuntu 9.10 Karmic)...
evtest (package linEAKD)
Linux support for Easy Access and Internet Keyboard. Launch this with evtest /dev/input/event7 or evtest /dev/input/event8 to get the code / scancode corresponding to any button on the remote. This is the code to be used in the lircd.conf file.
dmesg
Prints the kernel messages. Might show interesting messages regarding input devices (unrecognized keys...)

Files

Log files where interesting information might be found:

Xorg.log
That file is located at /var/log/Xorg.0.log (and similar). For instance it shows the input devices that were recognized, and how they are handled by X:
(II) config/hal: Adding input device Gyration Gyration RF Technology Receiver
(**) Gyration Gyration RF Technology Receiver: always reports core events
(**) Gyration Gyration RF Technology Receiver: Device: "/dev/input/event6"
(II) Gyration Gyration RF Technology Receiver: Found 1 mouse buttons
(II) Gyration Gyration RF Technology Receiver: Found scroll wheel(s)
(II) Gyration Gyration RF Technology Receiver: Found keys
(II) Gyration Gyration RF Technology Receiver: Configuring as keyboard
(II) Gyration Gyration RF Technology Receiver: Adding scrollwheel support
(**) Gyration Gyration RF Technology Receiver: YAxisMapping: buttons 4 and 5
(**) Gyration Gyration RF Technology Receiver: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200
(II) XINPUT: Adding extended input device "Gyration Gyration RF Technology Receiver" (type: KEYBOARD)
(**) Option "xkb_rules" "evdev"
(**) Option "xkb_model" "pc105"
(**) Option "xkb_layout" "be"
(**) Option "xkb_options" "lv3:ralt_switch"
(EE) Gyration Gyration RF Technology Receiver: failed to initialize for relative axes.

Troubleshooting Gyration Remote 3101

  • Captured all keycodes / keysyms in X using xev. Not all buttons are seen by X (like LiveTV or Guide), other are captured by Ubuntu (like VolUp and VolDown).
  • Captured all keycodes / scancodes seen by the kernel with showkey -k and showkey -s (in a console TTY, i.e. not X).
    • All buttons have a keycode but the one that don't send RF signals (Connect, Setup, Input, Red, Green, Teletext, Yellow and Blue).
    • Some of these buttons have no scancode (LiveTV, Guide, ChanUp, ChanDown and DVD).
  • Tried xbindkeys and xbindkeys-config (see [1]) → it does not work!!! Keys that are invisible to X remains invisible!!!
  • Tried acpi_listen, but it just doesn't produce anything to me...
  • Installed lirc. Works very well!!! Hourray! Almost all keys work in XBMC, except Power, LiveTV, Home, and DVD. Note that keys Connect, Setup, Input, Red, Green, T, Yellow, Blue does not send RF codes and so are not meant to be used on PC.
  • Installed keytouch and keytouch-editor. There are 2 !!! devices for the remote:
    • /dev/input/event7, which according to links in /dev/input/by-id is USB kbd event. Most buttons on the remote are obtained through this event, except the key listed below.
    • /dev/input/event8, which is USB mouse event. The following buttons are obtained: Power, LiveTV, Left Click, Right Click, Home, DVD. Note that the key Power doesn't have a scancode, only a keycode.
  • Installed linEAKD. Run evtest to get the lirc keycode/scancode for both devices (i.e. /dev/input/event7 and /dev/input/event8):
    • sudo evtest /dev/input/event7
    • sudo evtest /dev/input/event8 - It confirms that Power button does not have a scancode, only a keycode (142, SLEEP).
  • Configured lirc to connect to 2 remotes simultaneously [2]:
  • #Assuming that lircd is not running...
    sudo /usr/sbin/lircd --output=/var/run/lirc/lircd1 --pidfile=/var/run/lirc/lircd1.pid --driver=devinput --device=/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd --listen
    sudo /usr/sbin/lircd --output=/var/run/lirc/lircd --driver=devinput --device=/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse --pidfile=/var/run/lirc/lircd.pid --connect=localhost:8765
    irw                    #Should show event for all buttons (except those without an RF code)
    

TO DO:

  • Try to set up the support of multimedia keys directly in X (see /var/log/Xorg.0.log for information regarding the input devices configured by X), without using lirc. The logs refers to evdev being used.
  • Investigate why the teletext buttons (red, green...) seem to send an event on the USB bus, but these events are not seen by lirc, evtest...
  • Make the star and dash buttons to work. These buttons actually send 2 events (shift + key). This post says that lirc can be configured to support that.
  • Enable *ALL* buttons on the Gyration Remote 3101 + mouse. When set up via lirc, it is possible to enable all buttons, but the mouse function does not work anymore because it is taken over by lirc. This post says that it should be fixed in next release of lirc.

Setting up the Gyration Remote 3101

The procedure below was done on Ubuntu 9.10 Karmic Koala.

  • Tried to setup lirc as described at [3] and [4].
  • sudo apt-get install lirc
    
    • I selected Windows media center remote, and no transmitter, but actually I should have started from a blank remote control file.
    • file /etc/lirc/lircd.conf as defined here.
      • Fix: In the original file, Power was reported as 0x0074, when on my system the keycode is 0x008E. Changing the settings doesn't make the button to work better though...
    • file /etc/lirc/hardware.conf (REMOTE_DEVICE must match name at ls -l /dev/input/by-id):
    #Chosen Remote Control
    REMOTE="GYRATION REMOTE 3101"
    REMOTE_MODULES=""
    REMOTE_DRIVER="devinput"
    REMOTE_DEVICE="/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd"
    REMOTE_SOCKET=""
    REMOTE_LIRCD_CONF=""
    REMOTE_LIRCD_ARGS=""
    
    #Enable lircd
    START_LIRCD="true"
    
    • Restart the lirc daemon and test it. Every button works except Power, LiveTV and DVD !
    sudo /etc/init.d/lirc restart
    irw
    
  • Add the definition of the gyration remote in XBMC (file /usr/share/xbmc/system/Lircmap.xml):
  • 	<remote device="gyration">
    		<play>Play</play>
    		<pause>Pause</pause>
    		<stop>Stop</stop>
    		<forward>Forward</forward>
    		<reverse>Rewind</reverse>
    		<left>Left</left>
    		<right>Right</right>
    		<up>Up</up>
    		<down>Down</down>
    		<select>Enter</select>
    		<pageplus>ChanUp</pageplus>
    		<pageminus>ChanDown</pageminus>
    		<back>Back</back>
    		<menu>Home</menu> 
    		<title>Guide</title>
    		<info>More</info>
    		<skipplus>Skip</skipplus>
    		<skipminus>Replay</skipminus>
    <!--		<display>Teletext</display> -->
    <!--		<start>Home</start> -->
    		<record>RecTV</record>
    		<volumeplus>VolUp</volumeplus>
    		<volumeminus>VolDown</volumeminus>
    		<mute>Mute</mute>
    		<power>Power</power> 
    <!--		<myvideo>Videos</myvideo> -->
    <!--		<mymusic>Music</mymusic> -->
    <!--		<mypictures>Pictures</mypictures> -->
    <!--		<mytv>TV</mytv> -->
    		<one>One</one>
    		<two>Two</two>
    		<three>Three</three>
    		<four>Four</four>
    		<five>Five</five>
    		<six>Six</six>
    		<seven>Seven</seven>
    		<eight>Eight</eight>
    		<nine>Nine</nine>
    		<zero>Zero</zero>
    <!--		<star>StarHash</star> -->
    		<hash>StarHash</hash>
    		<clear>Clear</clear>
    		<enter>Enter</enter>
    <!--		<red>Red</red> -->
    <!--		<green>Green</green> -->
    <!--		<yellow>Yellow</yellow> -->
    <!--		<blue>Blue</blue> -->
    	</remote>
    
  • To work-around the Power that does not work, I edited the remote action file to show the shutdown menu when pressing the Back button in the Home window (file /usr/share/xbmc/system/keymaps/remote.xml):
      <Home>
        <remote>
          <!-- ... -->
          <back>XBMC.ActivateWindow(shutdownmenu)</back>
        </remote>
      </Home>
    

So in summary, to get the Gyration Remote 3101 to work in XBMC:

  • Install lirc
  • Edit file /etc/lirc/lircd.conf and hardware.conf
  • In XBMC, edit the button mapping file /usr/share/xbmc/system/Lircmap.xml (this file maps the remote name & button name as reported by LIRC to a XBMC command).
  • Edit the command mapping file /usr/share/xbmc/system/keymaps/remote.xml (this file maps the XBMC command in the previous file to real commands in XBMC).

Troubleshoot

My XBMC bugs on Delicious.

Freeze on Eeebuntu NBR 3.01

  • Eeebuntu NBR 3.01 - Ubuntu Jaunty 9.04 - Array Kernel 2.6.28-15 - XBMC v 9.04.1-jaunty1.
  • Freezes seems to be specific to Eeebuntu NBR 3, as reported here: [5], [6], [7]
  • Possible work-arounds:
    • Try stable platform as suggested in 2nd bug report above: Intrepid + intel xserver from xorg-edgers ppa + 2.6.28 kernel from jaunty + libpulse-dev + compiling XBMC from the SVN (slower GL than Ubuntu 9.04 though).
    • Try Eeebuntu NBR 2.0
      • Tried. The autoscan completes. But there are hick-ups reading the DVD (scene skip, roll-back). Need further testing to identify the causes. Rendering is not 100% smooth.

DVD Play-back hick-ups

  • Alien 4
    • This is a multi-angle DVD. When playing the Special Edition, the chapter 3 is played twice, then not possible to go backward (before 00:06:00) + misc. hick-ups. There is no problem with the Theatrical Cut.
      • Confirmed on Minimoy Samsung NC10 - Eeebuntu NBR 2.0 - XBMC v9.04.1-jaunty1.
      • Confirmed on Dell Latitude 620 - WinXP SP4 - XBMC 9.04.1 repack 2.
    • Media problem, not a XBMC bug. Windows readers also fail reading the DVD correctly (PowerDVD 4.0 on W2K can't even play the movie, WinDVD 4.0 on WXP performs a bit better, but with jumps/hickups).

Slow connection to Samba share

  • First launch of XBMC, Source on samba share takes long time to connect (20 sec).
    • Confirmed on Dell Latitude 620 - WinXP SP4

XBMC menu showing up unexpectedly and taking focus

  • Sometimes the XBMC navigation menu shows up when moving the mouse, although the current title is a DVD menu.
  • Moreover the frustrating part is that when this menu is shown, it is not possible to click on the DVD Menu Item

Output Audio via HDMI connector

If the host PC has several audio outputs (audio jack, HDMI, SPDIF...), it is possible to configure XBMC so that to use one of these output. This is done in the System - settings for Audio.

Choosing HDMI/Digital or analog output

  • Tells XBMC to either decode the audio stream locally and to play it on the audio card (analog), or to send the stream as-is to selected digital output (only HDMI / SPDIF - passthrough mode).
  • This choice is independent of where the audio will finally be sent.
    So can still choose analog, and have audio sent to your TV set connected via HDMI. The only difference is that in case of analog, you can still control the volume via XBMC, whereas you can't anymore in the case of HDMI (since the stream is decoded by the receiver, not by XBMC)

Selecting the correct output device This is the real problem in fact since there are usually many of them, and it is not quite clear which one to choose.

The easiest is to log onto the XBMC host (via SSH for instance):

aplay -L          # List all available output device

You get lot of devices like:

...
hw:CARD=Intel,DEV=0
HDA Intel, STAC92xx Analog
Direct hardware device without any conversions
...
plughw:CARD=NVidia,DEV=7
HDA NVidia, HDMI 0
Hardware device with all software conversions
...

Using aplay, you can test all these devices until you find the correct one:

aplay -D plughw:0,7 /usr/share/sounds/alsa/Front_Center.wav

If this works, you can then enter plughw:0,7 into XMBC device (select custom device if it is not in the list of proposed devices).


Reference: see [8], [9], [10]

Audio in both XBMC and Games / Advanced Launcher add-on

  • First, we need to list the audio devices we have. Note that aplay -l prints the available hardware devices, by card number and device number on each card, whereas aplay -L prints the available PCMs, ie. "software device aliases". The advantage of PCMs is that their references / identifiers are less likely to change after reboot, whereas identifier of hardware devices may change if a new device is added to the PC (http://superuser.com/questions/53957/what-do-alsa-devices-like-hw0-0-mean-how-do-i-figure-out-which-to-use see [this nice post]).
  • In my case I have (Zodiac Zbox mini-pc based on NVidia ION, connected to Samsung TV via HDMI):
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

From experience, I know that the correct card is the HDA NVidia card (i.e. card number 1, either HDMI 0 or 1 (i.e. device number 1 or 3).

  • We can test the device with aplay and speaker-test. This is not necessarily easy since for some devices, one might have to give extra parameters on the command-line, like the number of channel. In my case, I have:
speaker-test -Dhw:1,7                        # fails (error "Channels count (1) not available for playbacks: Invalid argument")
speaker-test -Dhw:1,7 -c 2                   # works (using bare hw device)
speaker-test -Dplughw:1,7                    # works (using sw device, with built-in support for all conversion)
aplay -Dhw:1,7 /usr/share/sounds/alsa/Front_Center.wav        # fails (error "aplay: set_params:1087: Channels count non available")
aplay -Dhw:1,7 -c 2 /usr/share/sounds/alsa/Front_Center.wav   # idem
aplay -Dplughw:1,7 /usr/share/sounds/alsa/Front_Center.wav    # works!
  • Based on the result above, I can create the file ~/.asoundrc in xbmc home directory (/home/xbmc) (from [11]):
pcm.!default {
  type plug
  slave {
    pcm "hw:1,7"
  }
}
ctl.!default {
  type hw
  card 1
}

This works only if xbmc sound is disabled (for instance, by selecting another audio device in the audio system properties). This is because by default XBMC uses audio for GUI sound, and XBMC maintain an exclusive access to the card. So by pointing XBMC to another audio device, we allow desktop application to access the device. Note that disabling the GUI sounds is not sufficient.

  • The following settings allow to use exclusive HDMI passthrough, and to fall back to a dmix plugin for the XBMC desktop mode (so that multiple applications can share the HDMI access) (from [12] and [13]). Copy in ~/.asoundrc:
pcm.hdmi_direct {
        type route
        slave {
                pcm "hdmi:1,1"
        }
        ttable.0.0 1
        ttable.1.1 1
        ttable.2.4 1
        ttable.3.5 1
        ttable.4.2 1
        ttable.5.3 1
}

pcm.hdmi_shared {
        type route
        slave {
                pcm "hdmi_dmixer"
        }
        ttable.0.0 1
        ttable.1.1 1
        ttable.2.4 1
        ttable.3.5 1
        ttable.4.2 1
        ttable.5.3 1
}

pcm.hdmi_dmixer {
        type dmix
        ipc_key 1024
        ipc_key_add_uid false
        ipc_perm 0660
        slave {
                pcm "hw:1,7"
        }
}

pcm.!default {
        type plug
        slave.pcm "hdmi_shared"
}
In XBMC, choose hdmi_direct for passthrough output device but hdmi_shared for audio output device (choosing hdmi_direct) will again give exclusive access to GUI sound and prevent desktop application to use audio).

Reference: