|
a/src/main.cxx |
|
b/src/main.cxx |
|
... |
|
... |
99 |
// - -m 1, RdrOnly: for the main instance: be a Renderer, do not start the
|
99 |
// - -m 1, RdrOnly: for the main instance: be a Renderer, do not start the
|
100 |
// Media Server even if the configuration indicates it is needed
|
100 |
// Media Server even if the configuration indicates it is needed
|
101 |
// (this is not used in normal situations, just edit the config
|
101 |
// (this is not used in normal situations, just edit the config
|
102 |
// instead!)
|
102 |
// instead!)
|
103 |
// - -m 2, MSOnly Media Server only, this is for the process forked/execed
|
103 |
// - -m 2, MSOnly Media Server only, this is for the process forked/execed
|
104 |
// by a main Renderer process.
|
104 |
// by a main Renderer process, or a standalone Media Server.
|
105 |
// - -m 3, Combined: for the main process: implement the Media Server
|
105 |
// - -m 3, Combined: for the main process: implement the Media Server
|
106 |
// as an embedded device. This works just fine with, for example,
|
106 |
// as an embedded device. This works just fine with, for example,
|
107 |
// upplay, but confuses most of the other Control Points.
|
107 |
// upplay, but confuses most of the other Control Points.
|
108 |
enum MSMode {Forked, RdrOnly, MSOnly, Combined};
|
108 |
enum MSMode {Forked, RdrOnly, MSOnly, Combined};
|
109 |
|
109 |
|
|
... |
|
... |
414 |
cerr << "Could not create empty config\n";
|
414 |
cerr << "Could not create empty config\n";
|
415 |
return 1;
|
415 |
return 1;
|
416 |
}
|
416 |
}
|
417 |
}
|
417 |
}
|
418 |
|
418 |
|
|
|
419 |
if (msmode == MSOnly && !enableMediaServer) {
|
|
|
420 |
cerr << "Pure Media Server mode requested, but this is "
|
|
|
421 |
"disabled by the configuration or by absent Media Server "
|
|
|
422 |
"modules.\n";
|
|
|
423 |
return 1;
|
|
|
424 |
}
|
|
|
425 |
|
419 |
if (Logger::getTheLog(logfilename) == 0) {
|
426 |
if (Logger::getTheLog(logfilename) == 0) {
|
420 |
cerr << "Can't initialize log" << endl;
|
427 |
cerr << "Can't initialize log" << endl;
|
421 |
return 1;
|
428 |
return 1;
|
422 |
}
|
429 |
}
|
423 |
Logger::getTheLog("")->setLogLevel(Logger::LogLevel(loglevel));
|
430 |
Logger::getTheLog("")->setLogLevel(Logger::LogLevel(loglevel));
|
|
... |
|
... |
453 |
if (cachedir.empty())
|
460 |
if (cachedir.empty())
|
454 |
cachedir = path_cat(path_tildexpand("~") , "/.cache/upmpdcli");
|
461 |
cachedir = path_cat(path_tildexpand("~") , "/.cache/upmpdcli");
|
455 |
}
|
462 |
}
|
456 |
|
463 |
|
457 |
string& mcfn = opts.cachefn;
|
464 |
string& mcfn = opts.cachefn;
|
458 |
// no cache access needed or desirable for a pure media renderer
|
465 |
// no cache access needed or desirable for a pure media server
|
459 |
if (!msonly && ohmetapersist) {
|
466 |
if (!msonly && ohmetapersist) {
|
460 |
opts.cachefn = path_cat(cachedir, "/metacache");
|
467 |
opts.cachefn = path_cat(cachedir, "/metacache");
|
461 |
if (!path_makepath(cachedir, 0755)) {
|
468 |
if (!path_makepath(cachedir, 0755)) {
|
462 |
LOGERR("makepath("<< cachedir << ") : errno : " << errno << endl);
|
469 |
LOGERR("makepath("<< cachedir << ") : errno : " << errno << endl);
|
463 |
} else {
|
470 |
} else {
|
|
... |
|
... |
553 |
}
|
560 |
}
|
554 |
|
561 |
|
555 |
|
562 |
|
556 |
// Initialize MPD client object. Retry until it works or power fail.
|
563 |
// Initialize MPD client object. Retry until it works or power fail.
|
557 |
MPDCli *mpdclip = 0;
|
564 |
MPDCli *mpdclip = 0;
|
|
|
565 |
bool enableL16 = false;
|
|
|
566 |
if (!msonly) {
|
558 |
int mpdretrysecs = 2;
|
567 |
int mpdretrysecs = 2;
|
559 |
for (;;) {
|
568 |
for (;;) {
|
560 |
mpdclip = new MPDCli(mpdhost, mpdport, mpdpassword);
|
569 |
mpdclip = new MPDCli(mpdhost, mpdport, mpdpassword);
|
561 |
if (mpdclip == 0) {
|
570 |
if (mpdclip == 0) {
|
562 |
LOGFAT("Can't allocate MPD client object" << endl);
|
571 |
LOGFAT("Can't allocate MPD client object" << endl);
|
563 |
return 1;
|
572 |
return 1;
|
564 |
}
|
573 |
}
|
565 |
if (!mpdclip->ok()) {
|
574 |
if (!mpdclip->ok()) {
|
566 |
LOGERR("MPD connection failed" << endl);
|
575 |
LOGERR("MPD connection failed" << endl);
|
567 |
delete mpdclip;
|
576 |
delete mpdclip;
|
568 |
mpdclip = 0;
|
577 |
mpdclip = 0;
|
569 |
sleep(mpdretrysecs);
|
578 |
sleep(mpdretrysecs);
|
570 |
mpdretrysecs = MIN(2*mpdretrysecs, 120);
|
579 |
mpdretrysecs = MIN(2*mpdretrysecs, 120);
|
571 |
} else {
|
580 |
} else {
|
572 |
break;
|
581 |
break;
|
573 |
}
|
582 |
}
|
574 |
}
|
583 |
}
|
575 |
|
|
|
576 |
const MpdStatus& mpdstat = mpdclip->getStatus();
|
584 |
const MpdStatus& mpdstat = mpdclip->getStatus();
|
577 |
// Only the "special" upmpdcli 0.19.16 version has patch != 0
|
585 |
// Only the "special" upmpdcli 0.19.16 version has patch != 0
|
578 |
bool enableL16 = mpdstat.versmajor >= 1 || mpdstat.versminor >= 20 ||
|
586 |
enableL16 = mpdstat.versmajor >= 1 || mpdstat.versminor >= 20 ||
|
579 |
mpdstat.verspatch >= 16;
|
587 |
mpdstat.verspatch >= 16;
|
|
|
588 |
}
|
|
|
589 |
|
580 |
|
590 |
|
581 |
// Initialize libupnpp, and check health
|
591 |
// Initialize libupnpp, and check health
|
582 |
LibUPnP *mylib = 0;
|
592 |
LibUPnP *mylib = 0;
|
583 |
string hwaddr;
|
593 |
string hwaddr;
|
584 |
int libretrysecs = 10;
|
594 |
int libretrysecs = 10;
|