|
a/src/ohreceiver.cxx |
|
b/src/ohreceiver.cxx |
|
... |
|
... |
149 |
if (m_metadata.empty()) {
|
149 |
if (m_metadata.empty()) {
|
150 |
LOGERR("OHReceiver::play: no metadata" << endl);
|
150 |
LOGERR("OHReceiver::play: no metadata" << endl);
|
151 |
return false;
|
151 |
return false;
|
152 |
}
|
152 |
}
|
153 |
|
153 |
|
154 |
m_dev->m_mpdcli->stop();
|
|
|
155 |
|
|
|
156 |
int id = -1;
|
154 |
int id = -1;
|
157 |
unordered_map<int, string> urlmap;
|
155 |
unordered_map<int, string> urlmap;
|
158 |
string line;
|
156 |
string line;
|
159 |
|
157 |
|
160 |
// We start the songcast command to receive the audio flux and either
|
158 |
// We start the songcast command to receive the audio flux and either
|
|
... |
|
... |
183 |
} else {
|
181 |
} else {
|
184 |
LOGDEB("OHReceiver::play: sc2mpd pid "<< m_cmd->getChildPid()<< endl);
|
182 |
LOGDEB("OHReceiver::play: sc2mpd pid "<< m_cmd->getChildPid()<< endl);
|
185 |
}
|
183 |
}
|
186 |
|
184 |
|
187 |
if (m_pm == OHReceiverParams::OHRP_MPD) {
|
185 |
if (m_pm == OHReceiverParams::OHRP_MPD) {
|
|
|
186 |
m_dev->m_mpdcli->stop();
|
|
|
187 |
|
188 |
// Wait for sc2mpd to signal ready, then play.
|
188 |
// Wait for sc2mpd to signal ready, then play.
|
189 |
// sc2mpd writes a single line to stdout "CONNECTED" when
|
189 |
// sc2mpd writes a single line to stdout "CONNECTED" when
|
190 |
// it gets there, which should be more or less instantaneous
|
190 |
// it gets there, which should be more or less instantaneous
|
191 |
int timeo = 15;
|
191 |
int timeo = 15;
|
192 |
if (m_cmd->getline(line, timeo) < 0) {
|
192 |
if (m_cmd->getline(line, timeo) < 0) {
|
|
... |
|
... |
223 |
|
223 |
|
224 |
out:
|
224 |
out:
|
225 |
if (!ok) {
|
225 |
if (!ok) {
|
226 |
iStop();
|
226 |
iStop();
|
227 |
}
|
227 |
}
|
228 |
maybeWakeUp(ok);
|
|
|
229 |
return ok;
|
228 |
return ok;
|
230 |
}
|
229 |
}
|
231 |
|
230 |
|
232 |
int OHReceiver::play(const SoapIncoming& sc, SoapOutgoing& data)
|
231 |
int OHReceiver::play(const SoapIncoming& sc, SoapOutgoing& data)
|
233 |
{
|
232 |
{
|
234 |
LOGDEB("OHReceiver::play" << endl);
|
233 |
LOGDEB("OHReceiver::play" << endl);
|
235 |
bool ok = iPlay();
|
234 |
bool ok = iPlay();
|
236 |
if (ok && m_dev->m_ohpr)
|
235 |
if (ok && m_dev->m_ohpr)
|
237 |
m_dev->m_ohpr->iSetSourceIndexByName("Receiver");
|
236 |
m_dev->m_ohpr->iSetSourceIndexByName("Receiver");
|
|
|
237 |
maybeWakeUp(ok);
|
238 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
238 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
239 |
}
|
239 |
}
|
240 |
|
240 |
|
241 |
bool OHReceiver::iStop()
|
241 |
bool OHReceiver::iStop()
|
242 |
{
|
242 |
{
|
243 |
LOGDEB("OHReceiver::iStop()\n");
|
243 |
LOGDEB("OHReceiver::iStop()\n");
|
244 |
if (m_cmd) {
|
244 |
if (m_cmd) {
|
245 |
m_cmd->zapChild();
|
245 |
m_cmd->zapChild();
|
246 |
m_cmd = shared_ptr<ExecCmd>();
|
246 |
m_cmd = shared_ptr<ExecCmd>();
|
247 |
}
|
247 |
}
|
|
|
248 |
|
|
|
249 |
if (m_pm == OHReceiverParams::OHRP_MPD) {
|
248 |
m_dev->m_mpdcli->stop();
|
250 |
m_dev->m_mpdcli->stop();
|
249 |
|
|
|
250 |
unordered_map<int, string> urlmap;
|
251 |
unordered_map<int, string> urlmap;
|
251 |
// Remove our bogus URi from the playlist
|
252 |
// Remove our bogus URi from the playlist
|
252 |
if (!m_dev->m_ohpl->urlMap(urlmap)) {
|
253 |
if (!m_dev->m_ohpl->urlMap(urlmap)) {
|
253 |
LOGERR("OHReceiver::stop: urlMap() failed" <<endl);
|
254 |
LOGERR("OHReceiver::stop: urlMap() failed" <<endl);
|
254 |
}
|
255 |
}
|
255 |
for (auto it = urlmap.begin(); it != urlmap.end(); it++) {
|
256 |
for (auto it = urlmap.begin(); it != urlmap.end(); it++) {
|
256 |
if (it->second == m_httpuri) {
|
257 |
if (it->second == m_httpuri) {
|
257 |
m_dev->m_mpdcli->deleteId(it->first);
|
258 |
m_dev->m_mpdcli->deleteId(it->first);
|
258 |
}
|
259 |
}
|
|
|
260 |
}
|
|
|
261 |
}
|
259 |
}
|
262 |
|
|
|
263 |
return true;
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
int OHReceiver::stop(const SoapIncoming& sc, SoapOutgoing& data)
|
|
|
267 |
{
|
|
|
268 |
LOGDEB("OHReceiver::stop" << endl);
|
|
|
269 |
iStop();
|
|
|
270 |
|
260 |
// At least the songcast windows driver never resets the source
|
271 |
// At least the songcast windows driver never resets the source
|
261 |
// index (it does call stop when it deconnects).
|
272 |
// index (it does call stop when it deconnects).
|
262 |
// I guess that there is no reason to reset the source, and
|
273 |
// I guess that there is no reason to reset the source, and
|
263 |
// another CP could just set it to what it wants, but Bubble at
|
274 |
// another CP could just set it to what it wants, but Bubble at
|
264 |
// least won't do a thing with the renderer as long as the source
|
275 |
// least won't do a thing with the renderer as long as the source
|
265 |
// is set to receiver.
|
276 |
// is set to receiver.
|
266 |
if (m_dev->m_ohpr)
|
277 |
if (m_dev->m_ohpr)
|
267 |
m_dev->m_ohpr->iSetSourceIndexByName("Playlist");
|
278 |
m_dev->m_ohpr->iSetSourceIndexByName("Playlist");
|
268 |
|
279 |
|
269 |
maybeWakeUp(true);
|
280 |
maybeWakeUp(true);
|
270 |
return true;
|
281 |
return UPNP_E_SUCCESS;
|
271 |
}
|
|
|
272 |
|
|
|
273 |
int OHReceiver::stop(const SoapIncoming& sc, SoapOutgoing& data)
|
|
|
274 |
{
|
|
|
275 |
LOGDEB("OHReceiver::stop" << endl);
|
|
|
276 |
return iStop() ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
|
|
277 |
}
|
282 |
}
|
278 |
|
283 |
|
279 |
bool OHReceiver::iSetSender(const string& uri, const string& metadata)
|
284 |
bool OHReceiver::iSetSender(const string& uri, const string& metadata)
|
280 |
{
|
285 |
{
|
281 |
// Only do something if data changes, and then first stop any
|
286 |
// Only do something if data changes, and then first stop any
|