本文整理汇总了C++中mpd::Song::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Song::empty方法的具体用法?C++ Song::empty怎么用?C++ Song::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpd::Song
的用法示例。
在下文中一共展示了Song::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DownloadInBackground
void Lyrics::DownloadInBackground(const MPD::Song &s)
{
if (s.empty() || s.getArtist().empty() || s.getTitle().empty())
return;
std::string filename = GenerateFilename(s);
std::ifstream f(filename.c_str());
if (f.is_open())
{
f.close();
return;
}
Statusbar::msg("Fetching lyrics for \"%s\"...", s.toString(Config.song_status_format_no_colors, Config.tags_separator).c_str());
MPD::Song *s_copy = new MPD::Song(s);
pthread_mutex_lock(&itsDIBLock);
if (itsWorkersNumber == itsMaxWorkersNumber)
itsToDownload.push(s_copy);
else
{
++itsWorkersNumber;
pthread_t t;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_create(&t, &attr, DownloadInBackgroundImpl, s_copy);
}
pthread_mutex_unlock(&itsDIBLock);
}
示例2: update
void Lyrics::update()
{
# ifdef HAVE_CURL_CURL_H
if (isReadyToTake)
Take();
if (isDownloadInProgress)
{
w.flush();
w.refresh();
}
# endif // HAVE_CURL_CURL_H
if (ReloadNP)
{
const MPD::Song s = myPlaylist->nowPlayingSong();
if (!s.empty() && !s.getArtist().empty() && !s.getTitle().empty())
{
drawHeader();
itsScrollBegin = 0;
itsSong = s;
Load();
}
ReloadNP = 0;
}
}
示例3: fetchInBackground
void Lyrics::fetchInBackground(const MPD::Song &s)
{
auto consumer = [this] {
std::string lyrics_file;
while (true)
{
MPD::Song qs;
{
auto queue = m_shared_queue.acquire();
assert(queue->first);
if (queue->second.empty())
{
queue->first = false;
break;
}
lyrics_file = lyricsFilename(queue->second.front());
if (!boost::filesystem::exists(lyrics_file))
qs = queue->second.front();
queue->second.pop();
}
if (!qs.empty())
{
auto lyrics = downloadLyrics(qs, nullptr, m_fetcher);
if (lyrics)
saveLyrics(lyrics_file, *lyrics);
}
}
};
auto queue = m_shared_queue.acquire();
queue->second.push(s);
// Start the consumer if it's not running.
if (!queue->first)
{
std::thread t(consumer);
t.detach();
queue->first = true;
}
}