remove optional pthread support - it's mandatory now
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
15
src/info.cpp
15
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<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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user