|
a/upmpd/ohplaylist.cxx |
|
b/upmpd/ohplaylist.cxx |
|
... |
|
... |
130 |
// encoded in base64...
|
130 |
// encoded in base64...
|
131 |
static string translateIdArray(const vector<UpSong>& in)
|
131 |
static string translateIdArray(const vector<UpSong>& in)
|
132 |
{
|
132 |
{
|
133 |
string out1;
|
133 |
string out1;
|
134 |
string sdeb;
|
134 |
string sdeb;
|
135 |
for (auto us : in) {
|
135 |
for (auto us = in.begin(); us != in.end(); us++) {
|
136 |
unsigned int val = us.mpdid;
|
136 |
unsigned int val = us->mpdid;
|
137 |
if (val) {
|
137 |
if (val) {
|
138 |
out1 += (unsigned char) ((val & 0xff000000) >> 24);
|
138 |
out1 += (unsigned char) ((val & 0xff000000) >> 24);
|
139 |
out1 += (unsigned char) ((val & 0x00ff0000) >> 16);
|
139 |
out1 += (unsigned char) ((val & 0x00ff0000) >> 16);
|
140 |
out1 += (unsigned char) ((val & 0x0000ff00) >> 8);
|
140 |
out1 += (unsigned char) ((val & 0x0000ff00) >> 8);
|
141 |
out1 += (unsigned char) ((val & 0x000000ff));
|
141 |
out1 += (unsigned char) ((val & 0x000000ff));
|
|
... |
|
... |
180 |
// restart at 0) this means that the ids are not a good cache key,
|
180 |
// restart at 0) this means that the ids are not a good cache key,
|
181 |
// we use the uris instead.
|
181 |
// we use the uris instead.
|
182 |
unordered_map<string, string> nmeta;
|
182 |
unordered_map<string, string> nmeta;
|
183 |
|
183 |
|
184 |
// Walk the playlist data from MPD
|
184 |
// Walk the playlist data from MPD
|
185 |
for (auto& usong : vdata) {
|
185 |
for (auto usong = vdata.begin(); usong != vdata.end(); usong++) {
|
186 |
auto inold = m_metacache.find(usong.uri);
|
186 |
auto inold = m_metacache.find(usong->uri);
|
187 |
if (inold != m_metacache.end()) {
|
187 |
if (inold != m_metacache.end()) {
|
188 |
// Entries already in the metadata array just get
|
188 |
// Entries already in the metadata array just get
|
189 |
// transferred to the new array
|
189 |
// transferred to the new array
|
190 |
nmeta[usong.uri].swap(inold->second);
|
190 |
nmeta[usong->uri].swap(inold->second);
|
191 |
m_metacache.erase(inold);
|
191 |
m_metacache.erase(inold);
|
192 |
} else {
|
192 |
} else {
|
193 |
// Entries not in the arrays are translated from the
|
193 |
// Entries not in the arrays are translated from the
|
194 |
// MPD data to our format. They were probably added by
|
194 |
// MPD data to our format. They were probably added by
|
195 |
// another MPD client.
|
195 |
// another MPD client.
|
196 |
if (nmeta.find(usong.uri) == nmeta.end()) {
|
196 |
if (nmeta.find(usong->uri) == nmeta.end()) {
|
197 |
nmeta[usong.uri] = didlmake(usong);
|
197 |
nmeta[usong->uri] = didlmake(*usong);
|
198 |
m_cachedirty = true;
|
198 |
m_cachedirty = true;
|
199 |
LOGDEB("OHPlaylist::makeIdArray: using mpd data for " <<
|
199 |
LOGDEB("OHPlaylist::makeIdArray: using mpd data for " <<
|
200 |
usong.mpdid << " uri " << usong.uri << endl);
|
200 |
usong->mpdid << " uri " << usong->uri << endl);
|
201 |
}
|
201 |
}
|
202 |
}
|
202 |
}
|
203 |
}
|
203 |
}
|
204 |
|
204 |
|
205 |
for (unordered_map<string, string>::const_iterator it = m_metacache.begin();
|
205 |
for (unordered_map<string, string>::const_iterator it = m_metacache.begin();
|
|
... |
|
... |
252 |
} else {
|
252 |
} else {
|
253 |
changed = diffmaps(m_state, state);
|
253 |
changed = diffmaps(m_state, state);
|
254 |
}
|
254 |
}
|
255 |
m_state = state;
|
255 |
m_state = state;
|
256 |
|
256 |
|
257 |
for (auto& entry : changed) {
|
257 |
for (auto it = changed.begin(); it != changed.end(); it++) {
|
258 |
names.push_back(entry.first);
|
258 |
names.push_back(it->first);
|
259 |
values.push_back(entry.second);
|
259 |
values.push_back(it->second);
|
260 |
}
|
260 |
}
|
261 |
|
261 |
|
262 |
return true;
|
262 |
return true;
|
263 |
}
|
263 |
}
|
264 |
|
264 |
|
|
... |
|
... |
493 |
bool ok = sc.getString("IdList", &sids);
|
493 |
bool ok = sc.getString("IdList", &sids);
|
494 |
vector<string> ids;
|
494 |
vector<string> ids;
|
495 |
string out("<TrackList>");
|
495 |
string out("<TrackList>");
|
496 |
if (ok) {
|
496 |
if (ok) {
|
497 |
stringToTokens(sids, ids);
|
497 |
stringToTokens(sids, ids);
|
498 |
for (auto& sid : ids) {
|
498 |
for (auto it = ids.begin(); it != ids.end(); it++) {
|
499 |
int id = atoi(sid.c_str());
|
499 |
int id = atoi(it->c_str());
|
500 |
if (id == -1) {
|
500 |
if (id == -1) {
|
501 |
// Lumin does this??
|
501 |
// Lumin does this??
|
502 |
LOGDEB("OHPlaylist::readlist: request for id -1" << endl);
|
502 |
LOGDEB("OHPlaylist::readlist: request for id -1" << endl);
|
503 |
continue;
|
503 |
continue;
|
504 |
}
|
504 |
}
|
|
... |
|
... |
518 |
m_metacache[song.uri] = metadata;
|
518 |
m_metacache[song.uri] = metadata;
|
519 |
m_cachedirty = true;
|
519 |
m_cachedirty = true;
|
520 |
metadata = SoapHelp::xmlQuote(metadata);
|
520 |
metadata = SoapHelp::xmlQuote(metadata);
|
521 |
}
|
521 |
}
|
522 |
out += "<Entry><Id>";
|
522 |
out += "<Entry><Id>";
|
523 |
out += sid.c_str();
|
523 |
out += it->c_str();
|
524 |
out += "</Id><Uri>";
|
524 |
out += "</Id><Uri>";
|
525 |
out += song.uri;
|
525 |
out += song.uri;
|
526 |
out += "</Uri><Metadata>";
|
526 |
out += "</Uri><Metadata>";
|
527 |
out += metadata;
|
527 |
out += metadata;
|
528 |
out += "</Metadata></Entry>";
|
528 |
out += "</Metadata></Entry>";
|