improvements for pthread related stuff
This commit is contained in:
@@ -37,6 +37,8 @@ const string lyrics_folder = home_folder + "/" + ".lyrics";
|
||||
#ifdef HAVE_CURL_CURL_H
|
||||
extern pthread_t lyrics_downloader;
|
||||
extern pthread_t artist_info_downloader;
|
||||
extern bool lyrics_ready;
|
||||
extern bool artist_info_ready;
|
||||
pthread_mutex_t curl = PTHREAD_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
|
||||
@@ -97,10 +99,7 @@ void * GetArtistInfo(void *ptr)
|
||||
first = 0;
|
||||
}
|
||||
input.close();
|
||||
sInfo->Flush();
|
||||
if (wCurrent == sInfo)
|
||||
sInfo->Refresh();
|
||||
artist_info_downloader = 0;
|
||||
artist_info_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
@@ -125,10 +124,7 @@ void * GetArtistInfo(void *ptr)
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
*sInfo << "Error while fetching artist's info: " << curl_easy_strerror(code);
|
||||
sInfo->Flush();
|
||||
if (wCurrent == sInfo)
|
||||
sInfo->Refresh();
|
||||
artist_info_downloader = 0;
|
||||
artist_info_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
@@ -142,10 +138,7 @@ void * GetArtistInfo(void *ptr)
|
||||
{
|
||||
EscapeHtml(result);
|
||||
*sInfo << "Last.fm returned an error message: " << result;
|
||||
sInfo->Flush();
|
||||
if (wCurrent == sInfo)
|
||||
sInfo->Refresh();
|
||||
artist_info_downloader = 0;
|
||||
artist_info_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
@@ -240,10 +233,7 @@ void * GetArtistInfo(void *ptr)
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
sInfo->Flush();
|
||||
if (wCurrent == sInfo)
|
||||
sInfo->Refresh();
|
||||
artist_info_downloader = 0;
|
||||
artist_info_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
#endif // HAVE_CURL_CURL_H
|
||||
@@ -275,10 +265,7 @@ void *GetLyrics(void *song)
|
||||
first = 0;
|
||||
}
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
sLyrics->Flush();
|
||||
if (wCurrent == sLyrics)
|
||||
sLyrics->Refresh();
|
||||
lyrics_downloader = 0;
|
||||
lyrics_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
# endif
|
||||
}
|
||||
@@ -314,10 +301,7 @@ void *GetLyrics(void *song)
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
*sLyrics << "Error while fetching lyrics: " << curl_easy_strerror(code);
|
||||
sLyrics->Flush();
|
||||
if (wCurrent == sLyrics)
|
||||
sLyrics->Refresh();
|
||||
lyrics_downloader = 0;
|
||||
lyrics_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
@@ -330,10 +314,7 @@ void *GetLyrics(void *song)
|
||||
if (result == "Not found")
|
||||
{
|
||||
*sLyrics << result;
|
||||
sLyrics->Flush();
|
||||
if (wCurrent == sLyrics)
|
||||
sLyrics->Refresh();
|
||||
lyrics_downloader = 0;
|
||||
lyrics_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
@@ -354,17 +335,11 @@ void *GetLyrics(void *song)
|
||||
output << result;
|
||||
output.close();
|
||||
}
|
||||
sLyrics->Flush();
|
||||
if (wCurrent == sLyrics)
|
||||
sLyrics->Refresh();
|
||||
lyrics_downloader = 0;
|
||||
lyrics_ready = 1;
|
||||
pthread_exit(NULL);
|
||||
# else
|
||||
else
|
||||
*sLyrics << "Local lyrics not found. As ncmpcpp has been compiled without curl support, you can put appropriate lyrics into ~/.lyrics directory (file syntax is \"ARTIST - TITLE.txt\") or recompile ncmpcpp with curl support.";
|
||||
sLyrics->Flush();
|
||||
if (wCurrent == sLyrics)
|
||||
sLyrics->Refresh();
|
||||
return NULL;
|
||||
# endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user