[mythtv] [Micropatch] tiny code cleanup.
michael at optusnet.com.au
michael at optusnet.com.au
Sat May 24 18:30:57 EDT 2003
(I'm just reading through the code trying to get
a feel for how it works. These changes are just tiny
things I noticed while reading. Worth what you paid for
them).
Micropatch: Change logic slightly in mythbackend/main.cpp
to remove duplicated code.
Reduces code size only; No functionality change.
Adds a brief comment.
diff -c -r mythtv-1/programs/mythbackend/main.cpp mythtv-2/programs/mythbackend/main.cpp
*** mythtv-1/programs/mythbackend/main.cpp 2003-05-23 15:49:40.000000000 +1000
--- mythtv-2/programs/mythbackend/main.cpp 2003-05-23 15:54:24.000000000 +1000
***************
*** 23,28 ****
--- 23,34 ----
QMap<int, EncoderLink *> tvList;
MythContext *gContext;
+ /*
+ * setupTVs().
+ * For each local capture card, create the encoder objects.
+ * If this is the master machine, also create an encoder object
+ * for each remote capture card.
+ */
void setupTVs(bool ismaster)
{
QString localhostname = gContext->GetHostName();
***************
*** 31,82 ****
query.exec("SELECT cardid,hostname FROM capturecard ORDER BY cardid;");
! if (query.isActive() && query.numRowsAffected())
{
! while (query.next())
! {
! int cardid = query.value(0).toInt();
! QString host = query.value(1).toString();
! if (host.isNull() || host.isEmpty())
! {
! cerr << "One of your capturecard entries does not have a "
! << "hostname.\n Please run setup and confirm all of the "
! << "capture cards.\n";
! exit(-1);
! }
! if (!ismaster)
! {
! if (host == localhostname)
! {
! TVRec *tv = new TVRec(cardid);
! tv->Init();
! EncoderLink *enc = new EncoderLink(cardid, tv);
! tvList[cardid] = enc;
! }
! }
! else
! {
! if (host == localhostname)
! {
! TVRec *tv = new TVRec(cardid);
! tv->Init();
! EncoderLink *enc = new EncoderLink(cardid, tv);
! tvList[cardid] = enc;
! }
! else
! {
! EncoderLink *enc = new EncoderLink(cardid, NULL, host);
! tvList[cardid] = enc;
! }
! }
}
- }
- else
- {
- cerr << "ERROR: no capture cards are defined in the database.\n";
- exit(0);
}
}
--- 37,72 ----
query.exec("SELECT cardid,hostname FROM capturecard ORDER BY cardid;");
! /* If the query returned nothing, get out of here */
! if (!(query.isActive() && query.numRowsAffected()))
{
! cerr << "ERROR: no capture cards are defined in the database.\n";
! exit(0);
! }
!
! while (query.next())
! {
! int cardid = query.value(0).toInt();
! QString host = query.value(1).toString();
! if (host.isNull() || host.isEmpty())
! {
! cerr << "One of your capturecard entries does not have a "
! << "hostname.\n Please run setup and confirm all of the "
! << "capture cards.\n";
! exit(-1);
! }
! if (host == localhostname)
! {
! TVRec *tv = new TVRec(cardid);
! tv->Init();
! tvList[cardid] = new EncoderLink(cardid, tv);
! }
! else if (ismaster)
! {
! tvList[cardid] = new EncoderLink(cardid, NULL, host);
}
}
}
More information about the mythtv-dev
mailing list