|
a/upmpd/ohplaylist.cxx |
|
b/upmpd/ohplaylist.cxx |
|
... |
|
... |
152 |
// not valid any more. Also there may be entries which were added
|
152 |
// not valid any more. Also there may be entries which were added
|
153 |
// through an MPD client and which don't know about, record the
|
153 |
// through an MPD client and which don't know about, record the
|
154 |
// metadata for these. We don't update the current array, but
|
154 |
// metadata for these. We don't update the current array, but
|
155 |
// just build a new cache for data about current entries
|
155 |
// just build a new cache for data about current entries
|
156 |
unordered_map<int, string> nmeta;
|
156 |
unordered_map<int, string> nmeta;
|
|
|
157 |
|
|
|
158 |
// Walk the playlist data from MPD
|
157 |
for (auto& usong : vdata) {
|
159 |
for (auto& usong : vdata) {
|
158 |
auto inold = m_metacache.find(usong.mpdid);
|
160 |
auto inold = m_metacache.find(usong.mpdid);
|
159 |
if (inold != m_metacache.end())
|
161 |
if (inold != m_metacache.end()) {
|
|
|
162 |
// Entries already in the metadata array just get
|
|
|
163 |
// transferred to the new array
|
160 |
nmeta[usong.mpdid].swap(inold->second);
|
164 |
nmeta[usong.mpdid].swap(inold->second);
|
161 |
else
|
165 |
} else {
|
|
|
166 |
// Entries not in the old array are translated from the
|
|
|
167 |
// MPD data to our format. They were probably added by
|
|
|
168 |
// another MPD client.
|
162 |
nmeta[usong.mpdid] = didlmake(usong);
|
169 |
nmeta[usong.mpdid] = didlmake(usong);
|
|
|
170 |
}
|
163 |
}
|
171 |
}
|
164 |
m_metacache = nmeta;
|
172 |
m_metacache = nmeta;
|
165 |
|
173 |
|
166 |
return out;
|
174 |
return out;
|
167 |
}
|
175 |
}
|
168 |
|
176 |
|
169 |
bool OHPlaylist::makestate(unordered_map<string, string> &st)
|
177 |
bool OHPlaylist::makestate(unordered_map<string, string> &st)
|
170 |
{
|
178 |
{
|
171 |
st.clear();
|
179 |
st.clear();
|
172 |
|
180 |
|
173 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
181 |
const MpdStatus &mpds = m_dev->getMpdStatusNoUpdate();
|
174 |
|
182 |
|
175 |
st["TransportState"] = mpdstatusToTransportState(mpds.state);
|
183 |
st["TransportState"] = mpdstatusToTransportState(mpds.state);
|
176 |
st["Repeat"] = SoapArgs::i2s(mpds.rept);
|
184 |
st["Repeat"] = SoapArgs::i2s(mpds.rept);
|
177 |
st["Shuffle"] = SoapArgs::i2s(mpds.random);
|
185 |
st["Shuffle"] = SoapArgs::i2s(mpds.random);
|
178 |
st["Id"] = SoapArgs::i2s(mpds.songid);
|
186 |
st["Id"] = SoapArgs::i2s(mpds.songid);
|
|
... |
|
... |
312 |
{
|
320 |
{
|
313 |
LOGDEB("OHPlaylist::seekSecondRelative" << endl);
|
321 |
LOGDEB("OHPlaylist::seekSecondRelative" << endl);
|
314 |
int seconds;
|
322 |
int seconds;
|
315 |
bool ok = sc.getInt("Value", &seconds);
|
323 |
bool ok = sc.getInt("Value", &seconds);
|
316 |
if (ok) {
|
324 |
if (ok) {
|
317 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
325 |
const MpdStatus &mpds = m_dev->getMpdStatusNoUpdate();
|
318 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
326 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
319 |
(mpds.state == MpdStatus::MPDS_PAUSE);
|
327 |
(mpds.state == MpdStatus::MPDS_PAUSE);
|
320 |
if (is_song) {
|
328 |
if (is_song) {
|
321 |
seconds += mpds.songelapsedms / 1000;
|
329 |
seconds += mpds.songelapsedms / 1000;
|
322 |
ok = m_dev->m_mpdcli->seek(seconds);
|
330 |
ok = m_dev->m_mpdcli->seek(seconds);
|
|
... |
|
... |
329 |
}
|
337 |
}
|
330 |
|
338 |
|
331 |
int OHPlaylist::transportState(const SoapArgs& sc, SoapData& data)
|
339 |
int OHPlaylist::transportState(const SoapArgs& sc, SoapData& data)
|
332 |
{
|
340 |
{
|
333 |
LOGDEB("OHPlaylist::transportState" << endl);
|
341 |
LOGDEB("OHPlaylist::transportState" << endl);
|
334 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
342 |
const MpdStatus &mpds = m_dev->getMpdStatusNoUpdate();
|
335 |
string tstate;
|
343 |
string tstate;
|
336 |
switch(mpds.state) {
|
344 |
switch(mpds.state) {
|
337 |
case MpdStatus::MPDS_PLAY:
|
345 |
case MpdStatus::MPDS_PLAY:
|
338 |
tstate = "Playing";
|
346 |
tstate = "Playing";
|
339 |
break;
|
347 |
break;
|
|
... |
|
... |
375 |
|
383 |
|
376 |
// Return current Id
|
384 |
// Return current Id
|
377 |
int OHPlaylist::id(const SoapArgs& sc, SoapData& data)
|
385 |
int OHPlaylist::id(const SoapArgs& sc, SoapData& data)
|
378 |
{
|
386 |
{
|
379 |
LOGDEB("OHPlaylist::id" << endl);
|
387 |
LOGDEB("OHPlaylist::id" << endl);
|
380 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
388 |
const MpdStatus &mpds = m_dev->getMpdStatusNoUpdate();
|
381 |
data.addarg("Value", SoapArgs::i2s(mpds.songid));
|
389 |
data.addarg("Value", SoapArgs::i2s(mpds.songid));
|
382 |
return UPNP_E_SUCCESS;
|
390 |
return UPNP_E_SUCCESS;
|
383 |
}
|
391 |
}
|
384 |
|
392 |
|
385 |
// Report the uri and metadata for a given track id.
|
393 |
// Report the uri and metadata for a given track id.
|
386 |
// Returns a 800 fault code if the given id is not in the playlist.
|
394 |
// Returns a 800 fault code if the given id is not in the playlist.
|
387 |
int OHPlaylist::ohread(const SoapArgs& sc, SoapData& data)
|
395 |
int OHPlaylist::ohread(const SoapArgs& sc, SoapData& data)
|
388 |
{
|
396 |
{
|
389 |
LOGDEB("OHPlaylist::ohread" << endl);
|
397 |
LOGDEB("OHPlaylist::ohread" << endl);
|
390 |
int id;
|
398 |
int id;
|
391 |
bool ok = sc.getInt("Value", &id);
|
399 |
bool ok = sc.getInt("Id", &id);
|
392 |
UpSong song;
|
400 |
UpSong song;
|
393 |
if (ok) {
|
401 |
if (ok) {
|
394 |
ok = m_dev->m_mpdcli->statSong(song, id, true);
|
402 |
ok = m_dev->m_mpdcli->statSong(song, id, true);
|
395 |
}
|
403 |
}
|
396 |
if (ok) {
|
404 |
if (ok) {
|