From: Lars Op den Kamp Date: Fri, 25 Nov 2011 00:11:53 +0000 (+0100) Subject: cec: changed - pass all commands that are directed at libcec to listeners. handle... X-Git-Tag: upstream/2.2.0~1^2~44^2~109 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=15d1a84cf1eeaa80ab27ec3f48390073ca2ded75;p=deb_libcec.git cec: changed - pass all commands that are directed at libcec to listeners. handle report audio state and set osd name --- diff --git a/src/lib/devices/CECAudioSystem.cpp b/src/lib/devices/CECAudioSystem.cpp index 67d25d6..1196544 100644 --- a/src/lib/devices/CECAudioSystem.cpp +++ b/src/lib/devices/CECAudioSystem.cpp @@ -44,12 +44,12 @@ CCECAudioSystem::CCECAudioSystem(CCECProcessor *processor, cec_logical_address a m_type = CEC_DEVICE_TYPE_AUDIO_SYSTEM; } -bool CCECAudioSystem::SetAudioStatus(const cec_audio_status status) +bool CCECAudioSystem::SetAudioStatus(uint8_t status) { if (m_audioStatus != status) { CStdString strLog; - strLog.Format(">> %s (%X): audio status changed from %s to %s", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(m_audioStatus), CCECCommandHandler::ToString(status)); + strLog.Format(">> %s (%X): audio status changed from %2x to %2x", GetLogicalAddressName(), m_iLogicalAddress, m_audioStatus, status); AddLog(CEC_LOG_DEBUG, strLog.c_str()); m_audioStatus = status; @@ -86,12 +86,12 @@ bool CCECAudioSystem::SetSystemAudioMode(const cec_command &command) bool CCECAudioSystem::TransmitAudioStatus(cec_logical_address dest) { CStdString strLog; - strLog.Format("<< %x -> %x: audio status '%2x'", m_iLogicalAddress, dest, CCECCommandHandler::ToString(m_audioStatus)); + strLog.Format("<< %x -> %x: audio status '%2x'", m_iLogicalAddress, dest, m_audioStatus); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_AUDIO_STATUS); - command.parameters.PushBack((uint8_t) m_audioStatus); + command.parameters.PushBack(m_audioStatus); return m_processor->Transmit(command); } diff --git a/src/lib/devices/CECAudioSystem.h b/src/lib/devices/CECAudioSystem.h index 0a80dac..9a9603e 100644 --- a/src/lib/devices/CECAudioSystem.h +++ b/src/lib/devices/CECAudioSystem.h @@ -41,7 +41,7 @@ namespace CEC CCECAudioSystem(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0); virtual ~CCECAudioSystem(void) {}; - virtual bool SetAudioStatus(const cec_audio_status status); + virtual bool SetAudioStatus(uint8_t status); virtual bool SetSystemAudioMode(const cec_system_audio_status mode); virtual bool SetSystemAudioMode(const cec_command &command); virtual bool TransmitAudioStatus(cec_logical_address dest); @@ -51,6 +51,6 @@ namespace CEC protected: cec_system_audio_status m_systemAudioStatus; - cec_audio_status m_audioStatus; + uint8_t m_audioStatus; }; } diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index d852969..1227f8d 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -265,6 +265,18 @@ void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language) } } +void CCECBusDevice::SetOSDName(CStdString strName) +{ + CLockObject lock(&m_mutex); + if (m_strDeviceName != strName) + { + CStdString strLog; + strLog.Format(">> %s (%X): osd name set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, strName); + m_processor->AddLog(CEC_LOG_DEBUG, strLog); + m_strDeviceName = strName; + } +} + void CCECBusDevice::SetMenuState(const cec_menu_state state) { CLockObject lock(&m_mutex); diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 477109b..748758c 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -78,6 +78,7 @@ namespace CEC virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = 0); virtual void SetCecVersion(const cec_version newVersion); virtual void SetMenuLanguage(const cec_menu_language &menuLanguage); + virtual void SetOSDName(CStdString strName); virtual void SetMenuState(const cec_menu_state state); virtual void SetVendorId(uint64_t iVendorId); virtual void SetPowerStatus(const cec_power_status powerStatus); diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 366f7dd..037825a 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -129,14 +129,21 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS: HandleReportPhysicalAddress(command); break; + case CEC_OPCODE_REPORT_AUDIO_STATUS: + HandleReportAudioStatus(command); + break; + case CEC_OPCODE_SET_OSD_NAME: + HandleSetOSDName(command); + break; default: UnhandledCommand(command); - if (command.destination == CECDEVICE_BROADCAST || m_busDevice->MyLogicalAddressContains(command.destination)) - m_busDevice->GetProcessor()->AddCommand(command); bHandled = false; break; } + if (command.destination == CECDEVICE_BROADCAST || m_busDevice->MyLogicalAddressContains(command.destination)) + m_busDevice->GetProcessor()->AddCommand(command); + return bHandled; } @@ -144,8 +151,6 @@ bool CCECCommandHandler::HandleActiveSource(const cec_command &command) { if (command.parameters.size == 2) { - m_busDevice->GetProcessor()->AddCommand(command); - uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); return m_busDevice->GetProcessor()->SetStreamPath(iAddress); } @@ -158,8 +163,6 @@ bool CCECCommandHandler::HandleDeckControl(const cec_command &command) CCECBusDevice *device = GetDevice(command.destination); if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && command.parameters.size > 0) { - m_busDevice->GetProcessor()->AddCommand(command); - ((CCECPlaybackDevice *) device)->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]); return true; } @@ -287,12 +290,22 @@ bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) if (device) return device->TransmitMenuState(command.initiator); } - else + } + + return false; +} + +bool CCECCommandHandler::HandleReportAudioStatus(const cec_command &command) +{ + if (command.parameters.size == 1) + { + CCECBusDevice *device = GetDevice(command.initiator); + if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) { - m_busDevice->GetProcessor()->AddCommand(command); + ((CCECAudioSystem *)device)->SetAudioStatus(command.parameters[0]); + return true; } } - return false; } @@ -356,8 +369,13 @@ bool CCECCommandHandler::HandleRoutingInformation(const cec_command &command) CCECBusDevice *device = GetDevice(command.initiator); if (device) + { device->SetPhysicalAddress(iNewAddress); + return true; + } } + + return false; } bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command) @@ -373,12 +391,31 @@ bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command) language.language[iPtr] = command.parameters[iPtr]; language.language[3] = 0; device->SetMenuLanguage(language); + return true; + } + } + return false; +} - if (m_busDevice->MyLogicalAddressContains(command.destination)) - m_busDevice->GetProcessor()->AddCommand(command); +bool CCECCommandHandler::HandleSetOSDName(const cec_command &command) +{ + if (command.parameters.size > 0) + { + CCECBusDevice *device = GetDevice(command.initiator); + if (device) + { + char buf[1024]; + for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) + buf[iPtr] = (char)command.parameters[iPtr]; + buf[command.parameters.size] = 0; + + CStdString strName(buf); + device->SetOSDName(strName); + + return true; } } - return true; + return false; } bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) @@ -399,9 +436,8 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) device->TransmitMenuState(command.initiator); } } - return false; } - return true; + return false; } bool CCECCommandHandler::HandleSetSystemAudioModeRequest(const cec_command &command) @@ -421,8 +457,6 @@ bool CCECCommandHandler::HandleStandby(const cec_command &command) if (device) device->SetPowerStatus(CEC_POWER_STATUS_STANDBY); - m_busDevice->GetProcessor()->AddCommand(command); - return true; } @@ -459,9 +493,10 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) } m_busDevice->GetProcessor()->SetCurrentButton((cec_user_control_code) command.parameters[0]); + return true; } } - return true; + return false; } bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command) diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index c398427..8b31d2c 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -72,12 +72,14 @@ namespace CEC virtual bool HandleGiveOSDName(const cec_command &command); virtual bool HandleGivePhysicalAddress(const cec_command &command); virtual bool HandleMenuRequest(const cec_command &command); + virtual bool HandleReportAudioStatus(const cec_command &command); virtual bool HandleReportPhysicalAddress(const cec_command &command); virtual bool HandleReportPowerStatus(const cec_command &command); virtual bool HandleRequestActiveSource(const cec_command &command); virtual bool HandleRoutingChange(const cec_command &command); virtual bool HandleRoutingInformation(const cec_command &command); virtual bool HandleSetMenuLanguage(const cec_command &command); + virtual bool HandleSetOSDName(const cec_command &command); virtual bool HandleSetStreamPath(const cec_command &command); virtual bool HandleSetSystemAudioModeRequest(const cec_command &command); virtual bool HandleStandby(const cec_command &command);