lyrics: use pthread_t instead of pthread_t *
This commit is contained in:
@@ -72,7 +72,7 @@ void Lyrics::Update()
|
|||||||
if (ReadyToTake)
|
if (ReadyToTake)
|
||||||
Take();
|
Take();
|
||||||
|
|
||||||
if (Downloader)
|
if (DownloadInProgress)
|
||||||
{
|
{
|
||||||
w->Flush();
|
w->Flush();
|
||||||
w->Refresh();
|
w->Refresh();
|
||||||
@@ -174,7 +174,7 @@ void *Lyrics::Download()
|
|||||||
void Lyrics::Load()
|
void Lyrics::Load()
|
||||||
{
|
{
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
if (Downloader)
|
if (DownloadInProgress)
|
||||||
return;
|
return;
|
||||||
# endif // HAVE_CURL_CURL_H
|
# endif // HAVE_CURL_CURL_H
|
||||||
if (itsSong.GetArtist().empty() || itsSong.GetTitle().empty())
|
if (itsSong.GetArtist().empty() || itsSong.GetTitle().empty())
|
||||||
@@ -214,8 +214,8 @@ void Lyrics::Load()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
Downloader = new pthread_t;
|
pthread_create(&Downloader, 0, DownloadWrapper, this);
|
||||||
pthread_create(Downloader, 0, DownloadWrapper, this);
|
DownloadInProgress = 1;
|
||||||
# else
|
# 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 << "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();
|
w->Flush();
|
||||||
@@ -278,11 +278,10 @@ void Lyrics::Refetch()
|
|||||||
void Lyrics::Take()
|
void Lyrics::Take()
|
||||||
{
|
{
|
||||||
assert(ReadyToTake);
|
assert(ReadyToTake);
|
||||||
pthread_join(*Downloader, 0);
|
pthread_join(Downloader, 0);
|
||||||
w->Flush();
|
w->Flush();
|
||||||
w->Refresh();
|
w->Refresh();
|
||||||
delete Downloader;
|
DownloadInProgress = 0;
|
||||||
Downloader = 0;
|
|
||||||
ReadyToTake = 0;
|
ReadyToTake = 0;
|
||||||
}
|
}
|
||||||
#endif // HAVE_CURL_CURL_H
|
#endif // HAVE_CURL_CURL_H
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
public:
|
public:
|
||||||
Lyrics() : ReloadNP(0),
|
Lyrics() : ReloadNP(0),
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
ReadyToTake(0), Downloader(0),
|
ReadyToTake(0), DownloadInProgress(0),
|
||||||
# endif // HAVE_CURL_CURL_H
|
# endif // HAVE_CURL_CURL_H
|
||||||
itsScrollBegin(0) { }
|
itsScrollBegin(0) { }
|
||||||
|
|
||||||
@@ -63,7 +63,6 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
void Load();
|
void Load();
|
||||||
|
|
||||||
std::string itsFilenamePath;
|
std::string itsFilenamePath;
|
||||||
|
|
||||||
static const std::string Folder;
|
static const std::string Folder;
|
||||||
|
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
@@ -72,7 +71,8 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
|
|
||||||
void Take();
|
void Take();
|
||||||
bool ReadyToTake;
|
bool ReadyToTake;
|
||||||
pthread_t *Downloader;
|
bool DownloadInProgress;
|
||||||
|
pthread_t Downloader;
|
||||||
# endif // HAVE_CURL_CURL_H
|
# endif // HAVE_CURL_CURL_H
|
||||||
|
|
||||||
size_t itsScrollBegin;
|
size_t itsScrollBegin;
|
||||||
|
|||||||
Reference in New Issue
Block a user