Switch to unified view

a/upmpd/upmpd.cxx b/upmpd/upmpd.cxx
...
...
1055
static const string 
1055
static const string 
1056
myProtocolInfo(
1056
myProtocolInfo(
1057
    "http-get:*:audio/wav:*,"
1057
    "http-get:*:audio/wav:*,"
1058
    "http-get:*:audio/wave:*,"
1058
    "http-get:*:audio/wave:*,"
1059
    "http-get:*:audio/x-wav:*,"
1059
    "http-get:*:audio/x-wav:*,"
1060
  "http-get:*:audio/x-aiff:*,"
1060
    "http-get:*:audio/mpeg:*,"
1061
    "http-get:*:audio/mpeg:*,"
1061
    "http-get:*:audio/x-mpeg:*,"
1062
    "http-get:*:audio/x-mpeg:*,"
1062
    "http-get:*:audio/mp1:*,"
1063
    "http-get:*:audio/mp1:*,"
1063
    "http-get:*:audio/aac:*,"
1064
    "http-get:*:audio/aac:*,"
1064
    "http-get:*:audio/flac:*,"
1065
    "http-get:*:audio/flac:*,"
...
...
1190
1191
1191
int main(int argc, char *argv[])
1192
int main(int argc, char *argv[])
1192
{
1193
{
1193
    string mpdhost("localhost");
1194
    string mpdhost("localhost");
1194
    int mpdport = 6600;
1195
    int mpdport = 6600;
1195
    // string upnplogfilename("/tmp/upmpd_libupnp.log");
1196
    string upnplogfilename("/tmp/upmpdcli_libupnp.log");
1196
    string logfilename;
1197
    string logfilename;
1197
    int loglevel(upnppdebug::Logger::LLINF);
1198
    int loglevel(upnppdebug::Logger::LLINF);
1198
    string configfile;
1199
    string configfile;
1199
    string friendlyname(dfltFriendlyName);
1200
    string friendlyname(dfltFriendlyName);
1200
    bool ownqueue = true;
1201
    bool ownqueue = true;
...
...
1304
    }
1305
    }
1305
1306
1306
    if (geteuid() == 0) {
1307
    if (geteuid() == 0) {
1307
        // Need to rewrite pid, it may have changed with the daemon call
1308
        // Need to rewrite pid, it may have changed with the daemon call
1308
        pidfile.write_pid();
1309
        pidfile.write_pid();
1310
      if (!logfilename.empty() && logfilename.compare("stderr")) {
1311
          if (chown(logfilename.c_str(), runas, -1) < 0) {
1312
              LOGERR("chown("<<logfilename<<") : errno : " << errno << endl);
1313
          }
1314
      }
1309
        if (setuid(runas) < 0) {
1315
        if (setuid(runas) < 0) {
1310
            LOGFAT("Can't set my uid to " << runas << " current: " << geteuid()
1316
            LOGFAT("Can't set my uid to " << runas << " current: " << geteuid()
1311
                   << endl);
1317
                   << endl);
1312
            return 1;
1318
            return 1;
1313
        }
1319
        }
1314
    }
1320
    }
1315
1321
1316
    // Initialize libupnpp, and check health
1322
    // Initialize libupnpp, and check health
1323
  LibUPnP *mylib = 0;
1324
  int libretrysecs = 10;
1325
    for (;;) {
1326
      // Libupnp init fails if we're started at boot and the network
1327
      // is not ready yet. So retry this forever
1317
    LibUPnP *mylib = LibUPnP::getLibUPnP(true);
1328
      mylib = LibUPnP::getLibUPnP(true);
1318
    if (!mylib) {
1329
     if (mylib) {
1319
      LOGFAT("Can't get LibUPnP" << endl);
1330
          break;
1320
      return 1;
1321
    }
1331
     }
1332
      sleep(libretrysecs);
1333
      libretrysecs = MIN(2*libretrysecs, 120);
1334
  }
1335
1322
    if (!mylib->ok()) {
1336
    if (!mylib->ok()) {
1323
        LOGFAT("Lib init failed: " <<
1337
        LOGFAT("Lib init failed: " <<
1324
               mylib->errAsString("main", mylib->getInitError()) << endl);
1338
               mylib->errAsString("main", mylib->getInitError()) << endl);
1325
        return 1;
1339
        return 1;
1326
    }
1340
    }
1327
    // mylib->setLogFileName(upnplogfilename, LibUPnP::LogLevelDebug);
1341
    //mylib->setLogFileName(upnplogfilename, LibUPnP::LogLevelDebug);
1328
1342
1329
    // Initialize MPD client module
1343
    // Initialize MPD client module
1330
    MPDCli mpdcli(mpdhost, mpdport);
1344
    MPDCli mpdcli(mpdhost, mpdport);
1331
    if (!mpdcli.ok()) {
1345
    if (!mpdcli.ok()) {
1332
        LOGFAT("MPD connection failed" << endl);
1346
        LOGFAT("MPD connection failed" << endl);