|
a/src/mpdcli.cxx |
|
b/src/mpdcli.cxx |
|
... |
|
... |
29 |
#include "libupnpp/log.hxx"
|
29 |
#include "libupnpp/log.hxx"
|
30 |
|
30 |
|
31 |
#include "upmpd.hxx"
|
31 |
#include "upmpd.hxx"
|
32 |
#include "conftree.hxx"
|
32 |
#include "conftree.hxx"
|
33 |
#include "execmd.h"
|
33 |
#include "execmd.h"
|
|
|
34 |
#include "upmpdutils.hxx"
|
34 |
|
35 |
|
35 |
struct mpd_status;
|
36 |
struct mpd_status;
|
36 |
|
37 |
|
37 |
using namespace std;
|
38 |
using namespace std;
|
38 |
using namespace UPnPP;
|
39 |
using namespace UPnPP;
|
|
... |
|
... |
56 |
|
57 |
|
57 |
UPnPP::PTMutexLocker conflock(g_configlock);
|
58 |
UPnPP::PTMutexLocker conflock(g_configlock);
|
58 |
g_config->get("onstart", m_onstart);
|
59 |
g_config->get("onstart", m_onstart);
|
59 |
g_config->get("onplay", m_onplay);
|
60 |
g_config->get("onplay", m_onplay);
|
60 |
g_config->get("onstop", m_onstop);
|
61 |
g_config->get("onstop", m_onstop);
|
|
|
62 |
string scratch;
|
61 |
g_config->get("onvolumechange", m_onvolumechange);
|
63 |
g_config->get("onvolumechange", scratch);
|
|
|
64 |
stringToStrings(scratch, m_onvolumechange);
|
62 |
g_config->get("getexternalvolume", m_getexternalvolume);
|
65 |
g_config->get("getexternalvolume", scratch);
|
|
|
66 |
stringToStrings(scratch, m_getexternalvolume);
|
|
|
67 |
|
63 |
m_externalvolumecontrol = false;
|
68 |
m_externalvolumecontrol = false;
|
64 |
string value;
|
69 |
string value;
|
65 |
if (g_config->get("externalvolumecontrol", value)) {
|
70 |
if (g_config->get("externalvolumecontrol", value)) {
|
66 |
m_externalvolumecontrol = atoi(value.c_str()) != 0;
|
71 |
m_externalvolumecontrol = atoi(value.c_str()) != 0;
|
67 |
}
|
72 |
}
|
|
... |
|
... |
179 |
return false;
|
184 |
return false;
|
180 |
}
|
185 |
}
|
181 |
|
186 |
|
182 |
if (m_externalvolumecontrol && !m_getexternalvolume.empty()) {
|
187 |
if (m_externalvolumecontrol && !m_getexternalvolume.empty()) {
|
183 |
string result;
|
188 |
string result;
|
184 |
vector<string> cmd;
|
|
|
185 |
cmd.push_back(m_getexternalvolume);
|
|
|
186 |
if (ExecCmd::backtick(cmd, result)) {
|
189 |
if (ExecCmd::backtick(m_getexternalvolume, result)) {
|
187 |
//LOGDEB("MPDCli::volume retrieved: " << result << endl);
|
190 |
//LOGDEB("MPDCli::volume retrieved: " << result << endl);
|
188 |
m_stat.volume = atoi(result.c_str());
|
191 |
m_stat.volume = atoi(result.c_str());
|
189 |
} else {
|
192 |
} else {
|
190 |
LOGERR("MPDCli::updStatus: error retrieving volume: " <<
|
193 |
LOGERR("MPDCli::updStatus: error retrieving volume: " <<
|
191 |
m_getexternalvolume << " failed\n");
|
194 |
m_getexternalvolume[0] << " failed\n");
|
192 |
}
|
195 |
}
|
193 |
} else {
|
196 |
} else {
|
194 |
m_stat.volume = mpd_status_get_volume(mpds);
|
197 |
m_stat.volume = mpd_status_get_volume(mpds);
|
195 |
}
|
198 |
}
|
196 |
if (m_stat.volume >= 0) {
|
199 |
if (m_stat.volume >= 0) {
|
|
... |
|
... |
480 |
if (!(m_externalvolumecontrol)) {
|
483 |
if (!(m_externalvolumecontrol)) {
|
481 |
RETRY_CMD(mpd_run_set_volume(M_CONN, volume));
|
484 |
RETRY_CMD(mpd_run_set_volume(M_CONN, volume));
|
482 |
}
|
485 |
}
|
483 |
if (!m_onvolumechange.empty()) {
|
486 |
if (!m_onvolumechange.empty()) {
|
484 |
ExecCmd ecmd;
|
487 |
ExecCmd ecmd;
|
485 |
vector<string> args;
|
488 |
vector<string> args = m_onvolumechange;
|
486 |
stringstream ss;
|
489 |
stringstream ss;
|
487 |
ss << volume;
|
490 |
ss << volume;
|
488 |
args.push_back(ss.str());
|
491 |
args.push_back(ss.str());
|
489 |
if (ecmd.doexec(m_onvolumechange, args)) {
|
492 |
if (ecmd.doexec1(args)) {
|
490 |
// doexec returns the exit status, should be zero
|
493 |
// doexec returns the exit status, should be zero
|
491 |
LOGDEB("MPDCli::setVolume: " << m_onvolumechange <<
|
494 |
LOGDEB("MPDCli::setVolume: " << m_onvolumechange[0] <<
|
492 |
" failed " << volume << endl);
|
495 |
" failed " << volume << endl);
|
493 |
}
|
496 |
}
|
494 |
}
|
497 |
}
|
495 |
m_stat.volume = volume;
|
498 |
m_stat.volume = volume;
|
496 |
m_cachedvolume = volume;
|
499 |
m_cachedvolume = volume;
|