Switch to unified view

a/src/ohradio.cxx b/src/ohradio.cxx
...
...
57
57
58
static vector<RadioMeta> o_radios;
58
static vector<RadioMeta> o_radios;
59
59
60
OHRadio::OHRadio(UpMpd *dev)
60
OHRadio::OHRadio(UpMpd *dev)
61
    : OHService(sTpProduct, sIdProduct, dev), m_active(false),
61
    : OHService(sTpProduct, sIdProduct, dev), m_active(false),
62
      m_id(0), m_songid(0), m_ok(false)
62
      m_id(0), m_ok(false)
63
{
63
{
64
    // Need Python
64
    // Need Python
65
    string pypath;
65
    string pypath;
66
    if (!ExecCmd::which("python2", pypath)) {
66
    if (!ExecCmd::which("python2", pypath)) {
67
        LOGINF("OHRadio: python2 not found, no radio service will be created\n");
67
        LOGINF("OHRadio: python2 not found, no radio service will be created\n");
...
...
235
        LOGDEB("OHRadio::setPlaying: audio url empty\n");
235
        LOGDEB("OHRadio::setPlaying: audio url empty\n");
236
        return UPNP_E_INTERNAL_ERROR;
236
        return UPNP_E_INTERNAL_ERROR;
237
    }
237
    }
238
238
239
    // Send url to mpd
239
    // Send url to mpd
240
    //m_dev->m_mpdcli->clearQueue();
240
    m_dev->m_mpdcli->clearQueue();
241
    UpSong song;
241
    UpSong song;
242
    song.album = o_radios[m_id].title;
242
    song.album = o_radios[m_id].title;
243
    song.uri = o_radios[m_id].uri;
243
    song.uri = o_radios[m_id].uri;
244
    if (m_songid > 0)
245
        m_dev->m_mpdcli->deleteId(m_songid);
246
    m_songid = m_dev->m_mpdcli->insert(audiourl, 0, song);
244
    if (m_dev->m_mpdcli->insert(audiourl, 0, song) < 0) {
247
    if (m_songid < 0) {
248
        m_songid = 0;
249
        LOGDEB("OHRadio::setPlaying: mpd insert failed\n");
245
        LOGDEB("OHRadio::setPlaying: mpd insert failed\n");
250
        return UPNP_E_INTERNAL_ERROR;
246
        return UPNP_E_INTERNAL_ERROR;
251
    }
247
    }
252
    m_dev->m_mpdcli->single(true);
248
    m_dev->m_mpdcli->single(true);
253
    if (!m_dev->m_mpdcli->play(0)) {
249
    if (!m_dev->m_mpdcli->play(0)) {
...
...
258
}
254
}
259
255
260
void OHRadio::setActive(bool onoff) {
256
void OHRadio::setActive(bool onoff) {
261
    m_active = onoff;
257
    m_active = onoff;
262
    if (m_active) {
258
    if (m_active) {
263
        m_dev->m_mpdcli->clearQueue();
259
        m_dev->m_mpdcli->restoreState(m_mpdsavedstate);
264
        maybeWakeUp(true);
260
        maybeWakeUp(true);
265
    } else {
261
    } else {
262
        m_dev->m_mpdcli->saveState(m_mpdsavedstate);
266
        m_dev->m_mpdcli->clearQueue();
263
        m_dev->m_mpdcli->clearQueue();
267
        m_songid = 0;
264
        iStop();
268
    }
265
    }
269
}
266
}
270
267
271
int OHRadio::iPlay()
268
int OHRadio::iPlay()
272
{
269
{