From: Mark Kendall Date: Tue, 10 Apr 2012 09:16:24 +0000 (+0100) Subject: Respond to Get Menu Language. bugzid: 547 X-Git-Tag: upstream/2.2.0~1^2~31^2~14 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fbdea54c9e414a98d3ff8ef4a4d03e7ff3568427;p=deb_libcec.git Respond to Get Menu Language. bugzid: 547 In the event that the menu language is undefined in libcec (currently the default), the response will be a feature abort. --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index a3208ba..ab1d710 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -888,6 +888,35 @@ bool CCECBusDevice::TransmitPhysicalAddress(void) return bReturn; } +bool CCECBusDevice::TransmitSetMenuLanguage(cec_logical_address dest) +{ + bool bReturn(false); + cec_menu_language language = GetMenuLanguage(); + + char lang[3]; + { + CLockObject lock(m_mutex); + lang[0] = language.language[0]; + lang[1] = language.language[1]; + lang[2] = language.language[2]; + } + + MarkBusy(); + if (lang[0] == '?' && lang[1] == '?' && lang[2] == '?') + { + CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): Menu language feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); + m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); + bReturn = true; + } + else + { + CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): Menu language '%s'", GetLogicalAddressName(), m_iLogicalAddress, lang); + bReturn = m_handler->TransmitSetMenuLanguage(m_iLogicalAddress, lang); + } + MarkReady(); + return bReturn; +} + bool CCECBusDevice::TransmitPoll(cec_logical_address dest) { bool bReturn(false); diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 30ac2dc..09d3648 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -100,6 +100,7 @@ namespace CEC virtual bool TransmitOSDName(cec_logical_address dest); virtual bool TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage); virtual bool TransmitPhysicalAddress(void); + virtual bool TransmitSetMenuLanguage(cec_logical_address dest); virtual bool TransmitPowerState(cec_logical_address dest); virtual bool TransmitPoll(cec_logical_address dest); virtual bool TransmitVendorID(cec_logical_address dest, bool bSendAbort = true); diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 0668ee7..eefc0e3 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -83,6 +83,10 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) if (m_processor->IsInitialised()) HandleGivePhysicalAddress(command); break; + case CEC_OPCODE_GET_MENU_LANGUAGE: + if (m_processor->IsInitialised()) + HandleGiveMenuLanguage(command); + break; case CEC_OPCODE_GIVE_OSD_NAME: if (m_processor->IsInitialised()) HandleGiveOSDName(command); @@ -341,6 +345,18 @@ bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) return false; } +bool CCECCommandHandler::HandleGiveMenuLanguage(const cec_command &command) +{ + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) + { + CCECBusDevice *device = GetDevice(command.destination); + if (device) + return device->TransmitSetMenuLanguage(command.initiator); + } + + return false; +} + bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command) { if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) @@ -875,6 +891,17 @@ bool CCECCommandHandler::TransmitPhysicalAddress(const cec_logical_address iInit return Transmit(command, false); } +bool CCECCommandHandler::TransmitSetMenuLanguage(const cec_logical_address iInitiator, const char lang[3]) +{ + cec_command command; + command.Format(command, iInitiator, CECDEVICE_BROADCAST, CEC_OPCODE_SET_MENU_LANGUAGE); + command.parameters.PushBack((uint8_t) lang[0]); + command.parameters.PushBack((uint8_t) lang[1]); + command.parameters.PushBack((uint8_t) lang[2]); + + return Transmit(command, false); +} + bool CCECCommandHandler::TransmitPoll(const cec_logical_address iInitiator, const cec_logical_address iDestination) { cec_command command; diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index 6cf16a4..da2d921 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -145,6 +145,7 @@ namespace CEC virtual bool TransmitOSDName(const cec_logical_address iInitiator, const cec_logical_address iDestination, CStdString strDeviceName); virtual bool TransmitOSDString(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_display_control duration, const char *strMessage); virtual bool TransmitPhysicalAddress(const cec_logical_address iInitiator, uint16_t iPhysicalAddress, cec_device_type type); + virtual bool TransmitSetMenuLanguage(const cec_logical_address iInitiator, const char lang[3]); virtual bool TransmitPoll(const cec_logical_address iInitiator, const cec_logical_address iDestination); virtual bool TransmitPowerState(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_power_status state); virtual bool TransmitVendorID(const cec_logical_address iInitiator, uint64_t iVendorId); @@ -171,6 +172,7 @@ namespace CEC virtual bool HandleGiveDeviceVendorId(const cec_command &command); virtual bool HandleGiveOSDName(const cec_command &command); virtual bool HandleGivePhysicalAddress(const cec_command &command); + virtual bool HandleGiveMenuLanguage(const cec_command &command); virtual bool HandleGiveSystemAudioModeStatus(const cec_command &command); virtual bool HandleImageViewOn(const cec_command &command); virtual bool HandleMenuRequest(const cec_command &command);