cec: added some more audio related opcode handling. added TransmitVendorId(), but...
[deb_libcec.git] / src / lib / CECProcessor.cpp
1 /*
2 * This file is part of the libCEC(R) library.
3 *
4 * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
6 *
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
8 *
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 *
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
26 *
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
31 */
32
33 #include "CECProcessor.h"
34
35 #include "AdapterCommunication.h"
36 #include "devices/CECBusDevice.h"
37 #include "devices/CECAudioSystem.h"
38 #include "devices/CECPlaybackDevice.h"
39 #include "devices/CECRecordingDevice.h"
40 #include "devices/CECTuner.h"
41 #include "devices/CECTV.h"
42 #include "implementations/CECCommandHandler.h"
43 #include "LibCEC.h"
44 #include "util/StdString.h"
45 #include "platform/timeutils.h"
46
47 using namespace CEC;
48 using namespace std;
49
50 CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm, const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS*/) :
51 m_bStarted(false),
52 m_strDeviceName(strDeviceName),
53 m_communication(serComm),
54 m_controller(controller),
55 m_bMonitor(false)
56 {
57 m_logicalAddresses.clear();
58 m_logicalAddresses.set(iLogicalAddress);
59 m_types.clear();
60 for (int iPtr = 0; iPtr < 16; iPtr++)
61 m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, iPtr == iLogicalAddress ? iPhysicalAddress : 0);
62 }
63
64 CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm, const char *strDeviceName, const cec_device_type_list &types) :
65 m_bStarted(false),
66 m_strDeviceName(strDeviceName),
67 m_types(types),
68 m_communication(serComm),
69 m_controller(controller),
70 m_bMonitor(false)
71 {
72 m_logicalAddresses.clear();
73 for (int iPtr = 0; iPtr < 16; iPtr++)
74 {
75 switch(iPtr)
76 {
77 case CECDEVICE_AUDIOSYSTEM:
78 m_busDevices[iPtr] = new CCECAudioSystem(this, (cec_logical_address) iPtr, 0xFFFF);
79 break;
80 case CECDEVICE_PLAYBACKDEVICE1:
81 case CECDEVICE_PLAYBACKDEVICE2:
82 case CECDEVICE_PLAYBACKDEVICE3:
83 m_busDevices[iPtr] = new CCECPlaybackDevice(this, (cec_logical_address) iPtr, 0xFFFF);
84 break;
85 case CECDEVICE_RECORDINGDEVICE1:
86 case CECDEVICE_RECORDINGDEVICE2:
87 case CECDEVICE_RECORDINGDEVICE3:
88 m_busDevices[iPtr] = new CCECRecordingDevice(this, (cec_logical_address) iPtr, 0xFFFF);
89 break;
90 case CECDEVICE_TUNER1:
91 case CECDEVICE_TUNER2:
92 case CECDEVICE_TUNER3:
93 case CECDEVICE_TUNER4:
94 m_busDevices[iPtr] = new CCECTuner(this, (cec_logical_address) iPtr, 0xFFFF);
95 break;
96 case CECDEVICE_TV:
97 m_busDevices[iPtr] = new CCECTV(this, (cec_logical_address) iPtr, 0);
98 break;
99 default:
100 m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, 0xFFFF);
101 break;
102 }
103 }
104 }
105
106 CCECProcessor::~CCECProcessor(void)
107 {
108 m_startCondition.Broadcast();
109 StopThread();
110 m_communication = NULL;
111 m_controller = NULL;
112 for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
113 delete m_busDevices[iPtr];
114 }
115
116 bool CCECProcessor::Start(void)
117 {
118 CLockObject lock(&m_mutex);
119 if (!m_communication || !m_communication->IsOpen())
120 {
121 m_controller->AddLog(CEC_LOG_ERROR, "connection is closed");
122 return false;
123 }
124
125 if (CreateThread())
126 {
127 if (!m_startCondition.Wait(&m_mutex) || !m_bStarted)
128 {
129 m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread");
130 return false;
131 }
132 return true;
133 }
134 else
135 m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread");
136
137 return false;
138 }
139
140 bool CCECProcessor::TryLogicalAddress(cec_logical_address address, unsigned int iIndex)
141 {
142 const char *strLabel = CCECCommandHandler::ToString(address);
143 CStdString strLog;
144 strLog.Format("trying logical address '%s'", strLabel);
145 AddLog(CEC_LOG_DEBUG, strLog);
146
147 SetAckMask(0x1 << address);
148 if (!m_busDevices[address]->TransmitPoll(address))
149 {
150 strLog.Format("using logical address '%s'", strLabel);
151 AddLog(CEC_LOG_NOTICE, strLog);
152
153 /* only set our OSD name and active source for the primary device */
154 if (m_logicalAddresses.empty())
155 {
156 m_busDevices[address]->m_strDeviceName = m_strDeviceName;
157 m_busDevices[address]->m_bActiveSource = true;
158 }
159 m_busDevices[address]->m_powerStatus = CEC_POWER_STATUS_STANDBY;
160 m_busDevices[address]->m_cecVersion = CEC_VERSION_1_3A;
161
162 m_logicalAddresses.set(address);
163
164 // TODO
165 m_busDevices[address]->SetPhysicalAddress((uint16_t)CEC_DEFAULT_PHYSICAL_ADDRESS + ((uint16_t)iIndex * 0x100));
166
167 return true;
168 }
169
170 strLog.Format("logical address '%s' already taken", strLabel);
171 AddLog(CEC_LOG_DEBUG, strLog);
172 return false;
173 }
174
175 bool CCECProcessor::FindLogicalAddressRecordingDevice(unsigned int iIndex)
176 {
177 AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'recording device'");
178 return TryLogicalAddress(CECDEVICE_RECORDINGDEVICE1, iIndex) ||
179 TryLogicalAddress(CECDEVICE_RECORDINGDEVICE2, iIndex) ||
180 TryLogicalAddress(CECDEVICE_RECORDINGDEVICE3, iIndex);
181 }
182
183 bool CCECProcessor::FindLogicalAddressTuner(unsigned int iIndex)
184 {
185 AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'tuner'");
186 return TryLogicalAddress(CECDEVICE_TUNER1, iIndex) ||
187 TryLogicalAddress(CECDEVICE_TUNER2, iIndex) ||
188 TryLogicalAddress(CECDEVICE_TUNER3, iIndex) ||
189 TryLogicalAddress(CECDEVICE_TUNER4, iIndex);
190 }
191
192 bool CCECProcessor::FindLogicalAddressPlaybackDevice(unsigned int iIndex)
193 {
194 AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'playback device'");
195 return TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE1, iIndex) ||
196 TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE2, iIndex) ||
197 TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE3, iIndex);
198 }
199
200 bool CCECProcessor::FindLogicalAddressAudioSystem(unsigned int iIndex)
201 {
202 AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'audio'");
203 return TryLogicalAddress(CECDEVICE_AUDIOSYSTEM, iIndex);
204 }
205
206 bool CCECProcessor::FindLogicalAddresses(void)
207 {
208 bool bReturn(true);
209 m_logicalAddresses.clear();
210 CStdString strLog;
211
212 for (unsigned int iPtr = 0; iPtr < 5; iPtr++)
213 {
214 if (m_types.types[iPtr] == CEC_DEVICE_TYPE_RESERVED)
215 continue;
216
217 strLog.Format("%s - device %d: type %d", __FUNCTION__, iPtr, m_types.types[iPtr]);
218 AddLog(CEC_LOG_DEBUG, strLog);
219
220 if (m_types.types[iPtr] == CEC_DEVICE_TYPE_RECORDING_DEVICE)
221 bReturn &= FindLogicalAddressRecordingDevice(iPtr);
222 if (m_types.types[iPtr] == CEC_DEVICE_TYPE_TUNER)
223 bReturn &= FindLogicalAddressTuner(iPtr);
224 if (m_types.types[iPtr] == CEC_DEVICE_TYPE_PLAYBACK_DEVICE)
225 bReturn &= FindLogicalAddressPlaybackDevice(iPtr);
226 if (m_types.types[iPtr] == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
227 bReturn &= FindLogicalAddressAudioSystem(iPtr);
228 }
229
230 return bReturn;
231 }
232
233 void *CCECProcessor::Process(void)
234 {
235 bool bParseFrame(false);
236 cec_command command;
237 CCECAdapterMessage msg;
238
239 {
240 if (m_logicalAddresses.empty() && !FindLogicalAddresses())
241 {
242 CLockObject lock(&m_mutex);
243 m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addressed");
244 m_startCondition.Signal();
245 return NULL;
246 }
247
248 SetAckMask(m_logicalAddresses.ackmask());
249
250 {
251 CLockObject lock(&m_mutex);
252 m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
253 m_bStarted = true;
254 m_startCondition.Signal();
255 }
256 }
257
258 while (!IsStopped())
259 {
260 command.clear();
261 msg.clear();
262
263 {
264 CLockObject lock(&m_mutex);
265 if (m_commandBuffer.Pop(command))
266 {
267 bParseFrame = true;
268 }
269 else if (m_communication->IsOpen() && m_communication->Read(msg, 50))
270 {
271 m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
272 if ((bParseFrame = (ParseMessage(msg) && !IsStopped())) == true)
273 command = m_currentframe;
274 }
275 }
276
277 if (bParseFrame)
278 ParseCommand(command);
279 bParseFrame = false;
280
281 Sleep(5);
282
283 m_controller->CheckKeypressTimeout();
284
285 for (unsigned int iDevicePtr = 0; iDevicePtr < 16; iDevicePtr++)
286 m_busDevices[iDevicePtr]->PollVendorId();
287
288 Sleep(5);
289 }
290
291 return NULL;
292 }
293
294 bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */)
295 {
296 bool bReturn(false);
297
298 if (!IsRunning())
299 return bReturn;
300
301 cec_logical_address addr = m_logicalAddresses.primary;
302
303 if (type != CEC_DEVICE_TYPE_RESERVED)
304 {
305 for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
306 {
307 if (m_logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type)
308 {
309 addr = (cec_logical_address) iPtr;
310 break;
311 }
312 }
313 }
314
315 return SetStreamPath(m_busDevices[addr]->GetPhysicalAddress());
316 }
317
318 bool CCECProcessor::SetActiveView(void)
319 {
320 return SetActiveSource();
321 }
322
323 bool CCECProcessor::SetDeckControlMode(cec_deck_control_mode mode)
324 {
325 bool bReturn(false);
326
327 CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
328 if (device)
329 {
330 ((CCECPlaybackDevice *) device)->SetDeckControlMode(mode);
331 bReturn = true;
332 }
333
334 return bReturn;
335 }
336
337 bool CCECProcessor::SetDeckInfo(cec_deck_info info)
338 {
339 bool bReturn(false);
340
341 CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
342 if (device)
343 {
344 ((CCECPlaybackDevice *) device)->SetDeckStatus(info);
345 bReturn = true;
346 }
347
348 return bReturn;
349 }
350
351 bool CCECProcessor::SetStreamPath(uint16_t iStreamPath)
352 {
353 bool bReturn(false);
354
355 CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath);
356 if (device)
357 {
358 for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
359 m_busDevices[iPtr]->m_bActiveSource = false;
360
361 device->m_bActiveSource = true;
362 device->m_powerStatus = CEC_POWER_STATUS_ON;
363
364 if (m_logicalAddresses.isset(device->m_iLogicalAddress))
365 bReturn = device->TransmitActiveSource();
366 else
367 bReturn = true;
368 }
369
370 return bReturn;
371 }
372
373 bool CCECProcessor::SetInactiveView(void)
374 {
375 if (!IsRunning())
376 return false;
377
378 if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary])
379 return m_busDevices[m_logicalAddresses.primary]->TransmitInactiveView();
380 return false;
381 }
382
383 void CCECProcessor::LogOutput(const cec_command &data)
384 {
385 CStdString strTx;
386 strTx.Format("<< %02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination);
387 if (data.opcode_set)
388 strTx.AppendFormat(":%02x", (uint8_t)data.opcode);
389
390 for (uint8_t iPtr = 0; iPtr < data.parameters.size; iPtr++)
391 strTx.AppendFormat(":%02x", data.parameters[iPtr]);
392 m_controller->AddLog(CEC_LOG_TRAFFIC, strTx.c_str());
393 }
394
395 bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress)
396 {
397 if (m_logicalAddresses.primary != iLogicalAddress)
398 {
399 CStdString strLog;
400 strLog.Format("<< setting primary logical address to %1x", iLogicalAddress);
401 m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
402 m_logicalAddresses.primary = iLogicalAddress;
403 m_logicalAddresses.set(iLogicalAddress);
404 return SetAckMask(m_logicalAddresses.ackmask());
405 }
406
407 return true;
408 }
409
410 bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress)
411 {
412 if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary])
413 {
414 m_busDevices[m_logicalAddresses.primary]->SetPhysicalAddress(iPhysicalAddress);
415 return SetActiveView();
416 }
417 return false;
418 }
419
420 bool CCECProcessor::SwitchMonitoring(bool bEnable)
421 {
422 CStdString strLog;
423 strLog.Format("== %s monitoring mode ==", bEnable ? "enabling" : "disabling");
424 m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
425
426 m_bMonitor = bEnable;
427 if (bEnable)
428 return SetAckMask(0);
429 else
430 return SetAckMask(m_logicalAddresses.ackmask());
431 }
432
433 bool CCECProcessor::PollDevice(cec_logical_address iAddress)
434 {
435 if (iAddress != CECDEVICE_UNKNOWN && m_busDevices[iAddress])
436 return m_busDevices[m_logicalAddresses.primary]->TransmitPoll(iAddress);
437 return false;
438 }
439
440 CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
441 {
442 CCECBusDevice *device = NULL;
443
444 for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
445 {
446 if (m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress)
447 {
448 device = m_busDevices[iPtr];
449 break;
450 }
451 }
452
453 return device;
454 }
455
456 CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const
457 {
458 CCECBusDevice *device = NULL;
459
460 for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
461 {
462 if (m_busDevices[iPtr]->m_type == type)
463 {
464 device = m_busDevices[iPtr];
465 break;
466 }
467 }
468
469 return device;
470 }
471
472 cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress)
473 {
474 return m_busDevices[iAddress]->GetCecVersion();
475 }
476
477 bool CCECProcessor::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language)
478 {
479 if (m_busDevices[iAddress])
480 {
481 *language = m_busDevices[iAddress]->GetMenuLanguage();
482 return (strcmp(language->language, "???") != 0);
483 }
484 return false;
485 }
486
487 uint64_t CCECProcessor::GetDeviceVendorId(cec_logical_address iAddress)
488 {
489 if (m_busDevices[iAddress])
490 return m_busDevices[iAddress]->GetVendorId();
491 return false;
492 }
493
494 cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress)
495 {
496 if (m_busDevices[iAddress])
497 return m_busDevices[iAddress]->GetPowerStatus();
498 return CEC_POWER_STATUS_UNKNOWN;
499 }
500
501 bool CCECProcessor::Transmit(const cec_command &data)
502 {
503 bool bReturn(false);
504 LogOutput(data);
505
506 CCECAdapterMessage *output = new CCECAdapterMessage(data);
507 bReturn = Transmit(output);
508 delete output;
509
510 return bReturn;
511 }
512
513 bool CCECProcessor::Transmit(CCECAdapterMessage *output)
514 {
515 bool bReturn(false);
516 CLockObject lock(&m_mutex);
517 {
518 CLockObject msgLock(&output->mutex);
519 if (!m_communication || !m_communication->Write(output))
520 return bReturn;
521 else
522 {
523 output->condition.Wait(&output->mutex);
524 if (output->state != ADAPTER_MESSAGE_STATE_SENT)
525 {
526 m_controller->AddLog(CEC_LOG_ERROR, "command was not sent");
527 return bReturn;
528 }
529 }
530
531 if (output->transmit_timeout > 0)
532 {
533 if ((bReturn = WaitForTransmitSucceeded(output->size(), output->transmit_timeout)) == false)
534 m_controller->AddLog(CEC_LOG_DEBUG, "did not receive ack");
535 }
536 else
537 bReturn = true;
538 }
539
540 return bReturn;
541 }
542
543 void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode, cec_abort_reason reason /* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */)
544 {
545 m_controller->AddLog(CEC_LOG_DEBUG, "<< transmitting abort message");
546
547 cec_command command;
548 // TODO
549 cec_command::format(command, m_logicalAddresses.primary, address, CEC_OPCODE_FEATURE_ABORT);
550 command.parameters.push_back((uint8_t)opcode);
551 command.parameters.push_back((uint8_t)reason);
552
553 Transmit(command);
554 }
555
556 bool CCECProcessor::WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout /* = 1000 */)
557 {
558 bool bError(false);
559 bool bTransmitSucceeded(false);
560 uint8_t iPacketsLeft(iLength / 4);
561
562 int64_t iNow = GetTimeMs();
563 int64_t iTargetTime = iNow + (uint64_t) iTimeout;
564
565 while (!bTransmitSucceeded && !bError && (iTimeout == 0 || iNow < iTargetTime))
566 {
567 CCECAdapterMessage msg;
568
569 if (!m_communication->Read(msg, iTimeout > 0 ? (int32_t)(iTargetTime - iNow) : 1000))
570 {
571 iNow = GetTimeMs();
572 continue;
573 }
574
575 if ((bError = msg.is_error()) == false)
576 {
577 m_controller->AddLog(bError ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
578
579 switch(msg.message())
580 {
581 case MSGCODE_COMMAND_ACCEPTED:
582 if (iPacketsLeft > 0)
583 iPacketsLeft--;
584 break;
585 case MSGCODE_TRANSMIT_SUCCEEDED:
586 bTransmitSucceeded = (iPacketsLeft == 0);
587 bError = !bTransmitSucceeded;
588 break;
589 default:
590 if (ParseMessage(msg))
591 m_commandBuffer.Push(m_currentframe);
592 }
593
594 iNow = GetTimeMs();
595 }
596 }
597
598 return bTransmitSucceeded && !bError;
599 }
600
601 bool CCECProcessor::ParseMessage(const CCECAdapterMessage &msg)
602 {
603 bool bEom = false;
604
605 if (msg.empty())
606 return bEom;
607
608 switch(msg.message())
609 {
610 case MSGCODE_FRAME_START:
611 {
612 m_currentframe.clear();
613 if (msg.size() >= 2)
614 {
615 m_currentframe.initiator = msg.initiator();
616 m_currentframe.destination = msg.destination();
617 m_currentframe.ack = msg.ack();
618 m_currentframe.eom = msg.eom();
619 }
620 }
621 break;
622 case MSGCODE_FRAME_DATA:
623 {
624 if (msg.size() >= 2)
625 {
626 m_currentframe.push_back(msg[1]);
627 m_currentframe.eom = msg.eom();
628 }
629 bEom = msg.eom();
630 }
631 break;
632 default:
633 break;
634 }
635
636 return bEom;
637 }
638
639 void CCECProcessor::ParseCommand(cec_command &command)
640 {
641 CStdString dataStr;
642 dataStr.Format(">> %1x%1x:%02x", command.initiator, command.destination, command.opcode);
643 for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
644 dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]);
645 m_controller->AddLog(CEC_LOG_TRAFFIC, dataStr.c_str());
646
647 if (!m_bMonitor)
648 m_busDevices[(uint8_t)command.initiator]->HandleCommand(command);
649 }
650
651 uint16_t CCECProcessor::GetPhysicalAddress(void) const
652 {
653 if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary])
654 return m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress();
655 return false;
656 }
657
658 void CCECProcessor::SetCurrentButton(cec_user_control_code iButtonCode)
659 {
660 m_controller->SetCurrentButton(iButtonCode);
661 }
662
663 void CCECProcessor::AddCommand(const cec_command &command)
664 {
665 m_controller->AddCommand(command);
666 }
667
668 void CCECProcessor::AddKey(cec_keypress &key)
669 {
670 m_controller->AddKey(key);
671 }
672
673 void CCECProcessor::AddKey(void)
674 {
675 m_controller->AddKey();
676 }
677
678 void CCECProcessor::AddLog(cec_log_level level, const CStdString &strMessage)
679 {
680 m_controller->AddLog(level, strMessage);
681 }
682
683 bool CCECProcessor::SetAckMask(uint16_t iMask)
684 {
685 bool bReturn(false);
686 CStdString strLog;
687 strLog.Format("setting ackmask to %2x", iMask);
688 m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
689
690 CCECAdapterMessage *output = new CCECAdapterMessage;
691
692 output->push_back(MSGSTART);
693 output->push_escaped(MSGCODE_SET_ACK_MASK);
694 output->push_escaped(iMask >> 8);
695 output->push_escaped((uint8_t)iMask);
696 output->push_back(MSGEND);
697
698 if ((bReturn = Transmit(output)) == false)
699 m_controller->AddLog(CEC_LOG_ERROR, "could not set the ackmask");
700
701 delete output;
702
703 return bReturn;
704 }