From: Lars Op den Kamp Date: Thu, 10 Nov 2011 17:30:00 +0000 (+0100) Subject: cec: mark the active source as active and other devices as inactive. removed duplicat... X-Git-Tag: upstream/2.2.0~1^2~75 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8ac9c610be214885ff040d23acb707eeaba1276c;p=deb_libcec.git cec: mark the active source as active and other devices as inactive. removed duplicate method SetActiveSource() / SetActiveView() --- diff --git a/include/cectypes.h b/include/cectypes.h index cb647fd..4a50371 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -115,15 +115,15 @@ typedef enum CEC_MINOR_CHANNEL_NUMBER_MASK = 0xFFFF } ECecChannelIdentifier; -typedef enum +typedef enum cec_deck_control_mode { CEC_DESK_CONTROL_MODE_SKIP_FORWARD_WIND = 1, CEC_DESK_CONTROL_MODE_SKIP_REVERSE_REWIND = 2, CEC_DESK_CONTROL_MODE_STOP = 3, CEC_DESK_CONTROL_MODE_EJECT = 4 -} ECecDeskControlMode; +} cec_deck_control_mode; -typedef enum +typedef enum cec_deck_info { CEC_DECK_INFO_PLAY = 0x11, CEC_DECK_INFO_RECORD = 0x12, @@ -140,7 +140,7 @@ typedef enum CEC_DECK_INFO_INDEX_SEARCH_FORWARD = 0x1D, CEC_DECK_INFO_INDEX_SEARCH_REVERSE = 0x1E, CEC_DECK_INFO_OTHER_STATUS = 0x1F -} ECecDeckInfo; +} cec_deck_info; typedef enum cec_device_type { diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 1bd39dd..53a1da3 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -292,11 +292,31 @@ void *CCECProcessor::Process(void) bool CCECProcessor::SetActiveView(void) { + bool bReturn(false); + if (!IsRunning()) - return false; + return bReturn; if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary]) - return m_busDevices[m_logicalAddresses.primary]->TransmitActiveView(); + { + SetStreamPath(m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress()); + bReturn = m_busDevices[m_logicalAddresses.primary]->TransmitActiveSource(); + } + return false; +} + +bool CCECProcessor::SetStreamPath(uint16_t iStreamPath) +{ + CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath); + if (device) + { + for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + m_busDevices[iPtr]->m_bActiveSource = false; + + device->m_bActiveSource = true; + return true; + } + return false; } @@ -342,7 +362,7 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress) if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary]) { m_busDevices[m_logicalAddresses.primary]->SetPhysicalAddress(iPhysicalAddress); - return m_busDevices[m_logicalAddresses.primary]->TransmitActiveView(); + return SetActiveView(); } return false; } @@ -367,6 +387,23 @@ bool CCECProcessor::PollDevice(cec_logical_address iAddress) return false; } + +CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const +{ + CCECBusDevice *device = NULL; + + for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + { + if (m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress) + { + device = m_busDevices[iPtr]; + break; + } + } + + return device; +} + cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress) { return m_busDevices[iAddress]->GetCecVersion(); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 8baf726..75651d7 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -57,6 +57,7 @@ namespace CEC virtual void *Process(void); virtual bool IsMonitoring(void) const { return m_bMonitor; } + virtual CCECBusDevice * GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const; virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress); virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language); virtual const std::string & GetDeviceName(void) { return m_strDeviceName; } @@ -71,6 +72,7 @@ namespace CEC virtual bool SetInactiveView(void); virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress); virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress); + virtual bool SetStreamPath(uint16_t iStreamPath); virtual bool SwitchMonitoring(bool bEnable); virtual bool PollDevice(cec_logical_address iAddress); diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 640534d..49ca7db 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -391,20 +391,6 @@ bool CCECBusDevice::TransmitActiveSource(void) return false; } -bool CCECBusDevice::TransmitActiveView(void) -{ - CStdString strLog; - strLog.Format("<< %s (%X) -> broadcast (F): active view (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress); - AddLog(CEC_LOG_NOTICE, strLog); - - cec_command command; - cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE); - command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF); - command.parameters.push_back(m_iPhysicalAddress & 0xFF); - - return m_processor->Transmit(command); -} - bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) { CStdString strLog; diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 6e59967..d07f4c8 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -81,7 +81,6 @@ namespace CEC virtual void SetPowerStatus(const cec_power_status powerStatus); virtual bool TransmitActiveSource(void); - virtual bool TransmitActiveView(void); virtual bool TransmitCECVersion(cec_logical_address dest); virtual bool TransmitInactiveView(void); virtual bool TransmitMenuState(cec_logical_address dest); diff --git a/src/lib/devices/CECPlaybackDevice.cpp b/src/lib/devices/CECPlaybackDevice.cpp index d96d5c9..ef6f00b 100644 --- a/src/lib/devices/CECPlaybackDevice.cpp +++ b/src/lib/devices/CECPlaybackDevice.cpp @@ -37,11 +37,24 @@ using namespace CEC; CCECPlaybackDevice::CCECPlaybackDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress /* = 0 */) : - CCECBusDevice(processor, address, iPhysicalAddress) + CCECBusDevice(processor, address, iPhysicalAddress), + m_deckStatus(CEC_DECK_INFO_NO_MEDIA) { m_type = CEC_DEVICE_TYPE_PLAYBACK_DEVICE; } +void CCECPlaybackDevice::SetDeckStatus(cec_deck_info deckStatus) +{ + if (m_deckStatus != deckStatus) + { + CStdString strLog; + strLog.Format(">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(m_deckStatus), CCECCommandHandler::ToString(deckStatus)); + AddLog(CEC_LOG_DEBUG, strLog.c_str()); + + m_deckStatus = deckStatus; + } +} + bool CCECPlaybackDevice::TransmitDeckStatus(cec_logical_address dest) { // need to support opcodes play and deck control before doing anything with this diff --git a/src/lib/devices/CECPlaybackDevice.h b/src/lib/devices/CECPlaybackDevice.h index 1af9485..24ce072 100644 --- a/src/lib/devices/CECPlaybackDevice.h +++ b/src/lib/devices/CECPlaybackDevice.h @@ -41,6 +41,13 @@ namespace CEC CCECPlaybackDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0); virtual ~CCECPlaybackDevice(void) {}; + virtual cec_deck_info GetDeckStatus(void) const { return m_deckStatus; }; + + virtual void SetDeckStatus(cec_deck_info deckStatus); + virtual bool TransmitDeckStatus(cec_logical_address dest); + + protected: + cec_deck_info m_deckStatus; }; } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 2f6dd69..7229480 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -422,18 +422,7 @@ CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const { - CCECBusDevice *device = NULL; - - for (unsigned int iPtr = 0; iPtr < 16; iPtr++) - { - if (m_busDevice->GetProcessor()->m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress) - { - device = m_busDevice->GetProcessor()->m_busDevices[iPtr]; - break; - } - } - - return device; + return m_busDevice->GetProcessor()->GetDeviceByPhysicalAddress(iPhysicalAddress); } void CCECCommandHandler::SetVendorId(const cec_command &command) @@ -494,6 +483,45 @@ const char *CCECCommandHandler::ToString(const cec_logical_address address) } } +const char *CCECCommandHandler::ToString(const cec_deck_info status) +{ + switch (status) + { + case CEC_DECK_INFO_PLAY: + return "play"; + case CEC_DECK_INFO_RECORD: + return "record"; + case CEC_DECK_INFO_PLAY_REVERSE: + return "play reverse"; + case CEC_DECK_INFO_STILL: + return "still"; + case CEC_DECK_INFO_SLOW: + return "slow"; + case CEC_DECK_INFO_SLOW_REVERSE: + return "slow reverse"; + case CEC_DECK_INFO_FAST_FORWARD: + return "fast forward"; + case CEC_DECK_INFO_FAST_REVERSE: + return "fast reverse"; + case CEC_DECK_INFO_NO_MEDIA: + return "no media"; + case CEC_DECK_INFO_STOP: + return "stop"; + case CEC_DECK_INFO_SKIP_FORWARD_WIND: + return "info skip forward wind"; + case CEC_DECK_INFO_SKIP_REVERSE_REWIND: + return "info skip reverse rewind"; + case CEC_DECK_INFO_INDEX_SEARCH_FORWARD: + return "info index search forward"; + case CEC_DECK_INFO_INDEX_SEARCH_REVERSE: + return "info index search reverse"; + case CEC_DECK_INFO_OTHER_STATUS: + return "other"; + default: + return "unknown"; + } +} + const char *CCECCommandHandler::ToString(const cec_opcode opcode) { switch (opcode) diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index 934dfc5..58b13e9 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -47,6 +47,7 @@ namespace CEC virtual bool HandleCommand(const cec_command &command); virtual cec_vendor_id GetVendorId(void) { return CEC_VENDOR_UNKNOWN; }; + static const char *ToString(const cec_deck_info status); static const char* ToString(const cec_logical_address address); static const char* ToString(const cec_opcode opcode); diff --git a/src/lib/implementations/VLCommandHandler.cpp b/src/lib/implementations/VLCommandHandler.cpp index d1c7605..e3d570b 100644 --- a/src/lib/implementations/VLCommandHandler.cpp +++ b/src/lib/implementations/VLCommandHandler.cpp @@ -55,7 +55,6 @@ bool CVLCommandHandler::HandleSetStreamPath(const cec_command &command) if (device) { return device->TransmitActiveSource() && - device->TransmitActiveView() && device->TransmitMenuState(command.initiator); } return false;