|
a/src/ohsndrcv.cxx |
|
b/src/ohsndrcv.cxx |
|
... |
|
... |
42 |
// internal source -> local mpd -> fifo -> isender->Songcast
|
42 |
// internal source -> local mpd -> fifo -> isender->Songcast
|
43 |
// ssender is an arbitrary script probably reading from an audio
|
43 |
// ssender is an arbitrary script probably reading from an audio
|
44 |
// driver input and managing a sender. Our local source or mpd are
|
44 |
// driver input and managing a sender. Our local source or mpd are
|
45 |
// uninvolved
|
45 |
// uninvolved
|
46 |
Internal(UpMpd *dv, const string& starterpath, int port)
|
46 |
Internal(UpMpd *dv, const string& starterpath, int port)
|
47 |
: dev(dv), mpd(0), origmpd(0), isender(0), ssender(0),
|
|
|
48 |
makeisendercmd(starterpath), mpdport(port) {
|
47 |
: dev(dv), makeisendercmd(starterpath), mpdport(port) {
|
49 |
// Stream volume control ? This decides if the aux mpd has mixer
|
48 |
// Stream volume control ? This decides if the aux mpd has
|
50 |
// "software" or "none"
|
49 |
// mixer "software" or "none"
|
51 |
scalestream = true;
|
|
|
52 |
std::unique_lock<std::mutex>(g_configlock);
|
50 |
std::unique_lock<std::mutex>(g_configlock);
|
53 |
string value;
|
51 |
string value;
|
54 |
if (g_config->get("scstreamscaled", value)) {
|
52 |
if (g_config->get("scstreamscaled", value)) {
|
55 |
scalestream = atoi(value.c_str()) != 0;
|
53 |
scalestream = atoi(value.c_str()) != 0;
|
56 |
}
|
54 |
}
|
|
... |
|
... |
69 |
deleteZ(mpd);
|
67 |
deleteZ(mpd);
|
70 |
deleteZ(isender);
|
68 |
deleteZ(isender);
|
71 |
deleteZ(ssender);
|
69 |
deleteZ(ssender);
|
72 |
}
|
70 |
}
|
73 |
UpMpd *dev;
|
71 |
UpMpd *dev;
|
74 |
MPDCli *mpd;
|
72 |
MPDCli *mpd{nullptr};
|
75 |
MPDCli *origmpd;
|
73 |
MPDCli *origmpd{nullptr};
|
76 |
ExecCmd *isender;
|
74 |
ExecCmd *isender{nullptr};
|
77 |
ExecCmd *ssender;
|
75 |
ExecCmd *ssender{nullptr};
|
78 |
string iuri;
|
76 |
string iuri;
|
79 |
string imeta;
|
77 |
string imeta;
|
80 |
string makeisendercmd;
|
78 |
string makeisendercmd;
|
81 |
int mpdport;
|
79 |
int mpdport;
|
82 |
bool scalestream;
|
80 |
bool scalestream{true};
|
83 |
};
|
81 |
};
|
84 |
|
82 |
|
85 |
|
83 |
|
86 |
SenderReceiver::SenderReceiver(UpMpd *dev, const string& starterpath, int port)
|
84 |
SenderReceiver::SenderReceiver(UpMpd *dev, const string& starterpath, int port)
|
87 |
{
|
85 |
{
|
|
... |
|
... |
121 |
// Stop MPD Play (normally already done)
|
119 |
// Stop MPD Play (normally already done)
|
122 |
m->dev->m_mpdcli->stop();
|
120 |
m->dev->m_mpdcli->stop();
|
123 |
|
121 |
|
124 |
// sndcmd will non empty if we actually started a script instead
|
122 |
// sndcmd will non empty if we actually started a script instead
|
125 |
// of reusing an old one (then need to read the initial data).
|
123 |
// of reusing an old one (then need to read the initial data).
|
126 |
ExecCmd *sndcmd = 0;
|
124 |
ExecCmd *sndcmd = nullptr;
|
127 |
|
125 |
|
128 |
if (script.empty() && !m->isender) {
|
126 |
if (script.empty() && !m->isender) {
|
129 |
// Internal source, first time: Start fifo MPD and Sender
|
127 |
// Internal source, first time: Start fifo MPD and Sender
|
130 |
m->isender = sndcmd = new ExecCmd();
|
128 |
m->isender = sndcmd = new ExecCmd();
|
131 |
vector<string> args;
|
129 |
vector<string> args;
|
|
... |
|
... |
184 |
meta = m->imeta;
|
182 |
meta = m->imeta;
|
185 |
}
|
183 |
}
|
186 |
|
184 |
|
187 |
if (sndcmd && script.empty()) {
|
185 |
if (sndcmd && script.empty()) {
|
188 |
// Just started the internal source script, connect to the new MPD
|
186 |
// Just started the internal source script, connect to the new MPD
|
|
|
187 |
deleteZ(m->mpd);
|
189 |
m->mpd = new MPDCli("localhost", m->mpdport);
|
188 |
m->mpd = new MPDCli("localhost", m->mpdport);
|
190 |
if (!m->mpd || !m->mpd->ok()) {
|
189 |
if (!m->mpd || !m->mpd->ok()) {
|
191 |
LOGERR("SenderReceiver::start: can't connect to new MPD\n");
|
190 |
LOGERR("SenderReceiver::start: can't connect to new MPD\n");
|
192 |
m->clear();
|
191 |
m->clear();
|
193 |
return false;
|
192 |
return false;
|
|
... |
|
... |
237 |
m->origmpd = 0;
|
236 |
m->origmpd = 0;
|
238 |
}
|
237 |
}
|
239 |
|
238 |
|
240 |
// We don't reuse external source processes
|
239 |
// We don't reuse external source processes
|
241 |
deleteZ(m->ssender);
|
240 |
deleteZ(m->ssender);
|
|
|
241 |
// Neither internal ones any more actually (used to).
|
|
|
242 |
deleteZ(m->isender);
|
|
|
243 |
deleteZ(m->mpd);
|
242 |
return true;
|
244 |
return true;
|
243 |
}
|
245 |
}
|