X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=1fca4a513f04ce99073210d31c0586e806a8374e;hb=88e5de6f3e5f0f0ff13f47490c364aa68b5e773c;hp=3eeb295af5a34ba2c3ab5b6ec8f754a0c0fc6305;hpb=c409848208093a15758c91e3fab9fbe806a62e12;p=deb_libcec.git diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 3eeb295..1fca4a5 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -50,7 +50,7 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi m_powerStatus(CEC_POWER_STATUS_UNKNOWN), m_processor(processor), m_vendor(CEC_VENDOR_UNKNOWN), - m_bMenuActive(true), + m_menuState(CEC_MENU_STATE_ACTIVATED), m_bActiveSource(false), m_iLastCommandSent(0), m_iLastActive(0), @@ -100,7 +100,7 @@ void CCECBusDevice::PollVendorId(void) m_iLastCommandSent = GetTimeMs(); cec_command command; - cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); + cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); if (m_processor->Transmit(command)) m_condition.Wait(&m_mutex, 1000); } @@ -119,7 +119,7 @@ bool CCECBusDevice::PowerOn(void) SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); cec_command command; - cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON); + cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON); return m_processor->Transmit(command); } @@ -134,7 +134,7 @@ bool CCECBusDevice::Standby(void) AddLog(CEC_LOG_DEBUG, strLog.c_str()); cec_command command; - cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY); + cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY); return m_processor->Transmit(command); } @@ -151,7 +151,7 @@ cec_version CCECBusDevice::GetCecVersion(void) strLog.Format("<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION); + cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION); CLockObject lock(&m_mutex); if (m_processor->Transmit(command)) m_condition.Wait(&m_mutex, 1000); @@ -176,7 +176,7 @@ cec_menu_language &CCECBusDevice::GetMenuLanguage(void) strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE); + cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE); CLockObject lock(&m_mutex); if (m_processor->Transmit(command)) m_condition.Wait(&m_mutex, 1000); @@ -206,7 +206,7 @@ cec_power_status CCECBusDevice::GetPowerStatus(void) strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS); + cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS); CLockObject lock(&m_mutex); if (m_processor->Transmit(command)) m_condition.Wait(&m_mutex, 1000); @@ -226,7 +226,7 @@ const cec_vendor_id CCECBusDevice::GetVendorId(void) strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); + cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); CLockObject lock(&m_mutex); if (m_processor->Transmit(command)) @@ -272,6 +272,17 @@ void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language) } } +void CCECBusDevice::SetMenuState(const cec_menu_state state) +{ + if (m_menuState != state) + { + CStdString strLog; + strLog.Format(">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_menuState)); + m_processor->AddLog(CEC_LOG_DEBUG, strLog); + m_menuState = state; + } +} + void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) { if (iNewAddress > 0) @@ -369,9 +380,9 @@ bool CCECBusDevice::TransmitActiveSource(void) AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE); - command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); - command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF)); + cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE); + command.parameters.PushBack((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); + command.parameters.PushBack((uint8_t) (m_iPhysicalAddress & 0xFF)); return m_processor->Transmit(command); } @@ -392,8 +403,8 @@ bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION); - command.parameters.push_back((uint8_t)m_cecVersion); + cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION); + command.parameters.PushBack((uint8_t)m_cecVersion); return m_processor->Transmit(command); } @@ -405,9 +416,9 @@ bool CCECBusDevice::TransmitInactiveView(void) AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE); - command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF); - command.parameters.push_back(m_iPhysicalAddress & 0xFF); + cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE); + command.parameters.PushBack((m_iPhysicalAddress >> 8) & 0xFF); + command.parameters.PushBack(m_iPhysicalAddress & 0xFF); return m_processor->Transmit(command); } @@ -415,16 +426,12 @@ bool CCECBusDevice::TransmitInactiveView(void) bool CCECBusDevice::TransmitMenuState(cec_logical_address dest) { CStdString strLog; - strLog.Format("<< %s (%X) -> %s (%X): ", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); - if (m_bMenuActive) - strLog.append("menu active"); - else - strLog.append("menu inactive"); + strLog.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState)); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS); - command.parameters.push_back(m_bMenuActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED); + cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS); + command.parameters.PushBack((uint8_t)m_menuState); return m_processor->Transmit(command); } @@ -436,9 +443,9 @@ bool CCECBusDevice::TransmitOSDName(cec_logical_address dest) AddLog(CEC_LOG_NOTICE, strLog.c_str()); cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME); + cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME); for (unsigned int iPtr = 0; iPtr < m_strDeviceName.length(); iPtr++) - command.parameters.push_back(m_strDeviceName.at(iPtr)); + command.parameters.PushBack(m_strDeviceName.at(iPtr)); return m_processor->Transmit(command); } @@ -450,14 +457,14 @@ bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_cont AddLog(CEC_LOG_NOTICE, strLog.c_str()); cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_STRING); - command.parameters.push_back((uint8_t)duration); + cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_STRING); + command.parameters.PushBack((uint8_t)duration); unsigned int iLen = strlen(strMessage); if (iLen > 13) iLen = 13; for (unsigned int iPtr = 0; iPtr < iLen; iPtr++) - command.parameters.push_back(strMessage[iPtr]); + command.parameters.PushBack(strMessage[iPtr]); return m_processor->Transmit(command); } @@ -469,10 +476,10 @@ bool CCECBusDevice::TransmitPhysicalAddress(void) AddLog(CEC_LOG_NOTICE, strLog.c_str()); cec_command command; - cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS); - command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); - command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF)); - command.parameters.push_back((uint8_t) (m_type)); + cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS); + command.parameters.PushBack((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); + command.parameters.PushBack((uint8_t) (m_iPhysicalAddress & 0xFF)); + command.parameters.PushBack((uint8_t) (m_type)); return m_processor->Transmit(command); } @@ -489,7 +496,7 @@ bool CCECBusDevice::TransmitPoll(cec_logical_address dest) AddLog(CEC_LOG_NOTICE, strLog.c_str()); cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_NONE); + cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_NONE); CLockObject lock(&m_mutex); bReturn = m_processor->Transmit(command); @@ -504,8 +511,8 @@ bool CCECBusDevice::TransmitPowerState(cec_logical_address dest) AddLog(CEC_LOG_NOTICE, strLog.c_str()); cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS); - command.parameters.push_back((uint8_t) m_powerStatus); + cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS); + command.parameters.PushBack((uint8_t) m_powerStatus); return m_processor->Transmit(command); } @@ -528,11 +535,11 @@ bool CCECBusDevice::TransmitVendorID(cec_logical_address dest) AddLog(CEC_LOG_NOTICE, strLog); cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); + cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_DEVICE_VENDOR_ID); - command.parameters.push_back((uint8_t) (((uint64_t)m_vendor >> 16) & 0xFF)); - command.parameters.push_back((uint8_t) (((uint64_t)m_vendor >> 8) & 0xFF)); - command.parameters.push_back((uint8_t) ((uint64_t)m_vendor & 0xFF)); + command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 16) & 0xFF)); + command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 8) & 0xFF)); + command.parameters.PushBack((uint8_t) ((uint64_t)m_vendor & 0xFF)); return m_processor->Transmit(command); }