Kodi Community Forum

Full Version: Kodi not working on Linux Mint xfce
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok I am a new to this whole linux thing but windows has pushed me to the breaking point. Linux Mint is awesome except I cannot get my Kodi running. I get the splash screen and then back to the desktop.

My system is an old Dell 3000 series.

I installed Kodi this way....

sudo add-apt-repository ppa:team-xbmc/ppa

Then I opened Software Manager and did a search for Kodi. Lots came up and I installed everything that said kodi.

Once done I restarted my system (I have no reason why, just seemed like a good idea) and then found Kodi under Multimedia and clicked on it.

I got the splash screen for Kodi 15.1 isengard and then it went away and I was looking at my desktop again.

I have run this version of kodi on this computer when it was running win7 with no problems. But in Linux I seem to have a problem.

Any help would be greatly appreciated.
Why did you do all that?

You added the correct repository, so just

apt-get update
apt-get install kodi

i'd go with openelec though, unless you need a browser and os gui, then try kodibuntu
Tried all you suggested already with same results.

He is my last crash report. Its all alien to me, but hopefully someone can make heads or tails out of it.

############## Kodi CRASH LOG ###############

################ SYSTEM INFO ################
Date: Thu Sep 17 00:54:55 CDT 2015
Kodi Options:
Arch: i686
Kernel: Linux 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:44:48 UTC 2015
Release: Ubuntu 14.04.2 LTS, Trusty Tahr
############## END SYSTEM INFO ##############

############### STACK TRACE #################
=====> Core file: /home/mikenkaren/core (2015-09-17 00:54:54.261421356 -0500)
=========================================
[New LWP 2189]
[New LWP 2192]
[New LWP 2193]
[New LWP 2194]
[New LWP 2195]
[New LWP 2196]
[New LWP 2197]
[New LWP 2198]
[New LWP 2205]
[New LWP 2206]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/lib/kodi/kodi.bin'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000000 in ?? ()

Thread 10 (Thread 0xaa580b40 (LWP 2206)):
#0 __strlen_sse2_bsf () at ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S:50
#1 0xb70611ce in PyString_FromString () from /usr/lib/i386-linux-gnu/libpython2.7.so.1.0
#2 0xb7061cac in PyDict_GetItemString () from /usr/lib/i386-linux-gnu/libpython2.7.so.1.0
#3 0xb705beaa in PyType_Ready () from /usr/lib/i386-linux-gnu/libpython2.7.so.1.0
#4 0xb706443b in _Py_ReadyTypes () from /usr/lib/i386-linux-gnu/libpython2.7.so.1.0
#5 0xb70845dd in Py_InitializeEx () from /usr/lib/i386-linux-gnu/libpython2.7.so.1.0
#6 0xb7084f7b in Py_Initialize () from /usr/lib/i386-linux-gnu/libpython2.7.so.1.0
#7 0x087c3e2d in XBPython::OnScriptInitialized(ILanguageInvoker*) ()
#8 0x087b53cc in ILanguageInvoker::onExecutionInitialized() ()
#9 0x087cc60e in CPythonInvoker::Execute(std:Confusedtring const&, std::vector<std:Confusedtring, std::allocator<std:Confusedtring> > const&) ()
#10 0x087b4d4e in CLanguageInvokerThread:Tonguerocess() ()
#11 0x097aef85 in CThread::Action() ()
#12 0x097af69d in CThread:ConfusedtaticThread(void*) ()
#13 0xb7368f70 in start_thread (arg=0xaa580b40) at pthread_create.c:312
#14 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 9 (Thread 0xb445eb40 (LWP 2205)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb736d12d in pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_timedwait.S:245
#2 0x097af527 in CThread::Sleep(unsigned int) ()
#3 0x08998ae7 in MEDIA_DETECT::CDetectDVDMedia:Tonguerocess() ()
#4 0x097aef85 in CThread::Action() ()
#5 0x097af69d in CThread:ConfusedtaticThread(void*) ()
#6 0xb7368f70 in start_thread (arg=0xb445eb40) at pthread_create.c:312
#7 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 8 (Thread 0xb2273b40 (LWP 2198)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb736d12d in pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_timedwait.S:245
#2 0x097adaa4 in XbmcThreads::CEventGroup::wait(unsigned int) ()
#3 0x08b3276d in CRemoteControl:Tonguerocess() ()
#4 0x097aef85 in CThread::Action() ()
#5 0x097af69d in CThread:ConfusedtaticThread(void*) ()
#6 0xb7368f70 in start_thread (arg=0xb2273b40) at pthread_create.c:312
#7 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 7 (Thread 0xb2a74b40 (LWP 2197)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb60c7c8b in poll () at ../sysdeps/unix/syscall-template.S:81
#2 0x097446a8 in PERIPHERALS::CPeripheralBusUSB::WaitForUpdate() ()
#3 0x09744780 in PERIPHERALS::CPeripheralBusUSB:Tonguerocess() ()
#4 0x097aef85 in CThread::Action() ()
#5 0x097af69d in CThread:ConfusedtaticThread(void*) ()
#6 0xb7368f70 in start_thread (arg=0xb2a74b40) at pthread_create.c:312
#7 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 6 (Thread 0xb3275b40 (LWP 2196)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb736d12d in pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_timedwait.S:245
#2 0x097466d0 in PERIPHERALS::CPeripheralBus:Tonguerocess() ()
#3 0x097aef85 in CThread::Action() ()
#4 0x097af69d in CThread:ConfusedtaticThread(void*) ()
#5 0xb7368f70 in start_thread (arg=0xb3275b40) at pthread_create.c:312
#6 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 5 (Thread 0xb3a76b40 (LWP 2195)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb736d12d in pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_timedwait.S:245
#2 0xb3a9b77c in CEC::CCECClient:Tonguerocess() () from /usr/lib/i386-linux-gnu/libcec.so.3.0
#3 0xb3aa0059 in PLATFORM::CThread::ThreadHandler(void*) () from /usr/lib/i386-linux-gnu/libcec.so.3.0
#4 0xb7368f70 in start_thread (arg=0xb3a76b40) at pthread_create.c:312
#5 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 4 (Thread 0xb42ffb40 (LWP 2194)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb60c7c8b in poll () at ../sysdeps/unix/syscall-template.S:81
#2 0xb67ccbbd in ?? () from /usr/lib/i386-linux-gnu/libpulse.so.0
#3 0xb67bb4ee in pa_mainloop_poll () from /usr/lib/i386-linux-gnu/libpulse.so.0
#4 0xb67bbd1d in pa_mainloop_iterate () from /usr/lib/i386-linux-gnu/libpulse.so.0
#5 0xb67bbdf4 in pa_mainloop_run () from /usr/lib/i386-linux-gnu/libpulse.so.0
#6 0xb67ccb5c in ?? () from /usr/lib/i386-linux-gnu/libpulse.so.0
#7 0xb5c574dd in ?? () from /usr/lib/i386-linux-gnu/pulseaudio/libpulsecommon-4.0.so
#8 0xb7368f70 in start_thread (arg=0xb42ffb40) at pthread_create.c:312
#9 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 3 (Thread 0xb4cc6b40 (LWP 2193)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb736cd1d in pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:145
#2 0xb5c5685b in pa_cond_wait () from /usr/lib/i386-linux-gnu/pulseaudio/libpulsecommon-4.0.so
#3 0xb67cd34e in pa_threaded_mainloop_wait () from /usr/lib/i386-linux-gnu/libpulse.so.0
#4 0x0863f746 in CAESinkPULSE::AddPackets(unsigned char**, unsigned int, unsigned int) ()
#5 0x08620c97 in ActiveAE::CActiveAESink::OutputSamples(ActiveAE::CSampleBuffer*) ()
#6 0x086220c0 in ActiveAE::CActiveAESink::StateMachine(int, Actor:Tonguerotocol*, Actor::Message*) ()
#7 0x08622b42 in ActiveAE::CActiveAESink:Tonguerocess() ()
#8 0x097aef85 in CThread::Action() ()
#9 0x097af69d in CThread:ConfusedtaticThread(void*) ()
#10 0xb7368f70 in start_thread (arg=0xb4cc6b40) at pthread_create.c:312
#11 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 2 (Thread 0xb0cbeb40 (LWP 2192)):
#0 0xb7798d50 in __kernel_vsyscall ()
#1 0xb736d12d in pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_timedwait.S:245
#2 0x0861ccc0 in ActiveAE::CActiveAE:Tonguerocess() ()
#3 0x097aef85 in CThread::Action() ()
#4 0x097af69d in CThread:ConfusedtaticThread(void*) ()
#5 0xb7368f70 in start_thread (arg=0xb0cbeb40) at pthread_create.c:312
#6 0xb60d6bee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129

Thread 1 (Thread 0xb4cf8740 (LWP 2189)):
#0 0x00000000 in ?? ()
############# END STACK TRACE ###############

################# LOG FILE ##################

00:54:48 T:3033499456 NOTICE: special://profile/ is mapped to: special://masterprofile/
00:54:48 T:3033499456 NOTICE: -----------------------------------------------------------------------
00:54:48 T:3033499456 NOTICE: Starting Kodi (15.1 Git:d496682). Platform: Linux x86 32-bit
00:54:48 T:3033499456 NOTICE: Using Release Kodi x32 build
00:54:48 T:3033499456 NOTICE: Kodi compiled Aug 16 2015 by GCC 4.8.4 for Linux x86 32-bit version 3.13.11 (199947)
00:54:48 T:3033499456 NOTICE: Running on Ubuntu 14.04.2 LTS, kernel: Linux x86 32-bit version 3.16.0-38-generic
00:54:48 T:3033499456 NOTICE: FFmpeg statically linked, version: 2.6.4-kodi-2.6.4-Isengard
00:54:48 T:3033499456 NOTICE: Host CPU: Intel® Pentium® 4 CPU 2.80GHz, 1 core available
00:54:48 T:3033499456 NOTICE: special://xbmc/ is mapped to: /usr/share/kodi
00:54:48 T:3033499456 NOTICE: special://xbmcbin/ is mapped to: /usr/lib/kodi
00:54:48 T:3033499456 NOTICE: special://masterprofile/ is mapped to: /home/mikenkaren/.kodi/userdata
00:54:48 T:3033499456 NOTICE: special://home/ is mapped to: /home/mikenkaren/.kodi
00:54:48 T:3033499456 NOTICE: special://temp/ is mapped to: /home/mikenkaren/.kodi/temp
00:54:48 T:3033499456 NOTICE: The executable running is: /usr/lib/kodi/kodi.bin
00:54:48 T:3033499456 NOTICE: Local hostname: mikenkaren-Dimension-3000
00:54:48 T:3033499456 NOTICE: Log File is located: /home/mikenkaren/.kodi/temp/kodi.log
00:54:48 T:3033499456 NOTICE: -----------------------------------------------------------------------
00:54:48 T:3033499456 NOTICE: load settings...
00:54:48 T:3033499456 NOTICE: Found 1 Lists of Devices
00:54:48 T:3033499456 NOTICE: Enumerated PULSE devices:
00:54:48 T:3033499456 NOTICE: Device 1
00:54:48 T:3033499456 NOTICE: m_deviceName : Default
00:54:48 T:3033499456 NOTICE: m_displayName : Default
00:54:48 T:3033499456 NOTICE: m_displayNameExtra: Default Output Device (PULSEAUDIO)
00:54:48 T:3033499456 NOTICE: m_deviceType : AE_DEVTYPE_PCM
00:54:48 T:3033499456 NOTICE: m_channels : FL,FR
00:54:48 T:3033499456 NOTICE: m_sampleRates : 5512,8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,176400,192000,384000
00:54:48 T:3033499456 NOTICE: m_dataFormats : AE_FMT_U8,AE_FMT_S16NE,AE_FMT_S24NE3,AE_FMT_S24NE4,AE_FMT_S32NE,AE_FMT_FLOAT
00:54:48 T:3033499456 NOTICE: Device 2
00:54:48 T:3033499456 NOTICE: m_deviceName : alsa_output.pci-0000_00_1f.5.analog-stereo
00:54:48 T:3033499456 NOTICE: m_displayName : Built-in Audio Analog Stereo
00:54:48 T:3033499456 NOTICE: m_displayNameExtra: Analog Output / Amplifier (PULSEAUDIO)
00:54:48 T:3033499456 NOTICE: m_deviceType : AE_DEVTYPE_PCM
00:54:48 T:3033499456 NOTICE: m_channels : FL,FR
00:54:48 T:3033499456 NOTICE: m_sampleRates : 5512,8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,176400,192000,384000
00:54:48 T:3033499456 NOTICE: m_dataFormats : AE_FMT_U8,AE_FMT_S16NE,AE_FMT_S24NE3,AE_FMT_S24NE4,AE_FMT_S32NE,AE_FMT_FLOAT
00:54:49 T:3033499456 NOTICE: No settings file to load (special://xbmc/system/advancedsettings.xml)
00:54:49 T:3033499456 NOTICE: No settings file to load (special://masterprofile/advancedsettings.xml)
00:54:49 T:3033499456 NOTICE: Default DVD Player: dvdplayer
00:54:49 T:3033499456 NOTICE: Default Video Player: dvdplayer
00:54:49 T:3033499456 NOTICE: Default Audio Player: paplayer
00:54:49 T:3033499456 NOTICE: Disabled debug logging due to GUI setting. Level 0.
00:54:49 T:3033499456 NOTICE: Log level changed to "LOG_LEVEL_NORMAL"
00:54:49 T:3033499456 NOTICE: Loading player core factory settings from special://xbmc/system/playercorefactory.xml.
00:54:49 T:3033499456 NOTICE: Loaded playercorefactory configuration
00:54:49 T:3033499456 NOTICE: Loading player core factory settings from special://masterprofile/playercorefactory.xml.
00:54:49 T:3033499456 NOTICE: special://masterprofile/playercorefactory.xml does not exist. Skipping.
00:54:49 T:2966154048 NOTICE: Thread ActiveAE start, auto delete: false
00:54:49 T:3033295680 NOTICE: Thread AESink start, auto delete: false
00:54:49 T:3033295680 NOTICE: PulseAudio: Opened device Default in pcm mode with Buffersize 150 ms
00:54:49 T:3033499456 NOTICE: Running database version Addons19
00:54:50 T:3033499456 NOTICE: ADDONS: Using repository repository.xbmc.org
00:54:50 T:3005700928 NOTICE: Thread PeripBusCEC start, auto delete: false
00:54:50 T:2997308224 NOTICE: Thread PeripBusUSBUdev start, auto delete: false
00:54:50 T:2988915520 NOTICE: Thread RemoteControl start, auto delete: false
00:54:51 T:3033499456 NOTICE: Setup SDL
00:54:51 T:3033499456 NOTICE: Checking resolution 16
00:54:51 T:3033499456 ERROR: CWinSystemX11::XErrorHandler: BadAtom (invalid Atom parameter), type:0, serial:49, error_code:5, request_code:18 minor_code:0
00:54:51 T:3033499456 NOTICE: Using visual 0x20
00:54:51 T:3033499456 NOTICE: GL_VENDOR = Intel Open Source Technology Center
00:54:51 T:3033499456 NOTICE: GL_RENDERER = Mesa DRI Intel® 865G x86/MMX/SSE2
00:54:51 T:3033499456 NOTICE: GL_VERSION = 1.3 Mesa 10.1.3
00:54:51 T:3033499456 NOTICE: GL_SHADING_LANGUAGE_VERSION = 1.20
00:54:51 T:3033499456 NOTICE: GL_EXTENSIONS = GL_ARB_multisample GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_copy_texture GL_EXT_polygon_offset GL_EXT_subtexture GL_EXT_texture_object GL_EXT_vertex_array GL_EXT_compiled_vertex_array GL_EXT_texture GL_EXT_texture3D GL_IBM_rasterpos_clip GL_ARB_point_parameters GL_EXT_draw_range_elements GL_EXT_packed_pixels GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_separate_specular_color GL_EXT_texture_edge_clamp GL_SGIS_generate_mipmap GL_SGIS_texture_border_clamp GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_ARB_multitexture GL_IBM_multimode_draw_arrays GL_IBM_texture_mirrored_repeat GL_3DFX_texture_compression_FXT1 GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_transpose_matrix GL_EXT_blend_func_separate GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_secondary_color GL_EXT_texture_env_add GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_INGR_blend_func_separate GL_NV_blend_square GL_NV_light_max_exponent GL_NV_texgen_reflection GL_S3_s3tc GL_SUN_multi_draw_arrays GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_EXT_framebuffer_object GL_EXT_texture_compression_s3tc GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_MESA_window_pos GL_NV_packed_depth_stencil GL_NV_texture_rectangle GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_window_pos GL_EXT_texture_cube_map GL_APPLE_packed_pixels GL_APPLE_vertex_array_object GL_ARB_draw_buffers GL_ARB_shader_objects GL_ARB_vertex_program GL_ARB_vertex_shader GL_ATI_draw_buffers GL_EXT_stencil_wrap GL_MESA_pack_invert GL_MESA_ycbcr_texture GL_ARB_half_float_pixel GL_ARB_point_sprite GL_ARB_shading_language_100 GL_ARB_sync GL_ARB_vertex_buffer_object GL_ATI_blend_equation_separate GL_EXT_blend_equation_separate GL_OES_read_format GL_ARB_pixel_buffer_object GL_ARB_texture_rectangle GL_EXT_pixel_buffer_object GL_EXT_texture_compression_dxt1 GL_EXT_texture_rectangle GL_ARB_framebuffer_object GL_EXT_framebuffer_blit GL_EXT_packed_depth_stencil GL_APPLE_object_purgeable GL_ARB_vertex_array_object GL_EXT_gpu_program_parameters GL_OES_EGL_image GL_ARB_copy_buffer GL_ARB_map_buffer_range GL_EXT_separate_shader_objects GL_ARB_debug_output GL_ARB_draw_elements_base_vertex GL_ARB_explicit_attrib_location GL_ARB_provoking_vertex GL_ARB_sampler_objects GL_EXT_provoking_vertex GL_ARB_get_program_binary GL_ARB_robustness GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_ARB_internalformat_query GL_ARB_map_buffer_alignment GL_ARB_texture_storage GL_AMD_shader_trinary_minmax GL_ARB_clear_buffer_object GL_ARB_invalidate_subdata GL_ARB_vertex_attrib_binding GL_KHR_debug
00:54:51 T:3033499456 ERROR: ResetRenderSystem() GL_MAX_TEXTURE_IMAGE_UNITS_ARB returned error 1280
00:54:52 T:3033499456 NOTICE: Running database version Addons19
00:54:52 T:3033499456 NOTICE: Running database version ViewModes6
00:54:52 T:3033499456 NOTICE: Running database version Textures13
00:54:52 T:3033499456 NOTICE: Running database version MyMusic52
00:54:52 T:3033499456 NOTICE: Running database version MyVideos93
00:54:52 T:3033499456 NOTICE: Running database version TV29
00:54:52 T:3033499456 NOTICE: Running database version Epg10
00:54:52 T:3033499456 NOTICE: start dvd mediatype detection
00:54:52 T:3024481088 NOTICE: Thread DetectDVDMedia start, auto delete: false
00:54:53 T:3033499456 WARNING: JSONRPC: Could not parse type "PVR.Details.Channel"
00:54:53 T:3033499456 WARNING: JSONRPC: Could not parse type "PVR.Details.ChannelGroup.Extended"
00:54:53 T:3033499456 WARNING: JSONRPC: Could not parse type "GUI.Property.Value"
00:54:53 T:3033499456 WARNING: JSONRPC: Could not parse type "Setting.Details.SettingList"
00:54:53 T:2857896768 NOTICE: Thread LanguageInvoker start, auto delete: false
00:54:53 T:3033499456 NOTICE: initialize done
00:54:53 T:3033499456 NOTICE: Running the application...


############### END LOG FILE ################

############ END Kodi CRASH LOG #############
Your old GPU needs special handling, which we don't support ... provide your Debug Log - if my google skill was correct you have an old intel gpu without proper GL support, which needs an overwrite.
I can't get into kodi at all to get to the debugging feature.
enable it via advancedsettings.xml: http://kodi.wiki/view/Log_file/Advanced#...ttings.xml
GL_MAX_TEXTURE_IMAGE_UNITS_ARB returned error 1280


MESA_GL_VERSION_OVERRIDE=3.0 kodi
This is all new to me...but after a few failed attempts I got the debug log and posted here.

Thanks for your patience, I know it drives people nuts when they have to deal with a novice.
Open a terminal and write:

Code:
MESA_GL_VERSION_OVERRIDE=3.0 kodi
That worked! Thanks

Now where would I write that in that code in the kodi standalone script? I can pull up the script, just not sure where to enter it.

Here is the file. I know I need to add the line in here somewhere, just not sure where.

#!/bin/sh

# Copyright © 2009-2013 Team XBMC
# http://xbmc.org
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with XBMC; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# http://www.gnu.org/copyleft/gpl.html

APP=Kodi
prefix="/usr"
exec_prefix="/usr"
bindir="${exec_prefix}/bin"
bin_name=kodi
APP="${bindir}/${bin_name} --standalone $@"

PULSE_START="$(which start-pulseaudio-x11)"
if [ -n "$PULSE_START" ]; then
$PULSE_START
else
PULSE_SESSION="$(which pulse-session)"
if [ -n "$PULSE_SESSION" ]; then
XBMC="$PULSE_SESSION $XBMC"
fi
fi

LOOP=1
CRASHCOUNT=0
LASTSUCCESSFULSTART=$(date +%s)

while [ $(( $LOOP )) = "1" ]
do
$APP
RET=$?
NOW=$(date +%s)
if [ $(( ($RET >= 64 && $RET <=66) || $RET == 0 )) = "1" ]; then # clean exit
LOOP=0
else # crash
DIFF=$((NOW-LASTSUCCESSFULSTART))
if [ $(($DIFF > 60 )) = "1" ]; then # Not on startup, ignore
LASTSUCESSFULSTART=$NOW
CRASHCOUNT=0
else # at startup, look sharp
CRASHCOUNT=$((CRASHCOUNT+1))
if [ $(($CRASHCOUNT >= 3)) = "1" ]; then # Too many, bail out
LOOP=0
echo "${APP} has exited uncleanly 3 times in the last ${DIFF} seconds."
echo "Something is probably wrong"
fi
fi
fi
done