X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2FCECProcessor.cpp;h=7f4f366c04776188628924418f3fb743ebb11689;hb=90ea9066b2b0d23b3c05e7267bfab4f2a1d4a6e2;hp=81f501bf752c0183e906d31fd59ed6adb7818575;hpb=8fa354734e6dd2fd2e6fae68f7bbaf7ea84cbdfd;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 81f501b..7f4f366 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -158,7 +158,7 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, if (SetAckMask(m_logicalAddresses.AckMask()) && SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true)) { - m_controller->AddLog(CEC_LOG_ERROR, "processor thread started"); + m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); m_busScan = new CCECBusScan(this); m_busScan->CreateThread(true); return true; @@ -314,7 +314,7 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE if (type != CEC_DEVICE_TYPE_RESERVED) { - for (uint8_t iPtr = 0; iPtr < 16; iPtr++) + for (uint8_t iPtr = 0; iPtr <= 11; iPtr++) { if (m_logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type) { @@ -680,8 +680,13 @@ bool CCECProcessor::Transmit(const cec_command &data) CCECAdapterMessage *output = new CCECAdapterMessage(data); bReturn = Transmit(output); - delete output; + /* set to "not present" on failed ack */ + if (output->is_error() && output->reply == MSGCODE_TRANSMIT_FAILED_ACK && + output->destination() != CECDEVICE_BROADCAST) + m_busDevices[output->destination()]->SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT); + + delete output; return bReturn; } @@ -691,6 +696,7 @@ bool CCECProcessor::Transmit(CCECAdapterMessage *output) CLockObject lock(&m_mutex); { m_communication->SetLineTimeout(m_iStandardLineTimeout); + output->tries = 1; do { @@ -717,7 +723,7 @@ bool CCECProcessor::Transmit(CCECAdapterMessage *output) } else bReturn = true; - }while (output->transmit_timeout > 0 && output->needs_retry() && ++output->tries <= output->maxTries); + }while (output->transmit_timeout > 0 && output->needs_retry() && ++output->tries < output->maxTries); } m_communication->SetLineTimeout(m_iStandardLineTimeout); @@ -826,7 +832,7 @@ bool CCECProcessor::ParseMessage(const CCECAdapterMessage &msg) m_currentframe.ack = msg.ack(); m_currentframe.eom = msg.eom(); } - if (m_currentframe.ack == true) + if (m_currentframe.ack == 0x1) { m_lastInitiator = m_currentframe.initiator; m_busDevices[m_lastInitiator]->GetHandler()->HandlePoll(m_currentframe.initiator, m_currentframe.destination); @@ -952,14 +958,14 @@ bool CCECProcessor::SetAckMask(uint16_t iMask) return bReturn; } -bool CCECProcessor::SendKeypress(cec_logical_address iDestination, cec_user_control_code key) +bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key) { - return m_busDevices[iDestination]->SendKeypress(key); + return m_busDevices[iDestination]->TransmitKeypress(key); } -bool CCECProcessor::SendKeyRelease(cec_logical_address iDestination) +bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination) { - return m_busDevices[iDestination]->SendKeyRelease(); + return m_busDevices[iDestination]->TransmitKeyRelease(); } const char *CCECProcessor::ToString(const cec_menu_state state) @@ -1286,19 +1292,26 @@ const char *CCECProcessor::ToString(const cec_vendor_id vendor) void *CCECBusScan::Process(void) { CCECBusDevice *device(NULL); - int iCount(0); + int iCount(50); while (!IsStopped()) { if (iCount == 0) { - for (unsigned int iPtr = 0; iPtr < 15 && !IsStopped(); iPtr++) + for (unsigned int iPtr = 0; iPtr <= 11 && !IsStopped(); iPtr++) { device = m_processor->m_busDevices[iPtr]; if (device && device->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT) { if (!IsStopped()) + { device->GetVendorId(); - Sleep(5); + Sleep(5); + } + if (!IsStopped()) + { + device->GetPowerStatus(true); + Sleep(5); + } } } }