|
a/upmpd/ohplaylist.cxx |
|
b/upmpd/ohplaylist.cxx |
|
... |
|
... |
45 |
static const string sTpProduct("urn:av-openhome-org:service:Playlist:1");
|
45 |
static const string sTpProduct("urn:av-openhome-org:service:Playlist:1");
|
46 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Playlist");
|
46 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Playlist");
|
47 |
|
47 |
|
48 |
OHPlaylist::OHPlaylist(UpMpd *dev, UpMpdRenderCtl *ctl)
|
48 |
OHPlaylist::OHPlaylist(UpMpd *dev, UpMpdRenderCtl *ctl)
|
49 |
: UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev), m_ctl(ctl),
|
49 |
: UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev), m_ctl(ctl),
|
50 |
m_cachedirty(false)
|
50 |
m_cachedirty(false), m_mpdqvers(-1)
|
51 |
{
|
51 |
{
|
52 |
dev->addActionMapping(this, "Play",
|
52 |
dev->addActionMapping(this, "Play",
|
53 |
bind(&OHPlaylist::play, this, _1, _2));
|
53 |
bind(&OHPlaylist::play, this, _1, _2));
|
54 |
dev->addActionMapping(this, "Pause",
|
54 |
dev->addActionMapping(this, "Pause",
|
55 |
bind(&OHPlaylist::pause, this, _1, _2));
|
55 |
bind(&OHPlaylist::pause, this, _1, _2));
|
|
... |
|
... |
142 |
return base64_encode(out1);
|
142 |
return base64_encode(out1);
|
143 |
}
|
143 |
}
|
144 |
|
144 |
|
145 |
bool OHPlaylist::makeIdArray(string& out)
|
145 |
bool OHPlaylist::makeIdArray(string& out)
|
146 |
{
|
146 |
{
|
|
|
147 |
const MpdStatus &mpds = m_dev->getMpdStatusNoUpdate();
|
|
|
148 |
|
|
|
149 |
if (mpds.qvers == m_mpdqvers) {
|
|
|
150 |
out = m_idArrayCached;
|
|
|
151 |
// Mpd queue did not change: no need to look at the metadata cache
|
|
|
152 |
//LOGDEB("OHPlaylist::makeIdArray: mpd queue did not change" << endl);
|
|
|
153 |
return true;
|
|
|
154 |
}
|
|
|
155 |
|
147 |
// Retrieve the data for current queue songs from mpd, and make an
|
156 |
// Retrieve the data for current queue songs from mpd, and make an
|
148 |
// ohPlaylist id array.
|
157 |
// ohPlaylist id array.
|
149 |
vector<UpSong> vdata;
|
158 |
vector<UpSong> vdata;
|
150 |
bool ok = m_dev->m_mpdcli->getQueueData(vdata);
|
159 |
bool ok = m_dev->m_mpdcli->getQueueData(vdata);
|
151 |
if (!ok) {
|
160 |
if (!ok) {
|
152 |
LOGERR("OHPlaylist::makeIdArray: getQueueData failed."
|
161 |
LOGERR("OHPlaylist::makeIdArray: getQueueData failed."
|
153 |
"metacache size " << m_metacache.size() << endl);
|
162 |
"metacache size " << m_metacache.size() << endl);
|
154 |
return false;
|
163 |
return false;
|
155 |
}
|
164 |
}
|
156 |
|
165 |
|
157 |
out = translateIdArray(vdata);
|
166 |
m_idArrayCached = out = translateIdArray(vdata);
|
|
|
167 |
m_mpdqvers = mpds.qvers;
|
158 |
|
168 |
|
159 |
// Update metadata cache: entries not in the current list are
|
169 |
// Update metadata cache: entries not in the current list are
|
160 |
// not valid any more. Also there may be entries which were added
|
170 |
// not valid any more. Also there may be entries which were added
|
161 |
// through an MPD client and which don't know about, record the
|
171 |
// through an MPD client and which don't know about, record the
|
162 |
// metadata for these. We don't update the current array, but
|
172 |
// metadata for these. We don't update the current array, but
|
|
... |
|
... |
531 |
if (ok) {
|
541 |
if (ok) {
|
532 |
int id = m_dev->m_mpdcli->insertAfterId(uri, afterid);
|
542 |
int id = m_dev->m_mpdcli->insertAfterId(uri, afterid);
|
533 |
if ((ok = (id != -1))) {
|
543 |
if ((ok = (id != -1))) {
|
534 |
m_metacache[uri] = metadata;
|
544 |
m_metacache[uri] = metadata;
|
535 |
m_cachedirty = true;
|
545 |
m_cachedirty = true;
|
|
|
546 |
m_mpdqvers = -1;
|
536 |
data.addarg("NewId", SoapArgs::i2s(id));
|
547 |
data.addarg("NewId", SoapArgs::i2s(id));
|
537 |
}
|
548 |
}
|
538 |
}
|
549 |
}
|
539 |
maybeWakeUp(ok);
|
550 |
maybeWakeUp(ok);
|
540 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
551 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
|
... |
|
... |
545 |
LOGDEB("OHPlaylist::deleteId" << endl);
|
556 |
LOGDEB("OHPlaylist::deleteId" << endl);
|
546 |
int id;
|
557 |
int id;
|
547 |
bool ok = sc.getInt("Value", &id);
|
558 |
bool ok = sc.getInt("Value", &id);
|
548 |
if (ok) {
|
559 |
if (ok) {
|
549 |
ok = m_dev->m_mpdcli->deleteId(id);
|
560 |
ok = m_dev->m_mpdcli->deleteId(id);
|
|
|
561 |
m_mpdqvers = -1;
|
550 |
maybeWakeUp(ok);
|
562 |
maybeWakeUp(ok);
|
551 |
}
|
563 |
}
|
552 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
564 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
553 |
}
|
565 |
}
|
554 |
|
566 |
|
555 |
int OHPlaylist::deleteAll(const SoapArgs& sc, SoapData& data)
|
567 |
int OHPlaylist::deleteAll(const SoapArgs& sc, SoapData& data)
|
556 |
{
|
568 |
{
|
557 |
LOGDEB("OHPlaylist::deleteAll" << endl);
|
569 |
LOGDEB("OHPlaylist::deleteAll" << endl);
|
558 |
bool ok = m_dev->m_mpdcli->clearQueue();
|
570 |
bool ok = m_dev->m_mpdcli->clearQueue();
|
|
|
571 |
m_mpdqvers = -1;
|
559 |
maybeWakeUp(ok);
|
572 |
maybeWakeUp(ok);
|
560 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
573 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
561 |
}
|
574 |
}
|
562 |
|
575 |
|
563 |
int OHPlaylist::tracksMax(const SoapArgs& sc, SoapData& data)
|
576 |
int OHPlaylist::tracksMax(const SoapArgs& sc, SoapData& data)
|