Respond to Get Menu Language. bugzid: 547
authorMark Kendall <mkendall@mythtv.org>
Tue, 10 Apr 2012 09:16:24 +0000 (10:16 +0100)
committerMark Kendall <mkendall@mythtv.org>
Tue, 10 Apr 2012 09:16:24 +0000 (10:16 +0100)
In the event that the menu language is undefined in libcec (currently
the default), the response will be a feature abort.

src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h

index a3208baea8b023977f98e8f0cdc9fa0e1c5ec621..ab1d710f9b4f0f7542dc633a036a1bd90883e9a0 100644 (file)
@@ -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);
index 30ac2dc788df51c50251eaae0c8a4488799ccc03..09d36480c7b0556bc17fecefdcd9f39505d98128 100644 (file)
@@ -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);
index 0668ee793bd16e3e6c1b47c58b3f8b76df251302..eefc0e3c5b2914c63f854e6c00c18788b139cc6a 100644 (file)
@@ -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;
index 6cf16a4b4615290b52507c8833498917406b4701..da2d92123b89ff60dce1c9ed486aa00bc01be5d5 100644 (file)
@@ -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);