remove optional pthread support - it's mandatory now

This commit is contained in:
Andrzej Rybczak
2010-08-09 11:57:58 +02:00
parent daad444f3c
commit 7f2ea9dc8f
10 changed files with 26 additions and 69 deletions

View File

@@ -17,7 +17,6 @@ AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the
AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto])
AC_ARG_WITH(iconv, AS_HELP_STRING([--with-iconv], [Enable iconv support (Note: if you use utf-8 system wide, you can disable this) @<:@default=auto@:>@]), [iconv=$withval], [iconv=auto])
AC_ARG_WITH(pdcurses, AS_HELP_STRING([--with-pdcurses[=LIBNAME]], [Link against pdcurses instead of ncurses @<:@default=XCurses@:>@]), [pdcurses=$withval], [pdcurses=no])
AC_ARG_WITH(threads, AS_HELP_STRING([--with-threads], [Enable threading support using posix threads @<:@default=auto@:>@]), [threads=$withval], [threads=auto])
AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto])
if test "$outputs" = "yes"; then
@@ -71,6 +70,15 @@ PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.1], [
AC_MSG_ERROR([libmpdclient >= 2.1 is required!])
)
dnl ========================
dnl = checking for pthread =
dnl ========================
AC_CHECK_HEADERS([pthread.h],
AC_CHECK_LIB(pthread, pthread_create, LDFLAGS="$LDFLAGS -lpthread",
AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
),
)
dnl ======================
dnl = checking for iconv =
dnl ======================
@@ -157,17 +165,10 @@ if test "$visualizer" = "yes" ; then
AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
fi
dnl =================================
dnl = checking for curl and pthread =
dnl =================================
dnl =====================
dnl = checking for curl =
dnl =====================
if test "$curl" != "no" ; then
if test "$threads" != "no" ; then
AC_CHECK_HEADERS([pthread.h], AC_CHECK_LIB(pthread, pthread_create, LDFLAGS="$LDFLAGS -lpthread",
if test "$threads" = "yes" ; then
AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
fi
), )
fi
AC_PATH_PROG(CURL_CONFIG, curl-config)
if test "$CURL_CONFIG" != "" ; then
CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
@@ -190,6 +191,7 @@ if test "$curl" != "no" ; then
fi
fi
dnl =======================
dnl = checking for taglib =
dnl =======================

View File

@@ -36,10 +36,8 @@ namespace
CURLcode Curl::perform(const std::string &URL, std::string &data, unsigned timeout)
{
# ifdef HAVE_PTHREAD_H
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&lock);
# endif
CURLcode result;
CURL *c = curl_easy_init();
curl_easy_setopt(c, CURLOPT_URL, URL.c_str());
@@ -49,9 +47,7 @@ CURLcode Curl::perform(const std::string &URL, std::string &data, unsigned timeo
curl_easy_setopt(c, CURLOPT_NOSIGNAL, 1);
result = curl_easy_perform(c);
curl_easy_cleanup(c);
# ifdef HAVE_PTHREAD_H
pthread_mutex_unlock(&lock);
# endif
return result;
}

View File

@@ -27,10 +27,6 @@
#ifdef HAVE_CURL_CURL_H
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#endif // HAVE_PTHREAD_H
#include <string>
#include "curl/curl.h"

View File

@@ -37,10 +37,6 @@ namespace Global
extern size_t MainStartY;
extern size_t MainHeight;
# ifdef HAVE_PTHREAD_H
extern pthread_mutex_t CurlLock;
# endif // HAVE_PTHREAD_H
extern bool BlockItemListUpdate;
extern bool UpdateStatusImmediately;

View File

@@ -105,9 +105,6 @@ void ParseArgv(int argc, char **argv)
# ifdef HAVE_TAGLIB_H
<< " taglib"
# endif
# ifdef HAVE_PTHREAD_H
<< " threads"
# endif
# ifdef _UTF8
<< " unicode"
# endif

View File

@@ -49,9 +49,7 @@ using Global::myOldScreen;
const std::string Info::Folder = home_path + HOME_FOLDER"artists";
bool Info::ArtistReady = 0;
#ifdef HAVE_PTHREAD_H
pthread_t *Info::Downloader = 0;
#endif // HAVE_PTHREAD_H
#endif // HAVE_CURL_CURL_H
@@ -91,7 +89,7 @@ std::basic_string<my_char_t> Info::Title()
return TO_WSTRING(itsTitle);
}
#if defined(HAVE_CURL_CURL_H) && defined(HAVE_PTHREAD_H)
#ifdef HAVE_CURL_CURL_H
void Info::Update()
{
if (!ArtistReady)
@@ -103,7 +101,7 @@ void Info::Update()
Downloader = 0;
ArtistReady = 0;
}
#endif // HAVE_CURL_CURL_H && HAVE_PTHREAD_H
#endif // HAVE_CURL_CURL_H
void Info::GetSong()
{
@@ -149,7 +147,6 @@ void Info::GetArtist()
if (!isInitialized)
Init();
# ifdef HAVE_PTHREAD_H
if (Downloader && !ArtistReady)
{
ShowMessage("Artist info is being downloaded...");
@@ -157,7 +154,6 @@ void Info::GetArtist()
}
else if (ArtistReady)
Update();
# endif // HAVE_PTHREAD_H
MPD::Song *s = myScreen->CurrentSong();
@@ -179,9 +175,7 @@ void Info::GetArtist()
w->Reset();
static_cast<Window &>(*w) << "Fetching artist info...";
w->Window::Refresh();
# ifdef HAVE_PTHREAD_H
if (!Downloader)
# endif // HAVE_PTHREAD_H
{
locale_to_utf(itsArtist);
@@ -219,13 +213,8 @@ void Info::GetArtist()
}
else
{
# ifdef HAVE_PTHREAD_H
Downloader = new pthread_t;
pthread_create(Downloader, 0, PrepareArtist, this);
# else
PrepareArtist(this);
w->Flush();
# endif // HAVE_PTHREAD_H
}
}
}

View File

@@ -40,9 +40,9 @@ class Info : public Screen<Scrollpad>
virtual std::basic_string<my_char_t> Title();
# if defined(HAVE_CURL_CURL_H) && defined(HAVE_PTHREAD_H)
# ifdef HAVE_CURL_CURL_H
virtual void Update();
# endif // HAVE_CURL_CURL_H && HAVE_PTHREAD_H
# endif // HAVE_CURL_CURL_H
virtual void EnterPressed() { }
virtual void SpacePressed() { }
@@ -74,9 +74,7 @@ class Info : public Screen<Scrollpad>
static const std::string Folder;
static bool ArtistReady;
# ifdef HAVE_PTHREAD_H
static pthread_t *Downloader;
# endif // HAVE_PTHREAD_H
# endif // HAVE_CURL_CURL_H
};

View File

@@ -63,9 +63,7 @@ bool Lyrics::Reload = 0;
#ifdef HAVE_CURL_CURL_H
bool Lyrics::Ready = 0;
#ifdef HAVE_PTHREAD_H
pthread_t *Lyrics::Downloader = 0;
#endif // HAVE_PTHREAD_H
#endif // HAVE_CURL_CURL_H
Lyrics *myLyrics = new Lyrics;
@@ -85,18 +83,16 @@ void Lyrics::Resize()
void Lyrics::Update()
{
# if defined(HAVE_CURL_CURL_H) && defined(HAVE_PTHREAD_H)
# ifdef HAVE_CURL_CURL_H
if (Ready)
Take();
# endif // HAVE_CURL_CURL_H && HAVE_PTHREAD_H
# ifdef HAVE_PTHREAD_H
if (Downloader)
{
w->Flush();
w->Refresh();
}
# endif
# endif // HAVE_CURL_CURL_H
if (Reload)
SwitchTo();
@@ -113,7 +109,7 @@ void Lyrics::SwitchTo()
if (!isInitialized)
Init();
# if defined(HAVE_CURL_CURL_H) && defined(HAVE_PTHREAD_H)
# ifdef HAVE_CURL_CURL_H
if (Downloader && !Ready)
{
ShowMessage("Lyrics are being downloaded...");
@@ -121,7 +117,7 @@ void Lyrics::SwitchTo()
}
else if (Ready)
Take();
# endif // HAVE_CURL_CURL_H && HAVE_PTHREAD_H
# endif // HAVE_CURL_CURL_H
const MPD::Song *s = Reload ? myPlaylist->NowPlayingSong() : myScreen->CurrentSong();
@@ -143,9 +139,9 @@ void Lyrics::SwitchTo()
Global::RedrawHeader = 1;
w->Clear();
w->Reset();
# ifdef HAVE_PTHREAD_H
# ifdef HAVE_CURL_CURL_H
if (!Downloader)
# endif // HAVE_PTHREAD_H
# endif // HAVE_CURL_CURL_H
{
std::string file = locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";
EscapeUnallowedChars(file);
@@ -176,12 +172,9 @@ void Lyrics::SwitchTo()
}
else
{
# if defined(HAVE_CURL_CURL_H) && defined(HAVE_PTHREAD_H)
# ifdef HAVE_CURL_CURL_H
Downloader = new pthread_t;
pthread_create(Downloader, 0, Get, this);
# elif defined(HAVE_CURL_CURL_H)
Get(this);
w->Flush();
# else
*w << "Local lyrics not found. As ncmpcpp has been compiled without curl support, you can put appropriate lyrics into " << Folder << " directory (file syntax is \"$ARTIST - $TITLE.txt\") or recompile ncmpcpp with curl support.";
w->Flush();
@@ -285,7 +278,7 @@ void Lyrics::FetchAgain()
}
}
#if defined(HAVE_CURL_CURL_H) && defined(HAVE_PTHREAD_H)
#ifdef HAVE_CURL_CURL_H
void Lyrics::Take()
{
if (!Ready)
@@ -297,5 +290,5 @@ void Lyrics::Take()
Downloader = 0;
Ready = 0;
}
#endif // HAVE_CURL_CURL_H && HAVE_PTHREAD_H
#endif // HAVE_CURL_CURL_H

View File

@@ -61,15 +61,11 @@ class Lyrics : public Screen<Scrollpad>
# ifdef HAVE_CURL_CURL_H
static void *Get(void *);
# ifdef HAVE_PTHREAD_H
void Take();
# endif // HAVE_PTHREAD_H
static bool Ready;
# ifdef HAVE_PTHREAD_H
static pthread_t *Downloader;
# endif // HAVE_PTHREAD_H
# endif // HAVE_CURL_CURL_H

View File

@@ -25,12 +25,6 @@
#include "menu.h"
#include "scrollpad.h"
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#else
# define pthread_exit(x) return (x)
#endif // HAVE_PTHREAD_H
using namespace NCurses;
typedef std::pair<std::string, std::string> string_pair;