|
a/src/sc2mpd.cpp |
|
b/src/sc2mpd.cpp |
|
... |
|
... |
93 |
using namespace OpenHome::Av;
|
93 |
using namespace OpenHome::Av;
|
94 |
|
94 |
|
95 |
|
95 |
|
96 |
class OhmReceiverDriver : public IOhmReceiverDriver, public IOhmMsgProcessor {
|
96 |
class OhmReceiverDriver : public IOhmReceiverDriver, public IOhmMsgProcessor {
|
97 |
public:
|
97 |
public:
|
98 |
OhmReceiverDriver(AudioEater* eater, int port, const string&);
|
98 |
OhmReceiverDriver(AudioEater* eater, AudioEater::Context *ctxt);
|
99 |
|
99 |
|
100 |
private:
|
100 |
private:
|
101 |
// IOhmReceiverDriver
|
101 |
// IOhmReceiverDriver
|
102 |
virtual void Add(OhmMsg& aMsg);
|
102 |
virtual void Add(OhmMsg& aMsg);
|
103 |
virtual void Timestamp(OhmMsg& aMsg);
|
103 |
virtual void Timestamp(OhmMsg& aMsg);
|
|
... |
|
... |
139 |
};
|
139 |
};
|
140 |
Observer m_obs;
|
140 |
Observer m_obs;
|
141 |
AudioEater *m_eater;
|
141 |
AudioEater *m_eater;
|
142 |
};
|
142 |
};
|
143 |
|
143 |
|
144 |
OhmReceiverDriver::OhmReceiverDriver(AudioEater *eater, int port,
|
144 |
OhmReceiverDriver::OhmReceiverDriver(AudioEater *eater,
|
145 |
const string& ad)
|
145 |
AudioEater::Context *ctxt)
|
146 |
: m_eater(eater)
|
146 |
: m_eater(eater)
|
147 |
{
|
147 |
{
|
148 |
AudioEater::Context *ctxt = new AudioEater::Context(&audioqueue, port);
|
|
|
149 |
ctxt->alsadevice = ad;
|
|
|
150 |
audioqueue.start(1, m_eater->worker, ctxt);
|
148 |
audioqueue.start(1, m_eater->worker, ctxt);
|
151 |
}
|
149 |
}
|
152 |
|
150 |
|
153 |
void OhmReceiverDriver::Add(OhmMsg& aMsg)
|
151 |
void OhmReceiverDriver::Add(OhmMsg& aMsg)
|
154 |
{
|
152 |
{
|
|
... |
|
... |
263 |
LOGDEB("OhmReceiverDriver::Process: empty message\n");
|
261 |
LOGDEB("OhmReceiverDriver::Process: empty message\n");
|
264 |
return;
|
262 |
return;
|
265 |
}
|
263 |
}
|
266 |
|
264 |
|
267 |
m_obs.process(aMsg);
|
265 |
m_obs.process(aMsg);
|
|
|
266 |
if (aMsg.Halt()) {
|
|
|
267 |
return;
|
|
|
268 |
}
|
268 |
|
269 |
|
269 |
unsigned int bytes = aMsg.Audio().Bytes();
|
270 |
unsigned int bytes = aMsg.Audio().Bytes();
|
270 |
char *buf = (char *)malloc(bytes);
|
271 |
char *buf = (char *)malloc(bytes);
|
271 |
if (buf == 0) {
|
272 |
if (buf == 0) {
|
272 |
LOGERR("OhmReceiverDriver::Process: can't allocate " <<
|
273 |
LOGERR("OhmReceiverDriver::Process: can't allocate " <<
|
|
... |
|
... |
409 |
int port = 8768;
|
410 |
int port = 8768;
|
410 |
string value;
|
411 |
string value;
|
411 |
if (config.get("schttpport", value)) {
|
412 |
if (config.get("schttpport", value)) {
|
412 |
port = atoi(value.c_str());
|
413 |
port = atoi(value.c_str());
|
413 |
}
|
414 |
}
|
|
|
415 |
|
414 |
string alsadevice("default");
|
416 |
string alsadevice("default");
|
415 |
config.get("scalsadevice", alsadevice);
|
417 |
config.get("scalsadevice", alsadevice);
|
|
|
418 |
|
416 |
config.get("sclogfilename", logfilename);
|
419 |
config.get("sclogfilename", logfilename);
|
417 |
if (config.get("scloglevel", value))
|
420 |
if (config.get("scloglevel", value))
|
418 |
loglevel = atoi(value.c_str());
|
421 |
loglevel = atoi(value.c_str());
|
419 |
if (Logger::getTheLog(logfilename) == 0) {
|
422 |
if (Logger::getTheLog(logfilename) == 0) {
|
420 |
cerr << "Can't initialize log" << endl;
|
423 |
cerr << "Can't initialize log" << endl;
|
|
... |
|
... |
424 |
|
427 |
|
425 |
LOGINF("scmpdcli: using subnet " << (subnet & 0xff) << "." <<
|
428 |
LOGINF("scmpdcli: using subnet " << (subnet & 0xff) << "." <<
|
426 |
((subnet >> 8) & 0xff) << "." << ((subnet >> 16) & 0xff) << "." <<
|
429 |
((subnet >> 8) & 0xff) << "." << ((subnet >> 16) & 0xff) << "." <<
|
427 |
((subnet >> 24) & 0xff) << endl);
|
430 |
((subnet >> 24) & 0xff) << endl);
|
428 |
|
431 |
|
|
|
432 |
AudioEater::Context *ctxt = new AudioEater::Context(&audioqueue);
|
|
|
433 |
ctxt->port = port;
|
|
|
434 |
ctxt->alsadevice = alsadevice;
|
|
|
435 |
|
429 |
OhmReceiverDriver* driver = new OhmReceiverDriver(
|
436 |
OhmReceiverDriver* driver =
|
430 |
optionDevice.Value() ? &alsaAudioEater : &httpAudioEater, port,
|
437 |
new OhmReceiverDriver(optionDevice.Value() ?
|
431 |
alsadevice);
|
438 |
&alsaAudioEater : &httpAudioEater, ctxt);
|
432 |
|
439 |
|
433 |
OhmReceiver* receiver = new OhmReceiver(lib->Env(), adapter, ttl, *driver);
|
440 |
OhmReceiver* receiver = new OhmReceiver(lib->Env(), adapter, ttl, *driver);
|
434 |
|
441 |
|
435 |
CpStack* cpStack = lib->StartCp(subnet);
|
442 |
CpStack* cpStack = lib->StartCp(subnet);
|
436 |
cpStack = cpStack; // avoid unused variable warning
|
443 |
cpStack = cpStack; // avoid unused variable warning
|