Skip to content

Commit 3f2782e

Browse files
committed
Some minor whitespace and formatting tweaks.
1 parent 0126e40 commit 3f2782e

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

src/libcec.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ using std::endl;
3434
using std::map;
3535
using std::ostream;
3636
using std::string;
37+
using std::hex;
3738

3839
// cecloader has to be after some #includes and using namespaces :(
3940
using std::cout;
@@ -157,7 +158,7 @@ Cec::~Cec() {}
157158

158159
void Cec::init()
159160
{
160-
if (! cec)
161+
if (!cec)
161162
{
162163
// LibCecInitialise is noisy, so we redirect cout to nowhere
163164
RedirectStreamBuffer redirect(cout, 0);
@@ -205,7 +206,7 @@ void Cec::open(const std::string &name) {
205206
}
206207

207208
// Just use the first found
208-
LOG4CPLUS_INFO(logger, "Openning " << devices[id].path);
209+
LOG4CPLUS_INFO(logger, "Opening " << devices[id].path);
209210

210211
if (!cec->Open(devices[id].comm)) {
211212
throw std::runtime_error("Failed to open adapter");
@@ -283,7 +284,7 @@ ostream & Cec::listDevices(ostream & out) {
283284
cec_vendor_id vendor = (cec_vendor_id) cec->GetDeviceVendorId(logical_addres);
284285

285286
out << "\t" << cec->ToString(logical_addres)
286-
<< "@" << physical_address
287+
<< " @ 0x" << hex << physical_address
287288
<< " " << name.name << " (" << cec->ToString(vendor) << ")"
288289
<< endl;
289290
}
@@ -417,15 +418,6 @@ std::ostream& operator<<(std::ostream &out, const cec_keypress & key) {
417418
}
418419

419420
std::ostream& operator<<(std::ostream &out, const cec_command & cmd) {
420-
// cec_logical_address initiator; /**< the logical address of the initiator of this message */
421-
// cec_logical_address destination; /**< the logical address of the destination of this message */
422-
// int8_t ack; /**< 1 when the ACK bit is set, 0 otherwise */
423-
// int8_t eom; /**< 1 when the EOM bit is set, 0 otherwise */
424-
// cec_opcode opcode; /**< the opcode of this message */
425-
// cec_datapacket parameters; /**< the parameters attached to this message */
426-
// int8_t opcode_set; /**< 1 when an opcode is set, 0 otherwise (POLL message) */
427-
// int32_t transmit_timeout; /**< the timeout to use in ms */
428-
429421
return out << "Command "
430422
<< cmd.initiator << "->" << cmd.destination
431423
<< "[" << (cmd.ack ? "A" : " ") << (cmd.eom ? "A" : " ") << "]"

src/main.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ Main::Main() : cec(getCecName(), this), uinput(UINPUT_NAME, uinputCecMap),
7272
makeActive(true), running(false), lastUInputKeys({ }), logicalAddress(CECDEVICE_UNKNOWN)
7373
{
7474
LOG4CPLUS_TRACE_STR(logger, "Main::Main()");
75-
7675
}
7776

7877
Main::~Main() {
@@ -218,7 +217,7 @@ void Main::signalHandler(int sigNum) {
218217

219218
char *Main::getCecName() {
220219
LOG4CPLUS_TRACE_STR(logger, "Main::getCecName()");
221-
if (gethostname(cec_name,HOST_NAME_MAX) < 0 ) {
220+
if (gethostname(cec_name, HOST_NAME_MAX) < 0 ) {
222221
LOG4CPLUS_TRACE_STR(logger, "Main::getCecName()");
223222
strncpy(cec_name, CEC_NAME, sizeof(HOST_NAME_MAX));
224223
}
@@ -519,14 +518,7 @@ void Main::onCecSourceActivated(const cec_logical_address & address, bool bActiv
519518
LOG4CPLUS_DEBUG(logger, "Main::onCecSourceActivated(logicalAddress " << address << " = " << bActivated << ")");
520519
if( logicalAddress == address )
521520
{
522-
if( bActivated )
523-
{
524-
push(Command(COMMAND_ACTIVE));
525-
}
526-
else
527-
{
528-
push(Command(COMMAND_INACTIVE));
529-
}
521+
push(Command(bActivated ? COMMAND_ACTIVE : COMMAND_INACTIVE));
530522
}
531523
}
532524

@@ -577,6 +569,7 @@ int main (int argc, char *argv[]) {
577569
("verbose,v", accumulator<int>(&loglevel)->implicit_value(1), "verbose output (use -vv for more)")
578570
("quiet,q", "quiet output (print almost nothing)")
579571
("donotactivate,a", "do not activate device on startup")
572+
580573
("onstandby", value<string>()->value_name("<path>"), "command to run on standby")
581574
("onactivate", value<string>()->value_name("<path>"), "command to run on activation")
582575
("ondeactivate", value<string>()->value_name("<path>"), "command to run on deactivation")

src/main.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Main : public CecCallback {
3030

3131
// Some config params
3232
bool makeActive;
33-
bool running;
33+
bool running; // TODO Change this to be threadsafe!. Voiatile or better
3434

3535
//
3636
std::list<__u16> lastUInputKeys; // for key(s) repetition
@@ -80,6 +80,7 @@ class Main : public CecCallback {
8080
void listDevices();
8181

8282
void setMakeActive(bool active) {this->makeActive = active;};
83+
8384
void setOnStandbyCommand(const std::string &cmd) {this->onStandbyCommand = cmd;};
8485
void setOnActivateCommand(const std::string &cmd) {this->onActivateCommand = cmd;};
8586
void setOnDeactivateCommand(const std::string &cmd) {this->onDeactivateCommand = cmd;};

0 commit comments

Comments
 (0)