diff --git a/configure.in b/configure.in index 9445409f..8d37378f 100644 --- a/configure.in +++ b/configure.in @@ -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 ======================= diff --git a/src/curl_handle.cpp b/src/curl_handle.cpp index 2414fc1b..46f4225f 100644 --- a/src/curl_handle.cpp +++ b/src/curl_handle.cpp @@ -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; } diff --git a/src/curl_handle.h b/src/curl_handle.h index 9edee326..8a12eb8e 100644 --- a/src/curl_handle.h +++ b/src/curl_handle.h @@ -27,10 +27,6 @@ #ifdef HAVE_CURL_CURL_H -#ifdef HAVE_PTHREAD_H -# include -#endif // HAVE_PTHREAD_H - #include #include "curl/curl.h" diff --git a/src/global.h b/src/global.h index d912d6d4..e62e0cb0 100644 --- a/src/global.h +++ b/src/global.h @@ -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; diff --git a/src/helpers.cpp b/src/helpers.cpp index e295a84b..1408610f 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -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 diff --git a/src/info.cpp b/src/info.cpp index d47efa49..587dd899 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -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 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(*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 } } } diff --git a/src/info.h b/src/info.h index 0113ebe5..1b1ca6c5 100644 --- a/src/info.h +++ b/src/info.h @@ -40,9 +40,9 @@ class Info : public Screen virtual std::basic_string 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 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 }; diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 72119b67..582b9756 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -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 diff --git a/src/lyrics.h b/src/lyrics.h index 9b591fb9..3e895244 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -61,15 +61,11 @@ class Lyrics : public Screen # 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 diff --git a/src/ncmpcpp.h b/src/ncmpcpp.h index 82e66eb7..e5653cac 100644 --- a/src/ncmpcpp.h +++ b/src/ncmpcpp.h @@ -25,12 +25,6 @@ #include "menu.h" #include "scrollpad.h" -#ifdef HAVE_PTHREAD_H -# include -#else -# define pthread_exit(x) return (x) -#endif // HAVE_PTHREAD_H - using namespace NCurses; typedef std::pair string_pair;