Switch to unified view

a/src/ohreceiver.cxx b/src/ohreceiver.cxx
...
...
144
    }
144
    }
145
    if (m_metadata.empty()) {
145
    if (m_metadata.empty()) {
146
        LOGERR("OHReceiver::play: no metadata" << endl);
146
        LOGERR("OHReceiver::play: no metadata" << endl);
147
        return UPNP_E_INTERNAL_ERROR;
147
        return UPNP_E_INTERNAL_ERROR;
148
    }
148
    }
149
150
    m_dev->m_mpdcli->stop();
151
152
    int id = -1;
153
    unordered_map<int, string> urlmap;
154
    string line;
149
        
155
        
150
    // We start the songcast command to receive the audio flux and
156
    // We start the songcast command to receive the audio flux and
151
    // export it as HTTP, then insert http URI at the front of the
157
    // export it as HTTP, then insert http URI at the front of the
152
    // queue and execute next/play
158
    // queue and execute next/play
153
    if (m_cmd)
159
    if (m_cmd)
...
...
155
    m_cmd = shared_ptr<ExecCmd>(new ExecCmd());
161
    m_cmd = shared_ptr<ExecCmd>(new ExecCmd());
156
    vector<string> args;
162
    vector<string> args;
157
    args.push_back("-u");
163
    args.push_back("-u");
158
    args.push_back(m_uri);
164
    args.push_back(m_uri);
159
    LOGDEB("OHReceiver::play: executing scmpdcli" << endl);
165
    LOGDEB("OHReceiver::play: executing scmpdcli" << endl);
160
    ok = m_cmd->startExec("scmpdcli", args, false, false) >= 0;
166
    ok = m_cmd->startExec("scmpdcli", args, false, true) >= 0;
161
    if (!ok) {
167
    if (!ok) {
162
        LOGERR("OHReceiver::play: executing scmpdcli failed" <<endl);
168
        LOGERR("OHReceiver::play: executing scmpdcli failed" <<endl);
163
        goto out;
169
        goto out;
164
    } else {
170
    } else {
165
        LOGDEB("OHReceiver::play: scmpdcli pid "<< m_cmd->getChildPid()<< endl);
171
        LOGDEB("OHReceiver::play: scmpdcli pid "<< m_cmd->getChildPid()<< endl);
166
    }
172
    }
173
    // Wait for scmpdcli to signal ready, then play
174
    m_cmd->getline(line);
175
    LOGDEB("OHReceiver got " << line << " from scmpdcli" << endl);
167
176
168
    // And insert the appropriate uri in the mpd playlist
177
    // And insert the appropriate uri in the mpd playlist
169
    ok = m_pl->insertUri(0, m_httpuri, SoapHelp::xmlUnquote(m_metadata));
178
    if (!m_pl->urlMap(urlmap)) {
170
    if (!ok) {
171
        LOGERR("OHReceiver::play: insertUri() failed\n");
179
        LOGERR("OHReceiver::play: urlMap() failed" <<endl);
172
        goto out;
180
        goto out;
173
    }
181
    }
182
    for (auto it = urlmap.begin(); it != urlmap.end(); it++) {
183
        if (it->second == m_httpuri) {
184
            id = it->first;
185
        }
186
    }
187
    if (id == -1) {
188
        ok = m_pl->insertUri(0, m_httpuri, SoapHelp::xmlUnquote(m_metadata),
189
            &id);
190
        if (!ok) {
191
            LOGERR("OHReceiver::play: insertUri() failed\n");
192
            goto out;
193
        }
194
    }
195
174
    ok = m_dev->m_mpdcli->play(0);
196
    ok = m_dev->m_mpdcli->playId(id);
175
    if (!ok) {
197
    if (!ok) {
176
        LOGERR("OHReceiver::play: play() failed\n");
198
        LOGERR("OHReceiver::play: play() failed\n");
177
        goto out;
199
        goto out;
178
    }
200
    }
179
201
180
    maybeWakeUp(ok);
202
    maybeWakeUp(ok);
181
203
182
out:
204
out:
205
    if (!ok) {
206
        iStop();
207
    }
183
    return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
208
    return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
184
}
209
}
185
210
211
bool OHReceiver::iStop()
212
{
213
    if (m_cmd) {
214
        m_cmd->zapChild();
215
        m_cmd = shared_ptr<ExecCmd>(0);
216
    }
217
    return m_dev->m_mpdcli->stop();
218
}
219
186
int OHReceiver::stop(const SoapArgs& sc, SoapData& data)
220
int OHReceiver::stop(const SoapArgs& sc, SoapData& data)
187
{
221
{
188
    LOGDEB("OHReceiver::stop" << endl);
222
    LOGDEB("OHReceiver::stop" << endl);
189
    bool ok = false;
223
    bool ok = iStop();
190
    m_cmd->zapChild();
191
    m_cmd = shared_ptr<ExecCmd>(0);
192
    ok = m_dev->m_mpdcli->stop();
193
    maybeWakeUp(ok);
224
    maybeWakeUp(ok);
194
    return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
225
    return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
195
}
226
}
196
227
197
int OHReceiver::setSender(const SoapArgs& sc, SoapData& data)
228
int OHReceiver::setSender(const SoapArgs& sc, SoapData& data)