Switch to unified view

a/src/ohproduct.cxx b/src/ohproduct.cxx
...
...
243
           " new " << sindex << endl);
243
           " new " << sindex << endl);
244
    if (sindex < 0 || sindex >= int(o_sources.size())) {
244
    if (sindex < 0 || sindex >= int(o_sources.size())) {
245
        LOGERR("OHProduct::setSourceIndex: bad index: " << sindex << endl);
245
        LOGERR("OHProduct::setSourceIndex: bad index: " << sindex << endl);
246
        return UPNP_E_INVALID_PARAM;
246
        return UPNP_E_INVALID_PARAM;
247
    }
247
    }
248
    if (m_sourceIndex != sindex) {
248
    if (m_sourceIndex == sindex) {
249
        return UPNP_E_SUCCESS;
250
    }
249
251
250
        const MpdStatus& mpds = m_dev->getMpdStatus();
252
    const MpdStatus& mpds = m_dev->getMpdStatus();
251
        int savedms = mpds.songelapsedms;
253
    int savedms = mpds.songelapsedms;
252
254
    
253
        m_dev->m_ohif->setMetatext("");
255
    m_dev->m_ohif->setMetatext("");
254
256
255
        string curtp = o_sources[m_sourceIndex].first;
257
    string curtp = o_sources[m_sourceIndex].first;
256
        string curnm = o_sources[m_sourceIndex].second;
258
    string curnm = o_sources[m_sourceIndex].second;
257
        if (m_dev->m_ohpl && !curtp.compare("Playlist") &&
259
    if (m_dev->m_ohpl && !curtp.compare("Playlist") &&
258
            !curnm.compare("Playlist")) {
260
        !curnm.compare("Playlist")) {
259
            m_dev->m_ohpl->iStop();
261
        m_dev->m_ohpl->iStop();
260
            m_dev->m_ohpl->setActive(false);
262
        m_dev->m_ohpl->setActive(false);
261
        } else if (m_dev->m_ohrcv && !curtp.compare("Receiver") &&
263
    } else if (m_dev->m_ohrcv && !curtp.compare("Receiver") &&
262
            !curnm.compare("Receiver")) {
264
               !curnm.compare("Receiver")) {
263
            m_dev->m_ohrcv->iStop();
265
        m_dev->m_ohrcv->iStop();
264
            m_dev->m_ohrcv->setActive(false);
266
        m_dev->m_ohrcv->setActive(false);
265
        } else if (m_dev->m_ohrd && !curtp.compare("Radio") &&
267
    } else if (m_dev->m_ohrd && !curtp.compare("Radio") &&
266
            !curnm.compare("Radio")) {
268
               !curnm.compare("Radio")) {
267
            m_dev->m_ohrd->iStop();
269
        m_dev->m_ohrd->iStop();
268
            m_dev->m_ohrd->setActive(false);
270
        m_dev->m_ohrd->setActive(false);
269
        } else if (m_dev->m_sndrcv && m_dev->m_ohpl &&
271
    } else if (m_dev->m_sndrcv && m_dev->m_ohpl &&
270
                   !curtp.compare("Playlist") &&
272
               !curtp.compare("Playlist") &&
271
                   !curnm.compare(SndRcvPLName)) {
273
               !curnm.compare(SndRcvPLName)) {
272
            m_dev->m_sndrcv->stop();
274
        m_dev->m_sndrcv->stop();
273
            m_dev->m_ohpl->setActive(false);
275
        m_dev->m_ohpl->setActive(false);
274
        } else if (m_dev->m_sndrcv && m_dev->m_ohrd &&
276
    } else if (m_dev->m_sndrcv && m_dev->m_ohrd &&
275
                   !curtp.compare("Radio") &&
277
               !curtp.compare("Radio") &&
276
                   !curnm.compare(SndRcvRDName)) {
278
               !curnm.compare(SndRcvRDName)) {
277
            m_dev->m_ohrd->setActive(false);
279
        m_dev->m_ohrd->setActive(false);
278
            m_dev->m_sndrcv->stop();
280
        m_dev->m_sndrcv->stop();
279
        } else {
281
    } else {
280
            // External inputs managed by scripts Analog/Digital/Hdmi etc.
282
        // External inputs managed by scripts Analog/Digital/Hdmi etc.
281
            m_dev->m_sndrcv->stop();
283
        m_dev->m_sndrcv->stop();
282
        }
284
    }
283
285
284
        string newtp = o_sources[sindex].first;
286
    string newtp = o_sources[sindex].first;
285
        string newnm = o_sources[sindex].second;
287
    string newnm = o_sources[sindex].second;
286
        if (m_dev->m_ohpl && !newnm.compare("Playlist")) {
288
    if (m_dev->m_ohpl && !newnm.compare("Playlist")) {
287
            m_dev->m_ohpl->setActive(true);
289
        m_dev->m_ohpl->setActive(true);
288
        } else if (m_dev->m_ohrcv && !newnm.compare("Receiver")) {
290
    } else if (m_dev->m_ohrcv && !newnm.compare("Receiver")) {
289
            m_dev->m_ohrcv->setActive(true);
291
        m_dev->m_ohrcv->setActive(true);
290
        } else if (m_dev->m_ohrd && !newnm.compare("Radio")) {
292
    } else if (m_dev->m_ohrd && !newnm.compare("Radio")) {
291
            m_dev->m_ohrd->setActive(true);
293
        m_dev->m_ohrd->setActive(true);
292
        } else if (m_dev->m_ohpl && m_dev->m_sndrcv &&
294
    } else if (m_dev->m_ohpl && m_dev->m_sndrcv &&
293
                   !newnm.compare(SndRcvPLName)) {
295
               !newnm.compare(SndRcvPLName)) {
294
            m_dev->m_ohpl->setActive(true);
296
        m_dev->m_ohpl->setActive(true);
295
            m_dev->m_sndrcv->start(string(), savedms);
297
        m_dev->m_sndrcv->start(string(), savedms);
296
        } else if (m_dev->m_ohrd && m_dev->m_sndrcv &&
298
    } else if (m_dev->m_ohrd && m_dev->m_sndrcv &&
297
                   !newnm.compare(SndRcvRDName)) {
299
               !newnm.compare(SndRcvRDName)) {
298
            m_dev->m_ohrd->setActive(true);
300
        m_dev->m_ohrd->setActive(true);
299
            m_dev->m_sndrcv->start(string());
301
        m_dev->m_sndrcv->start(string());
300
        } else {
302
    } else {
301
            string sname = newtp + "-" + newnm;
303
        string sname = newtp + "-" + newnm;
302
            string spath = path_cat(scripts_dir, sname);
304
        string spath = path_cat(scripts_dir, sname);
303
            m_dev->m_sndrcv->start(spath);
305
        m_dev->m_sndrcv->start(spath);
304
        }
306
    }
305
        m_sourceIndex = sindex;
307
    m_sourceIndex = sindex;
306
308
307
        m_dev->loopWakeup();
309
    m_dev->loopWakeup();
308
    }
310
309
    return UPNP_E_SUCCESS;
311
    return UPNP_E_SUCCESS;
310
}
312
}
311
313
312
int OHProduct::setSourceIndex(const SoapIncoming& sc, SoapOutgoing&)
314
int OHProduct::setSourceIndex(const SoapIncoming& sc, SoapOutgoing&)
313
{
315
{