X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FCECCommandHandler.cpp;h=0f006272e2d2d45d1a426350013f114ecf60489c;hb=f42d3e0fb1f63456b87232019d9cce731acad640;hp=ebd2ec24a829e008dfa55a6aa2c1fc02d9f787f6;hpb=02e7043ec09609e351130b648b282f25a3e1f2b9;p=deb_libcec.git diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index ebd2ec2..0f00627 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -1,7 +1,7 @@ /* * This file is part of the libCEC(R) library. * - * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. @@ -239,7 +239,7 @@ bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command) bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) m_processor->TransmitAbort(command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED); return true; @@ -261,7 +261,7 @@ bool CCECCommandHandler::HandleFeatureAbort(const cec_command &command) bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -273,7 +273,7 @@ bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command) bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) @@ -285,7 +285,7 @@ bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command) bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)) @@ -297,7 +297,7 @@ bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command) bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -309,7 +309,7 @@ bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -321,7 +321,7 @@ bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command) bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -333,7 +333,7 @@ bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command) bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -349,7 +349,7 @@ bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) @@ -367,7 +367,7 @@ bool CCECCommandHandler::HandleImageViewOn(const cec_command &command) bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY) { @@ -417,7 +417,7 @@ bool CCECCommandHandler::HandleReportPowerStatus(const cec_command &command) bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) { - if (m_processor->IsStarted()) + if (m_processor->IsRunning()) { CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %i requests active source", (uint8_t) command.initiator); @@ -497,7 +497,7 @@ bool CCECCommandHandler::HandleSetOSDName(const cec_command &command) bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) { - if (m_processor->IsStarted() && command.parameters.size >= 2) + if (m_processor->IsRunning() && command.parameters.size >= 2) { uint16_t iStreamAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress); @@ -508,6 +508,9 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) { device->SetActiveSource(); device->TransmitActiveSource(); + + device->SetMenuState(CEC_MENU_STATE_ACTIVATED); + device->TransmitMenuState(command.initiator); } } return false; @@ -515,7 +518,7 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) bool CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) @@ -587,7 +590,7 @@ bool CCECCommandHandler::HandleTextViewOn(const cec_command &command) bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination) && command.parameters.size > 0) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination) && command.parameters.size > 0) { CLibCEC::AddKey(); @@ -623,7 +626,7 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) CLibCEC::AddKey(); return true; @@ -711,17 +714,6 @@ void CCECCommandHandler::SetPhysicalAddress(cec_logical_address iAddress, uint16 } } -void CCECCommandHandler::HandlePoll(const cec_logical_address iInitiator, const cec_logical_address iDestination) -{ - CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", m_processor->ToString(iInitiator), iInitiator, m_processor->ToString(iDestination), iDestination); -} - -bool CCECCommandHandler::HandleReceiveFailed(void) -{ - /* default = error */ - return true; -} - bool CCECCommandHandler::TransmitImageViewOn(const cec_logical_address iInitiator, const cec_logical_address iDestination) { cec_command command; @@ -907,6 +899,16 @@ bool CCECCommandHandler::TransmitSetSystemAudioMode(const cec_logical_address iI return Transmit(command, false); } +bool CCECCommandHandler::TransmitSetStreamPath(uint16_t iStreamPath) +{ + cec_command command; + cec_command::Format(command, m_busDevice->GetLogicalAddress(), CECDEVICE_BROADCAST, CEC_OPCODE_SET_STREAM_PATH); + command.parameters.PushBack((uint8_t) ((iStreamPath >> 8) & 0xFF)); + command.parameters.PushBack((uint8_t) (iStreamPath & 0xFF)); + + return Transmit(command, false); +} + bool CCECCommandHandler::TransmitSystemAudioModeStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_system_audio_status state) { cec_command command; @@ -956,12 +958,11 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* while (!bReturn && ++iTries <= iMaxTries) { m_expectedResponse = expectedResponse; - if (m_processor->Transmit(command)) + if ((bReturn = m_processor->Transmit(command)) == true) { CLibCEC::AddLog(CEC_LOG_DEBUG, "command transmitted"); - bReturn = bExpectResponse ? - m_condition.Wait(m_receiveMutex, m_iTransmitWait) : - true; + if (bExpectResponse) + bReturn = m_condition.Wait(m_receiveMutex, m_iTransmitWait); } } --m_iUseCounter;