| 455 | } |
| 456 | |
| 457 | bool CCECProcessor::Transmit(const cec_command &data, bool bIsReply) |
| 458 | { |
| 459 | cec_command transmitData(data); |
| 460 | uint8_t iMaxTries(0); |
| 461 | bool bRetry(true); |
| 462 | uint8_t iTries(0); |
| 463 | |
| 464 | // get the current timeout setting |
| 465 | uint8_t iLineTimeout(GetStandardLineTimeout()); |
| 466 | |
| 467 | // reset the state of this message to 'unknown' |
| 468 | cec_adapter_message_state adapterState = ADAPTER_MESSAGE_STATE_UNKNOWN; |
| 469 | |
| 470 | if (data.initiator == CECDEVICE_UNKNOWN && data.destination == CECDEVICE_UNKNOWN) |
| 471 | return false; |
| 472 | |
| 473 | CLockObject lock(m_mutex); |
| 474 | if (!m_communication) |
| 475 | return false; |
| 476 | |
| 477 | if (!m_communication->SupportsSourceLogicalAddress(transmitData.initiator)) |
| 478 | { |
| 479 | if (transmitData.initiator == CECDEVICE_UNREGISTERED && m_communication->SupportsSourceLogicalAddress(CECDEVICE_FREEUSE)) |
| 480 | { |
| 481 | m_libcec->AddLog(CEC_LOG_DEBUG, "initiator '%s' is not supported by the CEC adapter. using '%s' instead", ToString(transmitData.initiator), ToString(CECDEVICE_FREEUSE)); |
| 482 | transmitData.initiator = CECDEVICE_FREEUSE; |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | m_libcec->AddLog(CEC_LOG_DEBUG, "initiator '%s' is not supported by the CEC adapter", ToString(transmitData.initiator)); |
| 487 | return false; |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | LogOutput(transmitData); |
| 492 | |
| 493 | // find the initiator device |
| 494 | CCECBusDevice *initiator = m_busDevices->At(transmitData.initiator); |
| 495 | if (!initiator) |
| 496 | { |
| 497 | m_libcec->AddLog(CEC_LOG_WARNING, "invalid initiator"); |
| 498 | return false; |
| 499 | } |
| 500 | |
| 501 | // find the destination device, if it's not the broadcast address |
| 502 | if (transmitData.destination != CECDEVICE_BROADCAST) |
| 503 | { |
| 504 | // check if the device is marked as handled by libCEC |
| 505 | CCECBusDevice *destination = m_busDevices->At(transmitData.destination); |
| 506 | if (destination && destination->IsHandledByLibCEC()) |
| 507 | { |
| 508 | // and reject the command if it's trying to send data to a device that is handled by libCEC |
| 509 | m_libcec->AddLog(CEC_LOG_WARNING, "not sending data to myself!"); |
| 510 | return false; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | // wait until we finished allocating a new LA if it got lost if this is not a poll |
nothing calls this directly
no test coverage detected