Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libcec-daemon for libcec-4.0.5 #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = -I m4

AM_LDFLAGS = "-pthread"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does libcec now require pthreads?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it is if you link against libraspberrypi. Otherwise, it might not be.


bin_PROGRAMS = libcec-daemon
libcec_daemon_SOURCES = src/accumulator.hpp \
src/hdmi.cpp \
Expand Down
67 changes: 31 additions & 36 deletions src/libcec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,34 @@ const map<enum cec_user_control_code, const char *> Cec::cecUserControlCodeName
// We store a global handle, so we can use g_cec->ToString(..) in certain cases. This is a bit of a HACK :(
static ICECAdapter * g_cec = NULL;

int cecLogMessage(void *cbParam, const cec_log_message message) {
void cecLogMessage(void *cbParam, const cec_log_message *message) {
matthewbauer marked this conversation as resolved.
Show resolved Hide resolved
try {
return ((CecCallback*) cbParam)->onCecLogMessage(message);
((CecCallback*) cbParam)->onCecLogMessage(*message);
} catch (...) {}
return 0;
}

int cecKeyPress(void *cbParam, const cec_keypress key) {
void cecKeyPress(void *cbParam, const cec_keypress *key) {
try {
return ((CecCallback*) cbParam)->onCecKeyPress(key);
((CecCallback*) cbParam)->onCecKeyPress(*key);
} catch (...) {}
return 0;
}

int cecCommand(void *cbParam, const cec_command command) {
void cecCommand(void *cbParam, const cec_command *command) {
try {
return ((CecCallback*) cbParam)->onCecCommand(command);
((CecCallback*) cbParam)->onCecCommand(*command);
} catch (...) {}
return 0;
}

int cecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter param) {
void cecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter param) {
try {
return ((CecCallback*) cbParam)->onCecAlert(alert, param);
((CecCallback*) cbParam)->onCecAlert(alert, param);
} catch (...) {}
return 0;
}

int cecConfigurationChanged(void *cbParam, const libcec_configuration configuration) {
void cecConfigurationChanged(void *cbParam, const libcec_configuration *configuration) {
try {
return ((CecCallback*) cbParam)->onCecConfigurationChanged(configuration);
((CecCallback*) cbParam)->onCecConfigurationChanged(*configuration);
} catch (...) {}
return 0;
}

int cecMenuStateChanged(void *cbParam, const cec_menu_state menu_state) {
Expand All @@ -95,7 +90,7 @@ int cecMenuStateChanged(void *cbParam, const cec_menu_state menu_state) {

void cecSourceActivated(void *cbParam, const cec_logical_address address, const uint8_t val) {
try {
return ((CecCallback*) cbParam)->onCecSourceActivated(address, val);
((CecCallback*) cbParam)->onCecSourceActivated(address, val);
} catch (...) {}
}

Expand Down Expand Up @@ -142,13 +137,13 @@ Cec::Cec(const char * name, CecCallback * callback)
strncpy(config.strDeviceName, name, sizeof(config.strDeviceName));
config.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);

callbacks.CBCecLogMessage = &::cecLogMessage;
callbacks.CBCecKeyPress = &::cecKeyPress;
callbacks.CBCecCommand = &::cecCommand;
callbacks.CBCecConfigurationChanged = &::cecConfigurationChanged;
callbacks.CBCecAlert = &::cecAlert;
callbacks.CBCecMenuStateChanged = &::cecMenuStateChanged;
callbacks.CBCecSourceActivated = &::cecSourceActivated;
callbacks.logMessage = &::cecLogMessage;
callbacks.keyPress = &::cecKeyPress;
callbacks.commandReceived = &::cecCommand;
callbacks.configurationChanged = &::cecConfigurationChanged;
callbacks.alert = &::cecAlert;
callbacks.menuStateChanged = &::cecMenuStateChanged;
callbacks.sourceActivated = &::cecSourceActivated;

config.callbackParam = callback;
config.callbacks = &callbacks;
Expand Down Expand Up @@ -178,9 +173,9 @@ void Cec::open(const std::string &name) {
init();

// Search for adapters
cec_adapter devices[MAX_CEC_PORTS];
cec_adapter_descriptor devices[MAX_CEC_PORTS];

uint8_t ret = cec->FindAdapters(devices, MAX_CEC_PORTS, NULL);
uint8_t ret = cec->DetectAdapters(devices, MAX_CEC_PORTS);
if (ret < 0) {
throw std::runtime_error("Error occurred searching for adapters");
}
Expand All @@ -194,9 +189,9 @@ void Cec::open(const std::string &name) {
LOG4CPLUS_INFO(logger, "Looking for " << name);
for(id=0; id<ret; ++id)
{
if( name.compare(devices[id].path) == 0 )
if( name.compare(devices[id].strComPath) == 0 )
break;
if( name.compare(devices[id].comm) == 0 )
if( name.compare(devices[id].strComName) == 0 )
break;
}
if( id == ret )
Expand All @@ -206,13 +201,13 @@ void Cec::open(const std::string &name) {
}

// Just use the first found
LOG4CPLUS_INFO(logger, "Opening " << devices[id].path);
LOG4CPLUS_INFO(logger, "Opening " << devices[id].strComPath);

if (!cec->Open(devices[id].comm)) {
if (!cec->Open(devices[id].strComName)) {
throw std::runtime_error("Failed to open adapter");
}

LOG4CPLUS_INFO(logger, "Opened " << devices[id].path);
LOG4CPLUS_INFO(logger, "Opened " << devices[id].strComPath);
}

void Cec::close(bool makeInactive) {
Expand Down Expand Up @@ -253,11 +248,11 @@ bool Cec::ping() {
* This will close any open device!
*/
ostream & Cec::listDevices(ostream & out) {
cec_adapter devices[MAX_CEC_PORTS];
cec_adapter_descriptor devices[MAX_CEC_PORTS];

init();

int8_t ret = cec->FindAdapters(devices, MAX_CEC_PORTS, NULL);
int8_t ret = cec->DetectAdapters(devices, MAX_CEC_PORTS);
if (ret < 0) {
LOG4CPLUS_ERROR(logger, "Error occurred searching for adapters");
return out;
Expand All @@ -268,9 +263,9 @@ ostream & Cec::listDevices(ostream & out) {
}

for (int8_t i = 0; i < ret; i++) {
out << "[" << (int) i << "] port:" << devices[i].comm << " path:" << devices[i].path << endl;
out << "[" << (int) i << "] port:" << devices[i].strComName << " path:" << devices[i].strComPath << endl;

if (!cec->Open(devices[i].comm)) {
if (!cec->Open(devices[i].strComPath)) {
out << "\tFailed to open" << endl;
}

Expand All @@ -280,12 +275,12 @@ ostream & Cec::listDevices(ostream & out) {
cec_logical_address logical_addres = (cec_logical_address) j;

HDMI::physical_address physical_address(cec->GetDevicePhysicalAddress(logical_addres));
cec_osd_name name = cec->GetDeviceOSDName(logical_addres);
std::string name = cec->GetDeviceOSDName(logical_addres);
cec_vendor_id vendor = (cec_vendor_id) cec->GetDeviceVendorId(logical_addres);

out << "\t" << cec->ToString(logical_addres)
<< " @ 0x" << hex << physical_address
<< " " << name.name << " (" << cec->ToString(vendor) << ")"
<< " " << name << " (" << cec->ToString(vendor) << ")"
<< endl;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/libcec.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class Cec {
bool ping();

// These are just wrapper functions, to map C callbacks to C++
friend int cecLogMessage (void *cbParam, const CEC::cec_log_message &message);
friend int cecKeyPress (void *cbParam, const CEC::cec_keypress &key);
friend int cecCommand (void *cbParam, const CEC::cec_command &command);
friend int cecConfigurationChanged (void *cbParam, const CEC::libcec_configuration & configuration);
friend int cecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter & param);
friend void cecLogMessage (void *cbParam, const CEC::cec_log_message &message);
friend void cecKeyPress (void *cbParam, const CEC::cec_keypress &key);
friend void cecCommand (void *cbParam, const CEC::cec_command &command);
friend void cecConfigurationChanged (void *cbParam, const CEC::libcec_configuration & configuration);
friend void cecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter & param);
friend int cecMenuStateChanged(void *cbParam, const CEC::cec_menu_state & menu_state);
friend void cecSourceActivated(void *cbParam, const CEC::cec_logical_address & address, const uint8_t bActivated);
};
Expand Down