handle SIGTERM

In some situations, due to deadlocks or crashes, xbmc fails to exit properly in
CApplication::Stop(), so  g_powerManager.Reboot() / g_powerManager.Powerdown() never gets
called, that's a big no-no for openelec as our users can't shutdown or reboot.
There are few addons reported to cause this behaviour: trakkt.tv, watchdog, weather.underground.

I've also noticed that sometimes new threads (FileCache ??) get started AFTER
CApplication::Stop() is called, delaying shutdown with 1+ minute (2 curl timeoouts?).
The problem seems to be in CJobManager::CancelJobs() but I am too lame to understand where,
why, and how to fix it.

To me, it seems best to let systemd handle it. systemd sends SIGTERM, then waits
TimeoutStopSec=xx seconds then sends SIGKILL,s so dont call g_application.Stop() from
ApplicationMessenger as it can not be trusted. save the requested exitcode instead
(that's required for CEC to switch off the tv) and do it from a simple SIGTERM handler instead.

CEC thread has enough time (5 seconds in xbmc.service) to switch of the TV after receiving OnQuit.
As a side "effect", now guisettings.xml will ALWAYS be saved, even if shutdown / rebooot
is requested externaly (ssh, 3rdparty script).
Fix ALSA sound output for Amlogic-based devices.
Allow audio passthrough for Amlogic-based devices.
Enable true 1920x1080 output without upscaling on Amlogic-based devices.
Add support for retrieval of CPU temperature on Amlogic
Add support for AV (CVBS) video output on Amlogic
[aml] Fix the issue when the video display is disabled after a resolution change
[aml] Update all virtual consoles when changing framebuffer geometry after a resolution change

That helps to resolve the issue when framebuffer size is not always correctly change according to the resolution set.
It seems that the issue appeared after updating to the U-Boot bootloader released 2014-08-24 by Amlogic.
Reorder libraries in configure script to prevent linker errors when linking with libsmbclient

Place libsmbclient before all other libraries to prevent linker errors when linking
with libsmbclient if the libc that is currently used doesn't contain some functions
such as dn_expand (which are often included in libc), but are actually included in
libresolv.
[aml] Change the sample rates that are supported by ALSA but unsupported by HDMI to the closest supported value
[aml] Fill audio packets completely when resampling to prevent 'audio data unaligned' kernel warnings
[aml] Use fpsrate and fpsscale instead of rfpsrate and rfpsscale to detect framerate
Fix incorrect frame rate detection of some videos with variable frame rate.

Use FFMPEG's r_frame_rate, if it as valid, as a video stream frame rate, otherwise use avg_frame_rate.
Also remove CDVDStreamInfo.rfpsscale, CDVDStreamInfo.rfpsrate, CDemuxStreamVideo.irFpsScale and CDemuxStreamVideo.irFpsRate,
they are not needed anymore.
[aml] Always use the SYNC_OUTSIDE decoder flag for most smooth playback of H264 video
Save settings only if they were modified after last save

This prevents from multiple saving the same settings and helps to resolve
the issue on Amlogic G18REF TV-boxes when setiings may be lost after a poweroff.

On G18REF When you press the red button on the remote the system receives a signal that power
is about to off. XBMC always writes guisettings.xml before exit, and the same settings
may be written several times from different places in code. But the power gets turned off
before the system completes all shutdown procedures. There may be the case that guisettings.xml
is written half-way and couldn't be read upon next boot, so the XBMC creates a new one with
default settings.

With this fix the settings will be written at exit only once, minimizing the risk of being lost.