Skip to content

Commit 862a1fd

Browse files
committed
Update libcec-daemon for libcec-4.0.5
Fixes bramp#31
1 parent 3f2782e commit 862a1fd

File tree

2 files changed

+36
-41
lines changed

2 files changed

+36
-41
lines changed

src/libcec.cpp

+31-36
Original file line numberDiff line numberDiff line change
@@ -51,39 +51,34 @@ const map<enum cec_user_control_code, const char *> Cec::cecUserControlCodeName
5151
// We store a global handle, so we can use g_cec->ToString(..) in certain cases. This is a bit of a HACK :(
5252
static ICECAdapter * g_cec = NULL;
5353

54-
int cecLogMessage(void *cbParam, const cec_log_message message) {
54+
void cecLogMessage(void *cbParam, const cec_log_message *message) {
5555
try {
56-
return ((CecCallback*) cbParam)->onCecLogMessage(message);
56+
((CecCallback*) cbParam)->onCecLogMessage(*message);
5757
} catch (...) {}
58-
return 0;
5958
}
6059

61-
int cecKeyPress(void *cbParam, const cec_keypress key) {
60+
void cecKeyPress(void *cbParam, const cec_keypress *key) {
6261
try {
63-
return ((CecCallback*) cbParam)->onCecKeyPress(key);
62+
((CecCallback*) cbParam)->onCecKeyPress(*key);
6463
} catch (...) {}
65-
return 0;
6664
}
6765

68-
int cecCommand(void *cbParam, const cec_command command) {
66+
void cecCommand(void *cbParam, const cec_command *command) {
6967
try {
70-
return ((CecCallback*) cbParam)->onCecCommand(command);
68+
((CecCallback*) cbParam)->onCecCommand(*command);
7169
} catch (...) {}
72-
return 0;
7370
}
7471

75-
int cecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter param) {
72+
void cecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter param) {
7673
try {
77-
return ((CecCallback*) cbParam)->onCecAlert(alert, param);
74+
((CecCallback*) cbParam)->onCecAlert(alert, param);
7875
} catch (...) {}
79-
return 0;
8076
}
8177

82-
int cecConfigurationChanged(void *cbParam, const libcec_configuration configuration) {
78+
void cecConfigurationChanged(void *cbParam, const libcec_configuration *configuration) {
8379
try {
84-
return ((CecCallback*) cbParam)->onCecConfigurationChanged(configuration);
80+
((CecCallback*) cbParam)->onCecConfigurationChanged(*configuration);
8581
} catch (...) {}
86-
return 0;
8782
}
8883

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

9691
void cecSourceActivated(void *cbParam, const cec_logical_address address, const uint8_t val) {
9792
try {
98-
return ((CecCallback*) cbParam)->onCecSourceActivated(address, val);
93+
((CecCallback*) cbParam)->onCecSourceActivated(address, val);
9994
} catch (...) {}
10095
}
10196

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

145-
callbacks.CBCecLogMessage = &::cecLogMessage;
146-
callbacks.CBCecKeyPress = &::cecKeyPress;
147-
callbacks.CBCecCommand = &::cecCommand;
148-
callbacks.CBCecConfigurationChanged = &::cecConfigurationChanged;
149-
callbacks.CBCecAlert = &::cecAlert;
150-
callbacks.CBCecMenuStateChanged = &::cecMenuStateChanged;
151-
callbacks.CBCecSourceActivated = &::cecSourceActivated;
140+
callbacks.logMessage = &::cecLogMessage;
141+
callbacks.keyPress = &::cecKeyPress;
142+
callbacks.commandReceived = &::cecCommand;
143+
callbacks.configurationChanged = &::cecConfigurationChanged;
144+
callbacks.alert = &::cecAlert;
145+
callbacks.menuStateChanged = &::cecMenuStateChanged;
146+
callbacks.sourceActivated = &::cecSourceActivated;
152147

153148
config.callbackParam = callback;
154149
config.callbacks = &callbacks;
@@ -178,9 +173,9 @@ void Cec::open(const std::string &name) {
178173
init();
179174

180175
// Search for adapters
181-
cec_adapter devices[MAX_CEC_PORTS];
176+
cec_adapter_descriptor devices[MAX_CEC_PORTS];
182177

183-
uint8_t ret = cec->FindAdapters(devices, MAX_CEC_PORTS, NULL);
178+
uint8_t ret = cec->DetectAdapters(devices, MAX_CEC_PORTS);
184179
if (ret < 0) {
185180
throw std::runtime_error("Error occurred searching for adapters");
186181
}
@@ -194,9 +189,9 @@ void Cec::open(const std::string &name) {
194189
LOG4CPLUS_INFO(logger, "Looking for " << name);
195190
for(id=0; id<ret; ++id)
196191
{
197-
if( name.compare(devices[id].path) == 0 )
192+
if( name.compare(devices[id].strComPath) == 0 )
198193
break;
199-
if( name.compare(devices[id].comm) == 0 )
194+
if( name.compare(devices[id].strComName) == 0 )
200195
break;
201196
}
202197
if( id == ret )
@@ -206,13 +201,13 @@ void Cec::open(const std::string &name) {
206201
}
207202

208203
// Just use the first found
209-
LOG4CPLUS_INFO(logger, "Opening " << devices[id].path);
204+
LOG4CPLUS_INFO(logger, "Opening " << devices[id].strComPath);
210205

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

215-
LOG4CPLUS_INFO(logger, "Opened " << devices[id].path);
210+
LOG4CPLUS_INFO(logger, "Opened " << devices[id].strComPath);
216211
}
217212

218213
void Cec::close(bool makeInactive) {
@@ -253,11 +248,11 @@ bool Cec::ping() {
253248
* This will close any open device!
254249
*/
255250
ostream & Cec::listDevices(ostream & out) {
256-
cec_adapter devices[MAX_CEC_PORTS];
251+
cec_adapter_descriptor devices[MAX_CEC_PORTS];
257252

258253
init();
259254

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

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

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

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

282277
HDMI::physical_address physical_address(cec->GetDevicePhysicalAddress(logical_addres));
283-
cec_osd_name name = cec->GetDeviceOSDName(logical_addres);
278+
std::string name = cec->GetDeviceOSDName(logical_addres);
284279
cec_vendor_id vendor = (cec_vendor_id) cec->GetDeviceVendorId(logical_addres);
285280

286281
out << "\t" << cec->ToString(logical_addres)
287282
<< " @ 0x" << hex << physical_address
288-
<< " " << name.name << " (" << cec->ToString(vendor) << ")"
283+
<< " " << name << " (" << cec->ToString(vendor) << ")"
289284
<< endl;
290285
}
291286
}

src/libcec.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ class Cec {
6969
bool ping();
7070

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

0 commit comments

Comments
 (0)