various optimalizations, runs much faster now, especially with huge playlist

This commit is contained in:
unknown
2008-08-10 01:11:05 +02:00
parent 1cf51688ab
commit 237b98fab4
6 changed files with 119 additions and 68 deletions

View File

@@ -36,7 +36,6 @@ else
fi fi
AC_CHECK_HEADERS([ncurses.h], , AC_MSG_ERROR([missing ncurses.h header])) AC_CHECK_HEADERS([ncurses.h], , AC_MSG_ERROR([missing ncurses.h header]))
dnl ======================= dnl =======================
dnl = checking for libmpd = dnl = checking for libmpd =
dnl ======================= dnl =======================

View File

@@ -34,7 +34,7 @@ extern Menu *mSearcher;
extern Window *wFooter; extern Window *wFooter;
extern vector<Song> vPlaylist; extern vector<Song *> vPlaylist;
extern vector<MpdDataType> vFileType; extern vector<MpdDataType> vFileType;
extern vector<string> vNameList; extern vector<string> vNameList;
extern vector<long long> vHashList; extern vector<long long> vHashList;
@@ -557,9 +557,9 @@ void GetDirectory(string dir)
vNameList.push_back(s.GetFile()); vNameList.push_back(s.GetFile());
vHashList.push_back(s.GetHash()); vHashList.push_back(s.GetHash());
bool bold = 0; bool bold = 0;
for (vector<Song>::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++) for (vector<Song *>::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++)
{ {
if (it->GetHash() == s.GetHash()) if ((*it)->GetHash() == s.GetHash())
{ {
bold = 1; bold = 1;
break; break;

View File

@@ -55,7 +55,7 @@ char *MPD_PASSWORD = getenv("MPD_PASSWORD");
ncmpcpp_config Config; ncmpcpp_config Config;
vector<Song> vPlaylist; vector<Song *> vPlaylist;
vector<Song> vSearched; vector<Song> vSearched;
vector<MpdDataType> vFileType; vector<MpdDataType> vFileType;
vector<string> vNameList; vector<string> vNameList;
@@ -279,6 +279,7 @@ int main(int argc, char *argv[])
{ {
TraceMpdStatus(); TraceMpdStatus();
block_playlist_update = 0;
messages_allowed = 1; messages_allowed = 1;
if (Config.header_visibility) if (Config.header_visibility)
@@ -396,9 +397,9 @@ int main(int argc, char *argv[])
bool bold = 0; bool bold = 0;
for (vector<Song>::const_iterator it = vSongs.begin(); it != vSongs.end(); it++) for (vector<Song>::const_iterator it = vSongs.begin(); it != vSongs.end(); it++)
{ {
for (vector<Song>::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++) for (vector<Song *>::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++)
{ {
if (it->GetHash() == j->GetHash()) if (it->GetHash() == (*j)->GetHash())
{ {
bold = 1; bold = 1;
break; break;
@@ -544,7 +545,7 @@ int main(int argc, char *argv[])
case csPlaylist: case csPlaylist:
{ {
if (!mPlaylist->Empty()) if (!mPlaylist->Empty())
mpd_player_play_id(conn, vPlaylist[mPlaylist->GetChoice()-1].GetID()); mpd_player_play_id(conn, vPlaylist[mPlaylist->GetChoice()-1]->GetID());
break; break;
} }
case csBrowser: case csBrowser:
@@ -584,7 +585,7 @@ int main(int argc, char *argv[])
if (test) if (test)
{ {
mpd_playlist_add(conn, file); mpd_playlist_add(conn, file);
Song &s = vPlaylist.back(); Song &s = *vPlaylist.back();
mpd_player_play_id(conn, s.GetID()); mpd_player_play_id(conn, s.GetID());
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s)));
mBrowser->Refresh(); mBrowser->Refresh();
@@ -606,7 +607,7 @@ int main(int argc, char *argv[])
int new_id; int new_id;
try try
{ {
new_id = vPlaylist.at(mPlaylist->MaxChoice()-howmany).GetID(); new_id = vPlaylist.at(mPlaylist->MaxChoice()-howmany)->GetID();
} }
catch (std::out_of_range) catch (std::out_of_range)
{ {
@@ -866,9 +867,9 @@ int main(int argc, char *argv[])
for (vector<Song>::const_iterator it = vSearched.begin(); it != vSearched.end(); it++) for (vector<Song>::const_iterator it = vSearched.begin(); it != vSearched.end(); it++)
{ {
for (vector<Song>::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++) for (vector<Song *>::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++)
{ {
if (j->GetHash() == it->GetHash()) if ((*j)->GetHash() == it->GetHash())
{ {
bold = 1; bold = 1;
break; break;
@@ -902,7 +903,7 @@ int main(int argc, char *argv[])
if (test) if (test)
{ {
mpd_playlist_add(conn, file); mpd_playlist_add(conn, file);
Song &s = vPlaylist.back(); Song &s = *vPlaylist.back();
mpd_player_play_id(conn, s.GetID()); mpd_player_play_id(conn, s.GetID());
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s)));
mSearcher->Refresh(); mSearcher->Refresh();
@@ -939,7 +940,7 @@ int main(int argc, char *argv[])
int new_id; int new_id;
try try
{ {
new_id = vPlaylist.at(mPlaylist->MaxChoice()-howmany).GetID(); new_id = vPlaylist.at(mPlaylist->MaxChoice()-howmany)->GetID();
} }
catch (std::out_of_range) catch (std::out_of_range)
{ {
@@ -962,7 +963,7 @@ int main(int argc, char *argv[])
int new_id; int new_id;
try try
{ {
new_id = vPlaylist.at(mPlaylist->MaxChoice()-howmany).GetID(); new_id = vPlaylist.at(mPlaylist->MaxChoice()-howmany)->GetID();
} }
catch (std::out_of_range) catch (std::out_of_range)
{ {
@@ -979,7 +980,7 @@ int main(int argc, char *argv[])
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s)));
mpd_playlist_add(conn, (char *) s.GetFile().c_str()); mpd_playlist_add(conn, (char *) s.GetFile().c_str());
if (input == ENTER) if (input == ENTER)
mpd_player_play_id(conn, vPlaylist.back().GetID()); mpd_player_play_id(conn, vPlaylist.back()->GetID());
} }
if (input == KEY_SPACE) if (input == KEY_SPACE)
@@ -1005,17 +1006,16 @@ int main(int argc, char *argv[])
FOR_EACH_MPD_DATA(queue) FOR_EACH_MPD_DATA(queue)
mpd_playlist_queue_add(conn, queue->song->file); mpd_playlist_queue_add(conn, queue->song->file);
mpd_data_free(queue); mpd_data_free(queue);
mpd_playlist_queue_commit(conn);
ShowMessage("Added folder: " + getdir); ShowMessage("Added folder: " + getdir);
mpd_playlist_queue_commit(conn);
break; break;
} }
case MPD_DATA_TYPE_SONG: case MPD_DATA_TYPE_SONG:
{ {
if (mpd_playlist_add(conn, (char *) vNameList[ci].c_str()) == MPD_OK); mpd_playlist_queue_add(conn, (char *) vNameList[ci].c_str());
{ Song &s = *vPlaylist.back();
Song &s = vPlaylist.back();
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s)));
} mpd_playlist_queue_commit(conn);
break; break;
} }
case MPD_DATA_TYPE_PLAYLIST: case MPD_DATA_TYPE_PLAYLIST:
@@ -1036,21 +1036,13 @@ int main(int argc, char *argv[])
int id = mSearcher->GetChoice()-search_engine_static_option-1; int id = mSearcher->GetChoice()-search_engine_static_option-1;
if (id < 0) if (id < 0)
break; break;
try
{
if (mpd_playlist_add(conn, (char *)vSearched.at(id).GetFile().c_str()) == MPD_OK); mpd_playlist_queue_add(conn, (char *)vSearched[id].GetFile().c_str());
{ Song &s = vSearched[id];
Song &s = vPlaylist.back();
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s)));
mpd_playlist_queue_commit(conn);
mSearcher->Go(DOWN); mSearcher->Go(DOWN);
} }
}
catch (std::out_of_range)
{
ShowMessage("Error adding file!");
}
}
if (current_screen == csLibrary) if (current_screen == csLibrary)
goto Start_Point_For_KEY_SPACE; // sorry, but that's stupid to copy the same code here. goto Start_Point_For_KEY_SPACE; // sorry, but that's stupid to copy the same code here.
break; break;
@@ -1121,7 +1113,7 @@ int main(int argc, char *argv[])
mPlaylist->Timeout(50); mPlaylist->Timeout(50);
int id = mPlaylist->GetChoice()-1; int id = mPlaylist->GetChoice()-1;
while (!vPlaylist.empty() && input != ERR) while (!vPlaylist.empty() && input == KEY_DC)
{ {
TraceMpdStatus(); TraceMpdStatus();
timer = time(NULL); timer = time(NULL);
@@ -1131,13 +1123,15 @@ int main(int argc, char *argv[])
id = mPlaylist->GetChoice()-1; id = mPlaylist->GetChoice()-1;
mpd_playlist_queue_delete_pos(conn, id); mpd_playlist_queue_delete_pos(conn, id);
if (now_playing > id)
now_playing--;
delete vPlaylist[id];
vPlaylist.erase(vPlaylist.begin()+id); vPlaylist.erase(vPlaylist.begin()+id);
mPlaylist->DeleteOption(id+1); mPlaylist->DeleteOption(id+1);
mPlaylist->Refresh(); mPlaylist->Refresh();
} }
mPlaylist->ReadKey(input); mPlaylist->ReadKey(input);
} }
mpd_playlist_queue_commit(conn); mpd_playlist_queue_commit(conn);
mPlaylist->Timeout(ncmpcpp_window_timeout); mPlaylist->Timeout(ncmpcpp_window_timeout);
block_playlist_update = 0; block_playlist_update = 0;
@@ -1223,9 +1217,13 @@ int main(int argc, char *argv[])
} }
case 'm': // move song up case 'm': // move song up
{ {
block_playlist_update = 1;
int pos = mPlaylist->GetChoice()-1; int pos = mPlaylist->GetChoice()-1;
if (pos > 0 && !mPlaylist->Empty() && current_screen == csPlaylist) if (pos > 0 && !mPlaylist->Empty() && current_screen == csPlaylist)
{ {
std::swap<Song *>(vPlaylist[pos], vPlaylist[pos-1]);
mPlaylist->UpdateOption(pos, DisplaySong(*vPlaylist[pos-1]));
mPlaylist->UpdateOption(pos+1, DisplaySong(*vPlaylist[pos]));
mpd_playlist_move_pos(conn, pos, pos-1); mpd_playlist_move_pos(conn, pos, pos-1);
mPlaylist->Go(UP); mPlaylist->Go(UP);
} }
@@ -1233,9 +1231,13 @@ int main(int argc, char *argv[])
} }
case 'n': //move song down case 'n': //move song down
{ {
block_playlist_update = 1;
int pos = mPlaylist->GetChoice()-1; int pos = mPlaylist->GetChoice()-1;
if (pos+1 < mpd_playlist_get_playlist_length(conn) && !mPlaylist->Empty() && current_screen == csPlaylist) if (pos+1 < mpd_playlist_get_playlist_length(conn) && !mPlaylist->Empty() && current_screen == csPlaylist)
{ {
std::swap<Song *>(vPlaylist[pos+1], vPlaylist[pos]);
mPlaylist->UpdateOption(pos+2, DisplaySong(*vPlaylist[pos+1]));
mPlaylist->UpdateOption(pos+1, DisplaySong(*vPlaylist[pos]));
mpd_playlist_move_pos(conn, pos, pos+1); mpd_playlist_move_pos(conn, pos, pos+1);
mPlaylist->Go(DOWN); mPlaylist->Go(DOWN);
} }
@@ -1252,7 +1254,7 @@ int main(int argc, char *argv[])
int songpos, in; int songpos, in;
songpos = mpd_status_get_elapsed_song_time(conn); songpos = mpd_status_get_elapsed_song_time(conn);
Song &s = vPlaylist[now_playing]; Song &s = *vPlaylist[now_playing];
while (1) while (1)
{ {
@@ -1331,7 +1333,7 @@ int main(int argc, char *argv[])
{ {
case csPlaylist: case csPlaylist:
{ {
if (GetSongInfo(vPlaylist[id])) if (GetSongInfo(*vPlaylist[id]))
{ {
wCurrent = mTagEditor; wCurrent = mTagEditor;
wPrev = mPlaylist; wPrev = mPlaylist;
@@ -1404,7 +1406,7 @@ int main(int argc, char *argv[])
position = wFooter->GetString(3, TraceMpdStatus); position = wFooter->GetString(3, TraceMpdStatus);
newpos = atoi(position.c_str()); newpos = atoi(position.c_str());
if (newpos > 0 && newpos < 100 && !position.empty()) if (newpos > 0 && newpos < 100 && !position.empty())
mpd_player_seek(conn, vPlaylist[now_playing].GetTotalLength()*newpos/100.0); mpd_player_seek(conn, vPlaylist[now_playing]->GetTotalLength()*newpos/100.0);
UNBLOCK_STATUSBAR_UPDATE; UNBLOCK_STATUSBAR_UPDATE;
break; break;
} }
@@ -1439,14 +1441,34 @@ int main(int argc, char *argv[])
if (browsed_dir.empty()) if (browsed_dir.empty())
browsed_dir = "/"; browsed_dir = "/";
if (mBrowser->Empty())
GetDirectory(browsed_dir);
else
{
bool bold = 0;
for (int i = 0; i < vFileType.size(); i++)
{
if (vFileType[i] == MPD_DATA_TYPE_SONG)
{
for (vector<Song *>::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++)
{
if ((*it)->GetHash() == vHashList[i])
{
bold = 1;
break;
}
}
mBrowser->BoldOption(i+1, bold);
bold = 0;
}
}
}
if (wCurrent != mBrowser && current_screen != csTagEditor) if (wCurrent != mBrowser && current_screen != csTagEditor)
{ {
wCurrent = mBrowser; wCurrent = mBrowser;
wCurrent->Hide(); wCurrent->Hide();
current_screen = csBrowser; current_screen = csBrowser;
} }
if (mBrowser->Empty())
GetDirectory(browsed_dir);
break; break;
} }
case '4': // search screen case '4': // search screen
@@ -1458,6 +1480,25 @@ int main(int argc, char *argv[])
wCurrent = mSearcher; wCurrent = mSearcher;
wCurrent->Hide(); wCurrent->Hide();
current_screen = csSearcher; current_screen = csSearcher;
if (!vSearched.empty())
{
wCurrent->WriteXY(0, 0, "Updating list...");
bool bold = 0;
int i = search_engine_static_option;
for (vector<Song>::const_iterator it = vSearched.begin(); it != vSearched.end(); it++, i++)
{
for (vector<Song *>::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++)
{
if ((*j)->GetHash() == it->GetHash())
{
bold = 1;
break;
}
}
mSearcher->BoldOption(i+1, bold);
bold = 0;
}
}
} }
break; break;
} }

View File

@@ -200,6 +200,11 @@ bool Song::operator==(const Song &s) const
return itsFile == s.itsFile && itsArtist == s.itsArtist && itsTitle == s.itsTitle && itsAlbum == s.itsAlbum && itsTrack == s.itsTrack && itsYear == s.itsYear && itsGenre == s.itsGenre && itsComment == s.itsComment && itsHash == s.itsHash && itsMinutesLength && s.itsMinutesLength && itsSecondsLength == s.itsSecondsLength && itsPosition == s.itsPosition && itsID == s.itsID; return itsFile == s.itsFile && itsArtist == s.itsArtist && itsTitle == s.itsTitle && itsAlbum == s.itsAlbum && itsTrack == s.itsTrack && itsYear == s.itsYear && itsGenre == s.itsGenre && itsComment == s.itsComment && itsHash == s.itsHash && itsMinutesLength && s.itsMinutesLength && itsSecondsLength == s.itsSecondsLength && itsPosition == s.itsPosition && itsID == s.itsID;
} }
bool Song::operator!=(const Song &s) const
{
return itsFile != s.itsFile || itsArtist != s.itsArtist || itsTitle != s.itsTitle || itsAlbum != s.itsAlbum || itsTrack != s.itsTrack || itsYear != s.itsYear || itsGenre != s.itsGenre || itsComment != s.itsComment || itsHash != s.itsHash || itsMinutesLength || s.itsMinutesLength || itsSecondsLength != s.itsSecondsLength || itsPosition != s.itsPosition || itsID != s.itsID;
}
bool Song::operator<(const Song &s) const bool Song::operator<(const Song &s) const
{ {
return itsPosition < s.itsPosition; return itsPosition < s.itsPosition;

View File

@@ -80,6 +80,7 @@ class Song
Song & operator=(const Song &); Song & operator=(const Song &);
bool operator==(const Song &) const; bool operator==(const Song &) const;
bool operator!=(const Song &) const;
bool operator<(const Song &rhs) const; bool operator<(const Song &rhs) const;
private: private:
string itsFile; string itsFile;

View File

@@ -39,7 +39,7 @@ extern Menu *mLibSongs;
extern Window *wHeader; extern Window *wHeader;
extern Window *wFooter; extern Window *wFooter;
extern vector<Song> vPlaylist; extern vector<Song *> vPlaylist;
extern vector<Song> vSearched; extern vector<Song> vSearched;
extern vector<MpdDataType> vFileType; extern vector<MpdDataType> vFileType;
extern vector<string> vNameList; extern vector<string> vNameList;
@@ -75,6 +75,8 @@ extern bool block_statusbar_update;
extern bool block_playlist_update; extern bool block_playlist_update;
extern bool block_library_update; extern bool block_library_update;
long long playlist_old_id = -1;
int old_playing; int old_playing;
void TraceMpdStatus() void TraceMpdStatus()
@@ -129,7 +131,7 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
wFooter->Bold(1); wFooter->Bold(1);
wFooter->GetXY(sx, sy); wFooter->GetXY(sx, sy);
if (now_playing != mpd_player_get_current_song_pos(conn)) if (now_playing != mpd_player_get_current_song_pos(conn) && !block_playlist_update)
{ {
old_playing = now_playing; old_playing = now_playing;
now_playing = mpd_player_get_current_song_pos(conn); now_playing = mpd_player_get_current_song_pos(conn);
@@ -137,6 +139,8 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
if (what & MPD_CST_PLAYLIST) if (what & MPD_CST_PLAYLIST)
{ {
playlist_old_id = mpd_playlist_get_old_playlist_id(conn);
if (!block_playlist_update) if (!block_playlist_update)
{ {
int playlist_length = mpd_playlist_get_playlist_length(conn); int playlist_length = mpd_playlist_get_playlist_length(conn);
@@ -146,24 +150,24 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
if (playlist_length < vPlaylist.size()) if (playlist_length < vPlaylist.size())
{ {
mPlaylist->Clear(!playlist_length && current_screen != csLibrary); mPlaylist->Clear(!playlist_length && current_screen != csLibrary);
for (vector<Song *>::iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++)
delete *it;
vPlaylist.clear(); vPlaylist.clear();
}
playlist = mpd_playlist_get_changes(conn, -1); playlist = mpd_playlist_get_changes(conn, -1);
}
else
playlist = mpd_playlist_get_changes(conn, playlist_old_id);
vPlaylist.reserve(playlist_length); vPlaylist.reserve(playlist_length);
FOR_EACH_MPD_DATA(playlist) FOR_EACH_MPD_DATA(playlist)
{ {
if ((playlist_length > vPlaylist.size() && playlist->song->pos >= vPlaylist.size()) || playlist_length < vPlaylist.size()) Song *s = new Song(playlist->song);
{ vPlaylist.push_back(s);
vPlaylist.push_back(playlist->song); if (now_playing != s->GetPosition())
Song &s = vPlaylist.back(); mPlaylist->AddOption(DisplaySong(*s));
if (now_playing != s.GetPosition())
mPlaylist->AddOption(DisplaySong(s));
else else
mPlaylist->AddBoldOption(DisplaySong(s)); mPlaylist->AddBoldOption(DisplaySong(*s));
}
} }
mpd_data_free(playlist); mpd_data_free(playlist);
@@ -183,14 +187,15 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
playlist = mpd_playlist_get_changes(conn, -1); playlist = mpd_playlist_get_changes(conn, -1);
for (vector<Song>::iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++, i++) for (vector<Song *>::iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++, i++)
{ {
Song ss = playlist->song; Song ss = playlist->song;
ss.GetEmptyFields(1); ss.GetEmptyFields(1);
if (it->GetFile() != ss.GetFile() || it->GetTitle() != ss.GetTitle() || it->GetArtist() != ss.GetArtist() || it->GetAlbum() != ss.GetAlbum() || it->GetYear() != ss.GetYear() || it->GetTrack() != ss.GetTrack() || it->GetGenre() != ss.GetGenre() || it->GetComment() != ss.GetComment() || it->GetID() != ss.GetID() || it->GetPosition() != ss.GetPosition()) (*it)->GetEmptyFields(1);
if (**it != ss)
{ {
ss.GetEmptyFields(0); ss.GetEmptyFields(0);
*it = ss; **it = ss;
mPlaylist->UpdateOption(i, DisplaySong(ss)); mPlaylist->UpdateOption(i, DisplaySong(ss));
} }
playlist = mpd_data_get_next(playlist); playlist = mpd_data_get_next(playlist);
@@ -202,16 +207,16 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
if (vPlaylist.empty()) if (vPlaylist.empty())
ShowMessage("Cleared playlist!"); ShowMessage("Cleared playlist!");
if (!vNameList.empty()) if (current_screen == csBrowser)
{ {
bool bold = 0; bool bold = 0;
for (int i = 0; i < vFileType.size(); i++) for (int i = 0; i < vFileType.size(); i++)
{ {
if (vFileType[i] == MPD_DATA_TYPE_SONG) if (vFileType[i] == MPD_DATA_TYPE_SONG)
{ {
for (vector<Song>::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++) for (vector<Song *>::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++)
{ {
if (it->GetHash() == vHashList[i]) if ((*it)->GetHash() == vHashList[i])
{ {
bold = 1; bold = 1;
break; break;
@@ -222,15 +227,15 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
} }
} }
} }
if (!vSearched.empty()) if (current_screen == csSearcher)
{ {
bool bold = 0; bool bold = 0;
int i = search_engine_static_option; int i = search_engine_static_option;
for (vector<Song>::const_iterator it = vSearched.begin(); it != vSearched.end(); it++, i++) for (vector<Song>::const_iterator it = vSearched.begin(); it != vSearched.end(); it++, i++)
{ {
for (vector<Song>::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++) for (vector<Song *>::const_iterator j = vPlaylist.begin(); j != vPlaylist.end(); j++)
{ {
if (j->GetHash() == it->GetHash()) if ((*j)->GetHash() == it->GetHash())
{ {
bold = 1; bold = 1;
break; break;
@@ -254,7 +259,7 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
{ {
case MPD_PLAYER_PLAY: case MPD_PLAYER_PLAY:
{ {
Song &s = vPlaylist[now_playing]; Song &s = *vPlaylist[now_playing];
player_state = "Playing: "; player_state = "Playing: ";
mPlaylist->BoldOption(now_playing+1, 1); mPlaylist->BoldOption(now_playing+1, 1);
break; break;
@@ -281,7 +286,7 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
} }
if ((what & MPD_CST_ELAPSED_TIME)) if ((what & MPD_CST_ELAPSED_TIME))
{ {
Song &s = vPlaylist[now_playing]; Song &s = *vPlaylist[now_playing];
if (!player_state.empty()) if (!player_state.empty())
{ {
WindowTitle(DisplaySong(s, Config.song_window_title_format)); WindowTitle(DisplaySong(s, Config.song_window_title_format));
@@ -392,7 +397,7 @@ void NcmpcppStatusChanged(MpdObj *conn, ChangedStatusType what)
int id = mpd_player_get_current_song_pos(conn); int id = mpd_player_get_current_song_pos(conn);
if (!vPlaylist.empty() && id >= 0) if (!vPlaylist.empty() && id >= 0)
{ {
Song &s = vPlaylist[id]; Song &s = *vPlaylist[id];
if (!mPlaylist->Empty()) if (!mPlaylist->Empty())
{ {
if (old_playing >= 0) if (old_playing >= 0)