a/src/ohproduct.cxx b/src/ohproduct.cxx
...
...
276
        return UPNP_E_SUCCESS;
276
        return UPNP_E_SUCCESS;
277
    }
277
    }
278
278
279
    m_dev->m_ohif->setMetatext("");
279
    m_dev->m_ohif->setMetatext("");
280
280
281
    bool ok = true;
281
    string curtp = o_sources[m_sourceIndex].first;
282
    string curtp = o_sources[m_sourceIndex].first;
282
    string curnm = o_sources[m_sourceIndex].second;
283
    string curnm = o_sources[m_sourceIndex].second;
283
    if (m_dev->m_ohpl && !curtp.compare("Playlist") &&
284
    if (m_dev->m_ohpl && !curtp.compare("Playlist") &&
284
        !curnm.compare("Playlist")) {
285
        !curnm.compare("Playlist")) {
285
        m_dev->m_ohpl->setActive(false);
286
        m_dev->m_ohpl->setActive(false);
...
...
292
        m_dev->m_ohrd->setActive(false);
293
        m_dev->m_ohrd->setActive(false);
293
    } else if (m_dev->m_sndrcv && m_dev->m_ohpl &&
294
    } else if (m_dev->m_sndrcv && m_dev->m_ohpl &&
294
               !curtp.compare("Playlist") &&
295
               !curtp.compare("Playlist") &&
295
               !curnm.compare(SndRcvPLName)) {
296
               !curnm.compare(SndRcvPLName)) {
296
        m_dev->m_ohpl->setActive(false);
297
        m_dev->m_ohpl->setActive(false);
297
        m_dev->m_sndrcv->stop();
298
        ok = m_dev->m_sndrcv->stop();
298
    } else if (m_dev->m_sndrcv && m_dev->m_ohrd &&
299
    } else if (m_dev->m_sndrcv && m_dev->m_ohrd &&
299
               !curtp.compare("Radio") &&
300
               !curtp.compare("Radio") &&
300
               !curnm.compare(SndRcvRDName)) {
301
               !curnm.compare(SndRcvRDName)) {
301
        m_dev->setRadio(false);
302
        m_dev->setRadio(false);
302
        m_dev->m_ohrd->setActive(false);
303
        m_dev->m_ohrd->setActive(false);
303
        m_dev->m_sndrcv->stop();
304
        ok = m_dev->m_sndrcv->stop();
304
    } else {
305
    } else {
305
        // External inputs managed by scripts Analog/Digital/Hdmi etc.
306
        // External inputs managed by scripts Analog/Digital/Hdmi etc.
306
        m_dev->m_sndrcv->stop();
307
        ok = m_dev->m_sndrcv->stop();
307
    }
308
    }
309
310
    if (!ok)
311
        return UPNP_E_INTERNAL_ERROR;
308
312
309
    string newtp = o_sources[sindex].first;
313
    string newtp = o_sources[sindex].first;
310
    string newnm = o_sources[sindex].second;
314
    string newnm = o_sources[sindex].second;
311
    if (m_dev->m_ohpl && !newnm.compare("Playlist")) {
315
    if (m_dev->m_ohpl && !newnm.compare("Playlist")) {
312
        m_dev->m_ohpl->setActive(true);
316
        m_dev->m_ohpl->setActive(true);
...
...
315
    } else if (m_dev->m_ohrd && !newnm.compare("Radio")) {
319
    } else if (m_dev->m_ohrd && !newnm.compare("Radio")) {
316
        m_dev->setRadio(true);
320
        m_dev->setRadio(true);
317
        m_dev->m_ohrd->setActive(true);
321
        m_dev->m_ohrd->setActive(true);
318
    } else if (m_dev->m_ohpl && m_dev->m_sndrcv &&
322
    } else if (m_dev->m_ohpl && m_dev->m_sndrcv &&
319
               !newnm.compare(SndRcvPLName)) {
323
               !newnm.compare(SndRcvPLName)) {
320
        m_dev->m_sndrcv->start(string(), 0 /*savedms*/);
324
        ok = m_dev->m_sndrcv->start(string(), 0 /*savedms*/);
321
        m_dev->m_ohpl->setActive(true);
325
        m_dev->m_ohpl->setActive(true);
322
    } else if (m_dev->m_ohrd && m_dev->m_sndrcv &&
326
    } else if (m_dev->m_ohrd && m_dev->m_sndrcv &&
323
               !newnm.compare(SndRcvRDName)) {
327
               !newnm.compare(SndRcvRDName)) {
324
        m_dev->m_sndrcv->start(string());
328
        ok = m_dev->m_sndrcv->start(string());
325
        m_dev->m_ohrd->setActive(true);
329
        m_dev->m_ohrd->setActive(true);
326
    } else {
330
    } else {
327
        string sname = newtp + "-" + newnm;
331
        string sname = newtp + "-" + newnm;
328
        string spath = path_cat(scripts_dir, sname);
332
        string spath = path_cat(scripts_dir, sname);
329
        m_dev->m_sndrcv->start(spath);
333
        ok = m_dev->m_sndrcv->start(spath);
330
    }
334
    }
331
    m_sourceIndex = sindex;
335
    m_sourceIndex = sindex;
332
336
333
    m_dev->loopWakeup();
337
    m_dev->loopWakeup();
334
338
335
    return UPNP_E_SUCCESS;
339
    return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
336
}
340
}
337
341
338
int OHProduct::setSourceIndex(const SoapIncoming& sc, SoapOutgoing&)
342
int OHProduct::setSourceIndex(const SoapIncoming& sc, SoapOutgoing&)
339
{
343
{
340
    LOGDEB("OHProduct::setSourceIndex" << endl);
344
    LOGDEB("OHProduct::setSourceIndex" << endl);
...
...
412
static void listScripts(vector<pair<string, string> >& sources)
416
static void listScripts(vector<pair<string, string> >& sources)
413
{
417
{
414
    if (!g_config)
418
    if (!g_config)
415
        return;
419
        return;
416
420
417
    {
418
        std::unique_lock<std::mutex>(g_configlock);
419
        g_config->get("ohsrc_scripts_dir", scripts_dir);
421
    g_config->get("ohsrc_scripts_dir", scripts_dir);
420
    }
421
422
422
    DIR *dirp = opendir(scripts_dir.c_str());
423
    DIR *dirp = opendir(scripts_dir.c_str());
423
    if (dirp == 0) {
424
    if (dirp == 0) {
424
        LOGERR("Error opening scripts dir " << scripts_dir << " errno " <<
425
        LOGERR("Error opening scripts dir " << scripts_dir << " errno " <<
425
               errno << endl);
426
               errno << endl);