mpd: make functions take item consumer instead of returning vector of items

This commit is contained in:
Andrzej Rybczak
2012-10-01 20:44:22 +02:00
parent 60faa15462
commit 9a292ca20d
14 changed files with 206 additions and 209 deletions

View File

@@ -141,21 +141,19 @@ void Status::Changes::playlist()
myPlaylist->main().resizeList(playlist_length);
}
auto songs = Mpd.GetPlaylistChanges(Mpd.GetOldPlaylistID());
for (auto s = songs.begin(); s != songs.end(); ++s)
{
size_t pos = s->getPosition();
Mpd.GetPlaylistChanges(Mpd.GetOldPlaylistID(), [](MPD::Song &&s) {
size_t pos = s.getPosition();
if (pos < myPlaylist->main().size())
{
// if song's already in playlist, replace it with a new one
MPD::Song &old_s = myPlaylist->main()[pos].value();
myPlaylist->unregisterHash(old_s.getHash());
old_s = *s;
old_s = s;
}
else // otherwise just add it to playlist
myPlaylist->main().addItem(*s);
myPlaylist->registerHash(s->getHash());
}
myPlaylist->main().addItem(s);
myPlaylist->registerHash(s.getHash());
});
});
if (Mpd.isPlaying())