|
a/src/mpdcli.cxx |
|
b/src/mpdcli.cxx |
|
... |
|
... |
30 |
using namespace UPnPP;
|
30 |
using namespace UPnPP;
|
31 |
|
31 |
|
32 |
#define M_CONN ((struct mpd_connection *)m_conn)
|
32 |
#define M_CONN ((struct mpd_connection *)m_conn)
|
33 |
|
33 |
|
34 |
MPDCli::MPDCli(const string& host, int port, const string& pass,
|
34 |
MPDCli::MPDCli(const string& host, int port, const string& pass,
|
35 |
const string& onstart, const string& onstop)
|
35 |
const string& onstart, const string& onstop,
|
|
|
36 |
const string& onvolumechange)
|
36 |
: m_conn(0), m_ok(false), m_premutevolume(0), m_cachedvolume(50),
|
37 |
: m_conn(0), m_ok(false), m_premutevolume(0), m_cachedvolume(50),
|
37 |
m_host(host), m_port(port), m_password(pass), m_onstart(onstart),
|
38 |
m_host(host), m_port(port), m_password(pass), m_onstart(onstart),
|
38 |
m_onstop(onstop), m_lastinsertid(-1), m_lastinsertpos(-1),
|
39 |
m_onstop(onstop), m_onvolumechange(onvolumechange), m_lastinsertid(-1),
|
39 |
m_lastinsertqvers(-1)
|
40 |
m_lastinsertpos(-1), m_lastinsertqvers(-1)
|
40 |
{
|
41 |
{
|
41 |
regcomp(&m_tpuexpr, "^[[:alpha:]]+://.+", REG_EXTENDED|REG_NOSUB);
|
42 |
regcomp(&m_tpuexpr, "^[[:alpha:]]+://.+", REG_EXTENDED|REG_NOSUB);
|
42 |
if (!openconn()) {
|
43 |
if (!openconn()) {
|
43 |
return;
|
44 |
return;
|
44 |
}
|
45 |
}
|
|
... |
|
... |
363 |
volume = 0;
|
364 |
volume = 0;
|
364 |
else if (volume > 100)
|
365 |
else if (volume > 100)
|
365 |
volume = 100;
|
366 |
volume = 100;
|
366 |
|
367 |
|
367 |
RETRY_CMD(mpd_run_set_volume(M_CONN, volume));
|
368 |
RETRY_CMD(mpd_run_set_volume(M_CONN, volume));
|
|
|
369 |
if (!m_onvolumechange.empty()) {
|
|
|
370 |
char buf[256];
|
|
|
371 |
int n = snprintf(buf, sizeof buf, "%s %i", m_onvolumechange.c_str(),
|
|
|
372 |
volume);
|
|
|
373 |
if (!(n >= 0 && n < 256 && system(buf) != 0)) {
|
|
|
374 |
// The command has not been completely written to the buffer or
|
|
|
375 |
// the command has not run successfully.
|
|
|
376 |
LOGERR("MPDCli::setVolume: " << m_onvolumechange << " failed "
|
|
|
377 |
<< endl);
|
|
|
378 |
}
|
|
|
379 |
}
|
368 |
m_stat.volume = volume;
|
380 |
m_stat.volume = volume;
|
369 |
m_cachedvolume = volume;
|
381 |
m_cachedvolume = volume;
|
370 |
return true;
|
382 |
return true;
|
371 |
}
|
383 |
}
|
372 |
|
384 |
|