コード例 #1
0
ファイル: mpdpp.cpp プロジェクト: Spotlight0xff/ncmpcpp
SongIterator Connection::GetPlaylistChanges(unsigned version)
{
	prechecksNoCommandsList();
	mpd_send_queue_changes_meta(m_connection.get(), version);
	checkErrors();
	return SongIterator(m_connection.get(), defaultFetcher<Song>(mpd_recv_song));
}
コード例 #2
0
ファイル: command.cpp プロジェクト: reynhout/pms
/*
 * Retrieves current playlist from MPD
 * TODO: implement missing entity types
 */
bool
Control::update_queue()
{
	bool			rc;
	Song *			song;
	struct mpd_entity *	ent;
	const struct mpd_song *	ent_song;

	EXIT_IDLE;

	pms->log(MSG_DEBUG, 0, "Updating playlist from version %d to %d\n", st->last_playlist, st->playlist);

	if (st->last_playlist == -1) {
		_queue->clear();
	}

	if (!mpd_send_queue_changes_meta(conn->h(), st->last_playlist)) {
		return false;
	}

	while ((ent = mpd_recv_entity(conn->h())) != NULL)
	{
		switch(mpd_entity_get_type(ent))
		{
			case MPD_ENTITY_TYPE_SONG:
				ent_song = mpd_entity_get_song(ent);
				song = new Song(ent_song);
				_queue->add_local(song);
				break;
			case MPD_ENTITY_TYPE_UNKNOWN:
				pms->log(MSG_DEBUG, 0, "BUG in update_queue(): entity type not implemented by libmpdclient\n");
				break;
			default:
				pms->log(MSG_DEBUG, 0, "BUG in update_queue(): entity type not implemented by PMS\n");
				break;
		}
		mpd_entity_free(ent);
	}

	if ((rc = get_error_bool()) == true) {
		_queue->truncate_local(st->playlist_length);
		st->last_playlist = st->playlist;
	}

	return rc;
}