Permalink
Browse files

Merge commit '1c786d7d7d42d671a4dc8b5450acf189af4d888c'

  • Loading branch information...
margro committed Jun 10, 2012
2 parents 15cb6a6 + 1c786d7 commit 78b381b959447fe78a5691ec18c291b42184e1ee
View
@@ -125,6 +125,8 @@ libplist_not_found="== Could not find libplist. AirPlay support disabled. =="
libplist_disabled="== AirPlay support disabled. =="
alsa_not_found="== Could not find ALSA. ALSA support disabled. =="
dbus_not_found="== Could not find DBUS. DBUS support disabled. =="
+libcap_disabled="== Capabilities detection support disabled. =="
+libcap_not_found="== Could not find libcap. Capabilities detection support disabled. =="
libudev_not_found="== Could not find libudev. Will use polling to check for device changes. =="
libudev_disabled="== udev support disabled. Will use polling to check for device changes. =="
@@ -435,6 +437,12 @@ AC_ARG_ENABLE([vorbisenc],
[use_libvorbisenc=$enableval],
[use_libvorbisenc=auto])
+AC_ARG_ENABLE([libcap],
+ [AS_HELP_STRING([--enable-libcap],
+ [enable libcap support (default is auto)])],
+ [use_libcap=$enableval],
+ [use_libcap=auto])
+
### External libraries options
AC_ARG_ENABLE([external-libraries],
[AS_HELP_STRING([--enable-external-libraries],
@@ -1256,6 +1264,34 @@ else
AC_MSG_NOTICE($libcec_disabled)
fi
+# libcap
+if test "$use_libcap" = "auto"; then
+ if echo "$ARCH" | grep -q "linux" ; then
+ use_libcap="yes"
+ else
+ use_libcap="no"
+ fi
+fi
+
+if test "$use_libcap" != "no"; then
+ AC_CHECK_HEADERS([sys/capability.h],,
+ [if test "$use_libcap" = "yes"; then
+ AC_MSG_ERROR($libcap_not_found)
+ elif test "$use_libcap" != "no"; then
+ AC_MSG_NOTICE($libcap_not_found)
+ use_libcap="no"
+ fi
+ ])
+ if test "$use_libcap" != "no"; then
+ AC_CHECK_LIB([cap], main, LIBS="$LIBS -lcap", use_libcap=no)
+ fi
+ if test "$use_libcap" != "no"; then
+ AC_DEFINE([HAVE_LIBCAP], [1], [Whether to use libcap library.])
+ fi
+else
+ AC_MSG_NOTICE($libcap_disabled)
+fi
+
### External libraries checks
# External FFmpeg
View
@@ -57,7 +57,7 @@ Build-Depends: autoconf, automake, autopoint, autotools-dev, cmake, curl,
libswscale-dev, libtinyxml-dev, libtool, libudev-dev, libusb-dev, libva-dev,
libvdpau-dev, libvorbis-dev, libxinerama-dev, libxmu-dev, libxrandr-dev,
libxt-dev, libyajl-dev, lsb-release, nasm [!amd64], python-dev,
- python-support, unzip, yasm, zip, zlib1g-dev
+ python-support, unzip, yasm, zip, zlib1g-dev, libcap-dev
*** For developers and anyone else who compiles frequently it is recommended to
use ccache
View
@@ -44,7 +44,7 @@ Two methods exist to install the required Ubuntu packages:
For Ubuntu (all versions >= 7.04):
- # sudo apt-get install git-core build-essential gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound2-dev python-sqlite libglew-dev libcurl3 libcurl4-gnutls-dev libxrandr-dev libxrender-dev libmad0-dev libogg-dev libvorbisenc2 libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libhal-dev libhal-storage-dev libjasper-dev libfontconfig-dev libbz2-dev libboost-dev libenca-dev libxt-dev libxmu-dev libpng-dev libjpeg-dev libpulse-dev mesa-utils libcdio-dev libsamplerate-dev libmpeg3-dev libflac-dev libiso9660-dev libass-dev libssl-dev fp-compiler gdc libmpeg2-4-dev libmicrohttpd-dev libmodplug-dev libssh-dev gettext cvs python-dev libyajl-dev libboost-thread-dev libplist-dev libusb-dev libudev-dev libtinyxml-dev
+ # sudo apt-get install git-core build-essential gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound2-dev python-sqlite libglew-dev libcurl3 libcurl4-gnutls-dev libxrandr-dev libxrender-dev libmad0-dev libogg-dev libvorbisenc2 libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libhal-dev libhal-storage-dev libjasper-dev libfontconfig-dev libbz2-dev libboost-dev libenca-dev libxt-dev libxmu-dev libpng-dev libjpeg-dev libpulse-dev mesa-utils libcdio-dev libsamplerate-dev libmpeg3-dev libflac-dev libiso9660-dev libass-dev libssl-dev fp-compiler gdc libmpeg2-4-dev libmicrohttpd-dev libmodplug-dev libssh-dev gettext cvs python-dev libyajl-dev libboost-thread-dev libplist-dev libusb-dev libudev-dev libtinyxml-dev libcap-dev
For >= 10.10:
# sudo apt-get install autopoint libltdl-dev
View
@@ -1359,9 +1359,9 @@ bool CApplication::StartWebServer()
int webPort = atoi(g_guiSettings.GetString("services.webserverport"));
CLog::Log(LOGNOTICE, "Webserver: Starting...");
#ifdef _LINUX
- if (webPort < 1024 && geteuid() != 0)
+ if (webPort < 1024 && !CUtil::CanBindPrivileged())
{
- CLog::Log(LOGERROR, "Cannot start Web Server as port is smaller than 1024 and user is not root");
+ CLog::Log(LOGERROR, "Cannot start Web Server on port %i, no permission to bind to ports below 1024", webPort);
return false;
}
#endif
@@ -4023,15 +4023,8 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart)
#endif
}
m_bPlaybackStarting = false;
- if(bResult)
- {
- // we must have started, otherwise player might send this later
- if(IsPlaying())
- OnPlayBackStarted();
- else
- OnPlayBackEnded();
- }
- else
+
+ if (!bResult)
{
// we send this if it isn't playlistplayer that is doing this
int next = g_playlistPlayer.GetNextSong();
@@ -5424,13 +5417,6 @@ float CApplication::GetPercentage() const
{
if (IsPlaying() && m_pPlayer)
{
- if (IsPlayingAudio() && m_itemCurrentFile->HasMusicInfoTag())
- {
- const CMusicInfoTag& tag = *m_itemCurrentFile->GetMusicInfoTag();
- if (tag.GetDuration() > 0)
- return (float)(GetTime() / tag.GetDuration() * 100);
- }
-
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
return (float)(GetTime() / GetTotalTime() * 100);
else
View
@@ -103,7 +103,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
{
if (!ReadNextLine(strLine))
break;
- if (strLine.Left(7) == "INDEX 0")
+ if (strLine.Left(8) == "INDEX 01")
{
if (bCurrentFileChanged)
{
View
@@ -95,6 +95,9 @@
#include "cores/dvdplayer/DVDSubtitles/DVDSubtitleStream.h"
#include "windowing/WindowingFactory.h"
#include "video/VideoInfoTag.h"
+#ifdef HAVE_LIBCAP
+ #include <sys/capability.h>
+#endif
using namespace std;
using namespace XFILE;
@@ -2598,3 +2601,39 @@ bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdStr
return false;
}
+bool CUtil::CanBindPrivileged()
+{
+#ifdef _LINUX
+
+ if (geteuid() == 0)
+ return true; //root user can always bind to privileged ports
+
+#ifdef HAVE_LIBCAP
+
+ //check if CAP_NET_BIND_SERVICE is enabled, this allows non-root users to bind to privileged ports
+ bool canbind = false;
+ cap_t capabilities = cap_get_proc();
+ if (capabilities)
+ {
+ cap_flag_value_t value;
+ if (cap_get_flag(capabilities, CAP_NET_BIND_SERVICE, CAP_EFFECTIVE, &value) == 0)
+ canbind = value;
+
+ cap_free(capabilities);
+ }
+
+ return canbind;
+
+#else //HAVE_LIBCAP
+
+ return false;
+
+#endif //HAVE_LIBCAP
+
+#else //_LINUX
+
+ return true;
+
+#endif //_LINUX
+}
+
View
@@ -192,6 +192,8 @@ class CUtil
#endif
static CStdString ResolveExecutablePath();
static CStdString GetFrameworksPath(bool forPython = false);
+
+ static bool CanBindPrivileged();
};
@@ -241,15 +241,12 @@ void PAPlayer::UpdateCrossFadingTime(const CFileItem& file)
if ((m_crossFadeTime = g_guiSettings.GetInt("musicplayer.crossfade") * 1000))
{
if (
- m_streams.size() == 0 ||
- (
- file.HasMusicInfoTag() && !g_guiSettings.GetBool("musicplayer.crossfadealbumtracks") &&
- m_FileItem->HasMusicInfoTag() &&
- (m_FileItem->GetMusicInfoTag()->GetAlbum() != "") &&
- (m_FileItem->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) &&
- (m_FileItem->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) &&
- (m_FileItem->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1)
- )
+ file.HasMusicInfoTag() && !g_guiSettings.GetBool("musicplayer.crossfadealbumtracks") &&
+ m_FileItem->HasMusicInfoTag() &&
+ (m_FileItem->GetMusicInfoTag()->GetAlbum() != "") &&
+ (m_FileItem->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) &&
+ (m_FileItem->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) &&
+ (m_FileItem->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1)
)
{
//do not crossfade when playing consecutive albumtracks
@@ -316,16 +313,20 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */)
si->m_fadeOutTriggered = false;
si->m_isSlaved = false;
- if (si->m_decoder.TotalTime() < TIME_TO_CACHE_NEXT_FILE + m_crossFadeTime)
- si->m_prepareNextAtFrame = 0;
- else
- si->m_prepareNextAtFrame = (int)((si->m_decoder.TotalTime() - TIME_TO_CACHE_NEXT_FILE - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+ int64_t streamTotalTime = si->m_decoder.TotalTime();
+ if (si->m_endOffset)
+ streamTotalTime = si->m_endOffset - si->m_startOffset;
+
+ if (streamTotalTime >= TIME_TO_CACHE_NEXT_FILE + m_crossFadeTime)
+ si->m_prepareNextAtFrame = (int)((streamTotalTime - TIME_TO_CACHE_NEXT_FILE - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+
si->m_prepareTriggered = false;
- if (si->m_decoder.TotalTime() < m_crossFadeTime)
- si->m_playNextAtFrame = (int)((si->m_decoder.TotalTime() / 2) * si->m_sampleRate / 1000.0f);
+ if (streamTotalTime < m_crossFadeTime)
+ si->m_playNextAtFrame = (int)((streamTotalTime / 2) * si->m_sampleRate / 1000.0f);
else
- si->m_playNextAtFrame = (int)((si->m_decoder.TotalTime() - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+ si->m_playNextAtFrame = (int)((streamTotalTime - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+
si->m_playNextTriggered = false;
PrepareStream(si);
@@ -463,7 +464,7 @@ inline void PAPlayer::ProcessStreams(double &delay, double &buffer)
if (!m_currentStream && !si->m_started)
m_currentStream = si;
/* if the stream is finishing */
- if ((si->m_fadeOutTriggered && si->m_stream && !si->m_stream->IsFading()) || !ProcessStream(si, delay, buffer))
+ if ((si->m_playNextTriggered && si->m_stream && !si->m_stream->IsFading()) || !ProcessStream(si, delay, buffer))
{
if (!si->m_prepareTriggered)
{
@@ -523,7 +524,10 @@ inline void PAPlayer::ProcessStreams(double &delay, double &buffer)
if (!m_isFinished)
{
if (m_crossFadeTime)
+ {
si->m_stream->FadeVolume(1.0f, 0.0f, m_crossFadeTime);
+ si->m_fadeOutTriggered = true;
+ }
m_currentStream = NULL;
/* unregister the audio callback */
@@ -556,26 +560,27 @@ inline bool PAPlayer::ProcessStream(StreamInfo *si, double &delay, double &buffe
/* see if it is time yet to FF/RW or a direct seek */
if (!si->m_playNextTriggered && ((m_playbackSpeed != 1 && si->m_framesSent >= si->m_seekNextAtFrame) || si->m_seekFrame > -1))
{
+ int64_t time = (int64_t)0;
/* if its a direct seek */
if (si->m_seekFrame > -1)
{
- si->m_framesSent = si->m_seekFrame;
+ time = (int64_t)((float)si->m_seekFrame / (float)si->m_sampleRate * 1000.0f);
+ si->m_framesSent = (int)(si->m_seekFrame - ((float)si->m_startOffset * (float)si->m_sampleRate) / 1000.0f);
si->m_seekFrame = -1;
}
/* if its FF/RW */
else
{
si->m_framesSent += si->m_sampleRate * (m_playbackSpeed - 1);
si->m_seekNextAtFrame = si->m_framesSent + si->m_sampleRate / 2;
+ time = (int64_t)(((float)si->m_framesSent / (float)si->m_sampleRate * 1000.0f) + (float)si->m_startOffset);
}
- int64_t time = (int64_t)(si->m_startOffset + ((float)si->m_framesSent / (float)si->m_sampleRate * 1000.0f));
-
/* if we are seeking back before the start of the track start normal playback */
if (time < si->m_startOffset || si->m_framesSent < 0)
{
time = si->m_startOffset;
- si->m_framesSent = 0;
+ si->m_framesSent = (int)(si->m_startOffset * si->m_sampleRate / 1000);
si->m_seekNextAtFrame = 0;
ToFFRW(1);
}
@@ -586,7 +591,8 @@ inline bool PAPlayer::ProcessStream(StreamInfo *si, double &delay, double &buffe
int status = si->m_decoder.GetStatus();
if (status == STATUS_ENDED ||
status == STATUS_NO_FILE ||
- si->m_decoder.ReadSamples(PACKET_SIZE) == RET_ERROR)
+ si->m_decoder.ReadSamples(PACKET_SIZE) == RET_ERROR ||
+ ((si->m_endOffset) && (si->m_framesSent / si->m_sampleRate >= (si->m_endOffset - si->m_startOffset) / 1000)))
{
CLog::Log(LOGINFO, "PAPlayer::ProcessStream - Stream Finished");
return false;
@@ -702,7 +708,7 @@ int64_t PAPlayer::GetTime()
if (!m_currentStream)
return 0;
- double time = (double)m_currentStream->m_framesSent / (double)m_currentStream->m_sampleRate;
+ double time = ((double)m_currentStream->m_framesSent / (double)m_currentStream->m_sampleRate);
if (m_currentStream->m_stream)
time -= m_currentStream->m_stream->GetDelay();
@@ -812,13 +818,13 @@ void PAPlayer::SeekTime(int64_t iTime /*=0*/)
return;
int seekOffset = (int)(iTime - GetTime());
- if (m_currentStream->m_startOffset)
- iTime += m_currentStream->m_startOffset;
+ /*if (m_currentStream->m_startOffset)
+ iTime += m_currentStream->m_startOffset;*/
if (m_playbackSpeed != 1)
ToFFRW(1);
- m_currentStream->m_seekFrame = (int)(m_currentStream->m_sampleRate * (iTime / 1000));
+ m_currentStream->m_seekFrame = (int)((float)m_currentStream->m_sampleRate * ((float)iTime + (float)m_currentStream->m_startOffset) / 1000.0f);
m_callback.OnPlayBackSeek((int)iTime, seekOffset);
}
@@ -52,6 +52,7 @@
#if defined(TARGET_DARWIN)
#include "osx/DarwinUtils.h"
#endif
+#include "Util.h"
using namespace std;
using namespace ADDON;
@@ -798,11 +799,7 @@ void CGUISettings::Initialize()
#ifdef HAS_WEB_SERVER
CSettingsCategory* srvWeb = AddCategory(6, "webserver", 33101);
AddBool(srvWeb, "services.webserver", 263, false);
-#ifdef _LINUX
- AddString(srvWeb,"services.webserverport", 730, (geteuid()==0)?"80":"8080", EDIT_CONTROL_NUMBER_INPUT, false, 730);
-#else
- AddString(srvWeb,"services.webserverport", 730, "80", EDIT_CONTROL_NUMBER_INPUT, false, 730);
-#endif
+ AddString(srvWeb,"services.webserverport", 730, CUtil::CanBindPrivileged()?"80":"8080", EDIT_CONTROL_NUMBER_INPUT, false, 730);
AddString(srvWeb,"services.webserverusername",1048, "xbmc", EDIT_CONTROL_INPUT);
AddString(srvWeb,"services.webserverpassword",733, "", EDIT_CONTROL_HIDDEN_INPUT, true, 733);
AddDefaultAddon(srvWeb, "services.webskin",199, DEFAULT_WEB_INTERFACE, ADDON_WEB_INTERFACE);
@@ -2895,7 +2895,7 @@ void CGUIWindowSettingsCategory::ValidatePortNumber(CBaseSettingControl* pSettin
// check that it's a valid port
int port = atoi(pSetting->GetData().c_str());
#ifdef _LINUX
- if (listening && geteuid() != 0 && (port < 1024 || port > 65535))
+ if (listening && !CUtil::CanBindPrivileged() && (port < 1024 || port > 65535))
{
CGUIDialogOK::ShowAndGetInput(257, 850, 852, -1);
pSetting->SetData(userPort.c_str());

0 comments on commit 78b381b

Please sign in to comment.