From 9a54dc825e7730a1f2cb8edb201256dbd88da614 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 19 Jun 2012 22:32:43 +0200 Subject: [PATCH] cec: changed all Handle...() commands to return a cec_abort_reason and send the correct abort reason to the initiator as a response to directly addressed messages --- src/lib/CECTypeUtils.h | 19 + src/lib/implementations/ANCommandHandler.cpp | 76 ++-- src/lib/implementations/ANCommandHandler.h | 4 +- src/lib/implementations/CECCommandHandler.cpp | 424 ++++++++++-------- src/lib/implementations/CECCommandHandler.h | 74 +-- src/lib/implementations/SLCommandHandler.cpp | 95 ++-- src/lib/implementations/SLCommandHandler.h | 16 +- src/lib/implementations/VLCommandHandler.cpp | 4 +- src/lib/implementations/VLCommandHandler.h | 2 +- 9 files changed, 376 insertions(+), 338 deletions(-) diff --git a/src/lib/CECTypeUtils.h b/src/lib/CECTypeUtils.h index 5e39f54..20b8cbc 100644 --- a/src/lib/CECTypeUtils.h +++ b/src/lib/CECTypeUtils.h @@ -556,5 +556,24 @@ namespace CEC return "Unknown"; } } + + static const char *ToString(const cec_abort_reason reason) + { + switch(reason) + { + case CEC_ABORT_REASON_UNRECOGNIZED_OPCODE: + return "unrecognised opcode"; + case CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND: + return "not in correct mode to respond"; + case CEC_ABORT_REASON_CANNOT_PROVIDE_SOURCE: + return "cannot provide source"; + case CEC_ABORT_REASON_INVALID_OPERAND: + return "invalid operand"; + case CEC_ABORT_REASON_REFUSED: + return "refused"; + default: + return "unknown"; + } + } }; } diff --git a/src/lib/implementations/ANCommandHandler.cpp b/src/lib/implementations/ANCommandHandler.cpp index 7c2d059..554b637 100644 --- a/src/lib/implementations/ANCommandHandler.cpp +++ b/src/lib/implementations/ANCommandHandler.cpp @@ -48,61 +48,45 @@ CANCommandHandler::CANCommandHandler(CCECBusDevice *busDevice) : m_bOPTSendDeckStatusUpdateOnActiveSource = false; } -bool CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command) +int CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command) { - if (m_processor->CECInitialised() && command.parameters.size > 0) - { - CCECClient *client = m_processor->GetClient(command.destination); - - cec_keypress key; - key.duration = CEC_BUTTON_TIMEOUT; - key.keycode = CEC_USER_CONTROL_CODE_UNKNOWN; + if (command.parameters.size == 0) + return CEC_ABORT_REASON_INVALID_OPERAND; - switch (command.parameters[0]) - { - case CEC_USER_CONTROL_CODE_AN_RETURN: - key.keycode = client && client->GetClientVersion() >= CEC_CLIENT_VERSION_1_5_0 ? - CEC_USER_CONTROL_CODE_AN_RETURN : - CEC_USER_CONTROL_CODE_EXIT; - break; - case CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST: - key.keycode = CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST; - break; - default: - break; - } + if (!m_processor->CECInitialised()) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; - if (key.keycode != CEC_USER_CONTROL_CODE_UNKNOWN && client) - client->AddKey(key); - } + CCECClient *client = m_processor->GetClient(command.destination); + if (!client) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; - return true; -} + cec_keypress key; + key.duration = CEC_BUTTON_TIMEOUT; + key.keycode = CEC_USER_CONTROL_CODE_UNKNOWN; -bool CANCommandHandler::HandleCommand(const cec_command &command) -{ - bool bHandled(false); - if (m_processor->IsHandledByLibCEC(command.destination)) + switch (command.parameters[0]) { - switch(command.opcode) - { - case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN: - bHandled = true; - HandleVendorRemoteButtonDown(command); - break; - case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP: - bHandled = true; - HandleUserControlRelease(command); - break; - default: - break; - } + case CEC_USER_CONTROL_CODE_AN_RETURN: + key.keycode = client && client->GetClientVersion() >= CEC_CLIENT_VERSION_1_5_0 ? + CEC_USER_CONTROL_CODE_AN_RETURN : + CEC_USER_CONTROL_CODE_EXIT; + break; + case CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST: + key.keycode = CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST; + break; + default: + break; } - if (!bHandled) - bHandled = CCECCommandHandler::HandleCommand(command); + if (key.keycode != CEC_USER_CONTROL_CODE_UNKNOWN && client) + client->AddKey(key); + + return COMMAND_HANDLED; +} - return bHandled; +int CANCommandHandler::HandleVendorRemoteButtonUp(const cec_command &command) +{ + return HandleUserControlRelease(command); } bool CANCommandHandler::PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination) diff --git a/src/lib/implementations/ANCommandHandler.h b/src/lib/implementations/ANCommandHandler.h index 567684f..7a9d9e4 100644 --- a/src/lib/implementations/ANCommandHandler.h +++ b/src/lib/implementations/ANCommandHandler.h @@ -41,10 +41,10 @@ namespace CEC CANCommandHandler(CCECBusDevice *busDevice); virtual ~CANCommandHandler(void) {}; - bool HandleCommand(const cec_command &command); + int HandleVendorRemoteButtonDown(const cec_command &command); + int HandleVendorRemoteButtonUp(const cec_command &command); protected: - bool HandleVendorRemoteButtonDown(const cec_command &command); bool PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination); }; }; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 2bab840..6db30a4 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -71,7 +71,7 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) if (command.opcode_set == 0) return HandlePoll(command); - bool bHandled(true); + int iHandled(CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); CCECClient *client = m_busDevice->GetClient(); if (client) @@ -80,313 +80,314 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) switch(command.opcode) { case CEC_OPCODE_REPORT_POWER_STATUS: - HandleReportPowerStatus(command); + iHandled = HandleReportPowerStatus(command); break; case CEC_OPCODE_CEC_VERSION: - HandleDeviceCecVersion(command); + iHandled = HandleDeviceCecVersion(command); break; case CEC_OPCODE_SET_MENU_LANGUAGE: - HandleSetMenuLanguage(command); + iHandled = HandleSetMenuLanguage(command); break; case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS: - if (m_processor->CECInitialised()) - HandleGivePhysicalAddress(command); + iHandled = HandleGivePhysicalAddress(command); break; case CEC_OPCODE_GET_MENU_LANGUAGE: - if (m_processor->CECInitialised()) - HandleGiveMenuLanguage(command); + iHandled = HandleGiveMenuLanguage(command); break; case CEC_OPCODE_GIVE_OSD_NAME: - if (m_processor->CECInitialised()) - HandleGiveOSDName(command); + iHandled = HandleGiveOSDName(command); break; case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID: - if (m_processor->CECInitialised()) - HandleGiveDeviceVendorId(command); + iHandled = HandleGiveDeviceVendorId(command); break; case CEC_OPCODE_DEVICE_VENDOR_ID: - HandleDeviceVendorId(command); + iHandled = HandleDeviceVendorId(command); break; case CEC_OPCODE_VENDOR_COMMAND_WITH_ID: - HandleDeviceVendorCommandWithId(command); + iHandled = HandleDeviceVendorCommandWithId(command); break; case CEC_OPCODE_GIVE_DECK_STATUS: - if (m_processor->CECInitialised()) - HandleGiveDeckStatus(command); + iHandled = HandleGiveDeckStatus(command); break; case CEC_OPCODE_DECK_CONTROL: - HandleDeckControl(command); + iHandled = HandleDeckControl(command); break; case CEC_OPCODE_MENU_REQUEST: - if (m_processor->CECInitialised()) - HandleMenuRequest(command); + iHandled = HandleMenuRequest(command); break; case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: - if (m_processor->CECInitialised()) - HandleGiveDevicePowerStatus(command); + iHandled = HandleGiveDevicePowerStatus(command); break; case CEC_OPCODE_GET_CEC_VERSION: - if (m_processor->CECInitialised()) - HandleGetCecVersion(command); + iHandled = HandleGetCecVersion(command); break; case CEC_OPCODE_USER_CONTROL_PRESSED: - if (m_processor->CECInitialised()) - HandleUserControlPressed(command); + iHandled = HandleUserControlPressed(command); break; case CEC_OPCODE_USER_CONTROL_RELEASE: - if (m_processor->CECInitialised()) - HandleUserControlRelease(command); + iHandled = HandleUserControlRelease(command); break; case CEC_OPCODE_GIVE_AUDIO_STATUS: - if (m_processor->CECInitialised()) - HandleGiveAudioStatus(command); + iHandled = HandleGiveAudioStatus(command); break; case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS: - if (m_processor->CECInitialised()) - HandleGiveSystemAudioModeStatus(command); + iHandled = HandleGiveSystemAudioModeStatus(command); break; case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST: - if (m_processor->CECInitialised()) - HandleSystemAudioModeRequest(command); + iHandled = HandleSystemAudioModeRequest(command); break; case CEC_OPCODE_REPORT_AUDIO_STATUS: - HandleReportAudioStatus(command); + iHandled = HandleReportAudioStatus(command); break; case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS: - HandleSystemAudioModeStatus(command); + iHandled = HandleSystemAudioModeStatus(command); break; case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE: - HandleSetSystemAudioMode(command); + iHandled = HandleSetSystemAudioMode(command); break; case CEC_OPCODE_REQUEST_ACTIVE_SOURCE: - if (m_processor->CECInitialised()) - HandleRequestActiveSource(command); + iHandled = HandleRequestActiveSource(command); break; case CEC_OPCODE_SET_STREAM_PATH: - HandleSetStreamPath(command); + iHandled = HandleSetStreamPath(command); break; case CEC_OPCODE_ROUTING_CHANGE: - HandleRoutingChange(command); + iHandled = HandleRoutingChange(command); break; case CEC_OPCODE_ROUTING_INFORMATION: - HandleRoutingInformation(command); + iHandled = HandleRoutingInformation(command); break; case CEC_OPCODE_STANDBY: - if (m_processor->CECInitialised()) - HandleStandby(command); + iHandled = HandleStandby(command); break; case CEC_OPCODE_ACTIVE_SOURCE: - HandleActiveSource(command); + iHandled = HandleActiveSource(command); break; case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS: - HandleReportPhysicalAddress(command); + iHandled = HandleReportPhysicalAddress(command); break; case CEC_OPCODE_SET_OSD_NAME: - HandleSetOSDName(command); + iHandled = HandleSetOSDName(command); break; case CEC_OPCODE_IMAGE_VIEW_ON: - HandleImageViewOn(command); + iHandled = HandleImageViewOn(command); break; case CEC_OPCODE_TEXT_VIEW_ON: - HandleTextViewOn(command); + iHandled = HandleTextViewOn(command); break; case CEC_OPCODE_FEATURE_ABORT: - HandleFeatureAbort(command); + iHandled = HandleFeatureAbort(command); break; case CEC_OPCODE_VENDOR_COMMAND: - HandleVendorCommand(command); + iHandled = HandleVendorCommand(command); + break; + case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN: + iHandled = HandleVendorRemoteButtonDown(command); + break; + case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP: + iHandled = HandleVendorRemoteButtonUp(command); break; case CEC_OPCODE_PLAY: // libCEC (currently) doesn't need to do anything with this, since player applications handle it // but it should not respond with a feature abort + iHandled = COMMAND_HANDLED; break; default: - bHandled = false; break; } - if (bHandled) + if (iHandled == COMMAND_HANDLED) m_waitForResponse->Received((command.opcode == CEC_OPCODE_FEATURE_ABORT && command.parameters.size > 0) ? (cec_opcode)command.parameters[0] : command.opcode); else - UnhandledCommand(command); + UnhandledCommand(command, (cec_abort_reason)iHandled); - return bHandled; + return iHandled == COMMAND_HANDLED; } -bool CCECCommandHandler::HandleActiveSource(const cec_command &command) +int CCECCommandHandler::HandleActiveSource(const cec_command &command) { if (command.parameters.size == 2) { uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iAddress); if (device) + { device->MarkAsActiveSource(); + return COMMAND_HANDLED; + } } - return true; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleDeckControl(const cec_command &command) +int CCECCommandHandler::HandleDeckControl(const cec_command &command) { CCECPlaybackDevice *device = CCECBusDevice::AsPlaybackDevice(GetDevice(command.destination)); if (device && command.parameters.size > 0) { device->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]); - return true; + return COMMAND_HANDLED; } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command) +int CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command) { if (command.parameters.size == 1) { CCECBusDevice *device = GetDevice(command.initiator); if (device) device->SetCecVersion((cec_version) command.parameters[0]); + + return COMMAND_HANDLED; } - return true; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command) +int CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command) { - if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) - m_processor->TransmitAbort(command.destination, command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED); - - return true; + return CEC_ABORT_REASON_REFUSED; } -bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command) +int CCECCommandHandler::HandleDeviceVendorId(const cec_command &command) { - return SetVendorId(command); + SetVendorId(command); + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleFeatureAbort(const cec_command &command) +int CCECCommandHandler::HandleFeatureAbort(const cec_command &command) { if (command.parameters.size == 2 && (command.parameters[1] == CEC_ABORT_REASON_UNRECOGNIZED_OPCODE || command.parameters[1] == CEC_ABORT_REASON_REFUSED)) m_processor->GetDevice(command.initiator)->SetUnsupportedFeature((cec_opcode)command.parameters[0]); - return true; + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command) +int CCECCommandHandler::HandleGetCecVersion(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->TransmitCECVersion(command.initiator); + if (device && device->TransmitCECVersion(command.initiator)) + return COMMAND_HANDLED; + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command) +int CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.destination)); - if (device) - return device->TransmitAudioStatus(command.initiator); + if (device && device->TransmitAudioStatus(command.initiator)) + return COMMAND_HANDLED; + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command) +int CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECPlaybackDevice *device = CCECBusDevice::AsPlaybackDevice(GetDevice(command.destination)); - if (device) - return device->TransmitDeckStatus(command.initiator); + if (device && device->TransmitDeckStatus(command.initiator)) + return COMMAND_HANDLED; + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) +int CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->TransmitPowerState(command.initiator); + if (device && device->TransmitPowerState(command.initiator)) + return COMMAND_HANDLED; + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command) +int CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->TransmitVendorID(command.initiator); + if (device && device->TransmitVendorID(command.initiator)) + return COMMAND_HANDLED; } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command) +int CCECCommandHandler::HandleGiveOSDName(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->TransmitOSDName(command.initiator); + if (device && device->TransmitOSDName(command.initiator)) + return COMMAND_HANDLED; } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) +int CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->TransmitPhysicalAddress(); + if (device && device->TransmitPhysicalAddress()) + return COMMAND_HANDLED; + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CCECCommandHandler::HandleGiveMenuLanguage(const cec_command &command) +int CCECCommandHandler::HandleGiveMenuLanguage(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->TransmitSetMenuLanguage(command.initiator); + if (device && device->TransmitSetMenuLanguage(command.initiator)) + return COMMAND_HANDLED; + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command) +int CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.destination)); - if (device) - return device->TransmitSystemAudioModeStatus(command.initiator); + if (device && device->TransmitSystemAudioModeStatus(command.initiator)) + return COMMAND_HANDLED; + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CCECCommandHandler::HandleImageViewOn(const cec_command &command) +int CCECCommandHandler::HandleImageViewOn(const cec_command &command) { m_processor->GetDevice(command.initiator)->MarkAsActiveSource(); - return true; + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) +int CCECCommandHandler::HandleMenuRequest(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { @@ -407,11 +408,13 @@ bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) device->SetMenuState(CEC_MENU_STATE_DEACTIVATED); } } - return device->TransmitMenuState(command.initiator); + if (device->TransmitMenuState(command.initiator)) + return COMMAND_HANDLED; } + return CEC_ABORT_REASON_INVALID_OPERAND; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } bool CCECCommandHandler::HandlePoll(const cec_command &command) @@ -420,7 +423,7 @@ bool CCECCommandHandler::HandlePoll(const cec_command &command) return true; } -bool CCECCommandHandler::HandleReportAudioStatus(const cec_command &command) +int CCECCommandHandler::HandleReportAudioStatus(const cec_command &command) { if (command.parameters.size == 1) { @@ -428,34 +431,38 @@ bool CCECCommandHandler::HandleReportAudioStatus(const cec_command &command) if (device) { device->SetAudioStatus(command.parameters[0]); - return true; + return COMMAND_HANDLED; } } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleReportPhysicalAddress(const cec_command &command) +int CCECCommandHandler::HandleReportPhysicalAddress(const cec_command &command) { if (command.parameters.size == 3) { uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); SetPhysicalAddress(command.initiator, iNewAddress); + return COMMAND_HANDLED; } - return true; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleReportPowerStatus(const cec_command &command) +int CCECCommandHandler::HandleReportPowerStatus(const cec_command &command) { if (command.parameters.size == 1) { CCECBusDevice *device = GetDevice(command.initiator); if (device) + { device->SetPowerStatus((cec_power_status) command.parameters[0]); + return COMMAND_HANDLED; + } } - return true; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) +int CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) { if (m_processor->CECInitialised()) { @@ -465,13 +472,12 @@ bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) vector devices; for (size_t iDevicePtr = 0; iDevicePtr < GetMyDevices(devices); iDevicePtr++) devices[iDevicePtr]->TransmitActiveSource(); - - return true; } - return false; + + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleRoutingChange(const cec_command &command) +int CCECCommandHandler::HandleRoutingChange(const cec_command &command) { if (command.parameters.size == 4) { @@ -480,25 +486,32 @@ bool CCECCommandHandler::HandleRoutingChange(const cec_command &command) CCECBusDevice *device = GetDevice(command.initiator); if (device) + { device->SetStreamPath(iNewAddress, iOldAddress); + return COMMAND_HANDLED; + } } - return true; + + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleRoutingInformation(const cec_command &command) +int CCECCommandHandler::HandleRoutingInformation(const cec_command &command) { if (command.parameters.size == 2) { uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress); if (device) + { device->MarkAsActiveSource(); + return COMMAND_HANDLED; + } } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command) +int CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command) { if (command.parameters.size == 3) { @@ -511,13 +524,14 @@ bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command) language.language[iPtr] = command.parameters[iPtr]; language.language[3] = 0; device->SetMenuLanguage(language); - return true; + return COMMAND_HANDLED; } } - return false; + + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleSetOSDName(const cec_command &command) +int CCECCommandHandler::HandleSetOSDName(const cec_command &command) { if (command.parameters.size > 0) { @@ -532,15 +546,19 @@ bool CCECCommandHandler::HandleSetOSDName(const cec_command &command) CStdString strName(buf); device->SetOSDName(strName); - return true; + return COMMAND_HANDLED; } } - return false; + + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) +int CCECCommandHandler::HandleSetStreamPath(const cec_command &command) { - if (m_processor->CECInitialised() && command.parameters.size >= 2) + if (!m_processor->CECInitialised()) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; + + if (command.parameters.size >= 2) { uint16_t iStreamAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); LIB_CEC->AddLog(CEC_LOG_DEBUG, ">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress); @@ -548,12 +566,16 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) /* one of the device handled by libCEC has been made active */ CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress); if (device && device->IsHandledByLibCEC()) + { device->ActivateSource(); + return COMMAND_HANDLED; + } } - return false; + + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command) +int CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command) { if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { @@ -568,28 +590,31 @@ bool CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command CCECBusDevice *newActiveDevice = GetDeviceByPhysicalAddress(iNewAddress); if (newActiveDevice) newActiveDevice->MarkAsActiveSource(); - return device->TransmitSetSystemAudioMode(command.initiator); + if (device->TransmitSetSystemAudioMode(command.initiator)) + return COMMAND_HANDLED; } else { device->SetSystemAudioModeStatus(CEC_SYSTEM_AUDIO_STATUS_OFF); - return device->TransmitSetSystemAudioMode(command.initiator); + if (device->TransmitSetSystemAudioMode(command.initiator)) + return COMMAND_HANDLED; } } } - return false; + + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CCECCommandHandler::HandleStandby(const cec_command &command) +int CCECCommandHandler::HandleStandby(const cec_command &command) { CCECBusDevice *device = GetDevice(command.initiator); if (device) device->SetPowerStatus(CEC_POWER_STATUS_STANDBY); - return true; + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleSystemAudioModeStatus(const cec_command &command) +int CCECCommandHandler::HandleSystemAudioModeStatus(const cec_command &command) { if (command.parameters.size == 1) { @@ -597,14 +622,14 @@ bool CCECCommandHandler::HandleSystemAudioModeStatus(const cec_command &command) if (device) { device->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]); - return true; + return COMMAND_HANDLED; } } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleSetSystemAudioMode(const cec_command &command) +int CCECCommandHandler::HandleSetSystemAudioMode(const cec_command &command) { if (command.parameters.size == 1) { @@ -612,89 +637,92 @@ bool CCECCommandHandler::HandleSetSystemAudioMode(const cec_command &command) if (device) { device->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]); - return true; + return COMMAND_HANDLED; } } - return false; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CCECCommandHandler::HandleTextViewOn(const cec_command &command) +int CCECCommandHandler::HandleTextViewOn(const cec_command &command) { m_processor->GetDevice(command.initiator)->MarkAsActiveSource(); - return true; + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) +int CCECCommandHandler::HandleUserControlPressed(const cec_command &command) { - if (m_processor->CECInitialised() && - m_processor->IsHandledByLibCEC(command.destination) && - command.parameters.size > 0) - { - CCECBusDevice *device = GetDevice(command.destination); - if (!device) - return true; + if (!m_processor->CECInitialised() || + !m_processor->IsHandledByLibCEC(command.destination)) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; - CCECClient *client = device->GetClient(); - if (client) - client->AddKey(); + if (command.parameters.size == 0) + return CEC_ABORT_REASON_INVALID_OPERAND; - if (command.parameters[0] <= CEC_USER_CONTROL_CODE_MAX) - client->SetCurrentButton((cec_user_control_code) command.parameters[0]); + CCECBusDevice *device = GetDevice(command.destination); + if (!device) + return CEC_ABORT_REASON_INVALID_OPERAND; - if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER || - command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION) - { - bool bPowerOn(true); - if (!device) - return true; + CCECClient *client = device->GetClient(); + if (client) + client->AddKey(); - // CEC_USER_CONTROL_CODE_POWER operates as a toggle - // assume CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION does not - if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER) - { - cec_power_status status = device->GetCurrentPowerStatus(); - bPowerOn = !(status == CEC_POWER_STATUS_ON || status == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); - } + if (command.parameters[0] <= CEC_USER_CONTROL_CODE_MAX) + client->SetCurrentButton((cec_user_control_code) command.parameters[0]); - if (bPowerOn) - { - device->ActivateSource(); - } - else - { - device->MarkAsInactiveSource(); - device->TransmitInactiveSource(); - device->SetMenuState(CEC_MENU_STATE_DEACTIVATED); - } + if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER || + command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION) + { + bool bPowerOn(true); + + // CEC_USER_CONTROL_CODE_POWER operates as a toggle + // assume CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION does not + if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER) + { + cec_power_status status = device->GetCurrentPowerStatus(); + bPowerOn = !(status == CEC_POWER_STATUS_ON || status == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); } - return true; + if (bPowerOn) + { + device->ActivateSource(); + } + else + { + device->MarkAsInactiveSource(); + device->TransmitInactiveSource(); + device->SetMenuState(CEC_MENU_STATE_DEACTIVATED); + } } - return false; + + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command) +int CCECCommandHandler::HandleUserControlRelease(const cec_command &command) { + if (!m_processor->CECInitialised() || + !m_processor->IsHandledByLibCEC(command.destination)) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; + CCECClient *client = m_processor->GetClient(command.destination); if (client) client->AddKey(); - return true; + + return COMMAND_HANDLED; } -bool CCECCommandHandler::HandleVendorCommand(const cec_command &command) +int CCECCommandHandler::HandleVendorCommand(const cec_command &command) { - if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) - m_processor->TransmitAbort(command.destination, command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED); - return true; + return CEC_ABORT_REASON_REFUSED; } -void CCECCommandHandler::UnhandledCommand(const cec_command &command) +void CCECCommandHandler::UnhandledCommand(const cec_command &command, const cec_abort_reason reason) { - LIB_CEC->AddLog(CEC_LOG_DEBUG, "unhandled command with opcode %02x from address %d", command.opcode, command.initiator); - - if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) - m_processor->TransmitAbort(m_busDevice->GetLogicalAddress(), command.initiator, command.opcode, CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); + if (m_processor->IsHandledByLibCEC(command.destination)) + { + LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending abort with opcode %02x and reason '%s' to %s", command.opcode, ToString(reason), ToString(command.initiator)); + m_processor->TransmitAbort(command.destination, command.initiator, command.opcode, reason); + } } size_t CCECCommandHandler::GetMyDevices(vector &devices) const diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index 1ede442..8b8bc27 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -39,6 +39,8 @@ namespace CEC { + #define COMMAND_HANDLED 0xFF + class CCECProcessor; class CCECBusDevice; @@ -167,42 +169,44 @@ namespace CEC virtual cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type; } protected: - virtual bool HandleActiveSource(const cec_command &command); - virtual bool HandleDeckControl(const cec_command &command); - virtual bool HandleDeviceCecVersion(const cec_command &command); - virtual bool HandleDeviceVendorCommandWithId(const cec_command &command); - virtual bool HandleDeviceVendorId(const cec_command &command); - virtual bool HandleFeatureAbort(const cec_command &command); - virtual bool HandleGetCecVersion(const cec_command &command); - virtual bool HandleGiveAudioStatus(const cec_command &command); - virtual bool HandleGiveDeckStatus(const cec_command &command); - virtual bool HandleGiveDevicePowerStatus(const cec_command &command); - 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); + virtual int HandleActiveSource(const cec_command &command); + virtual int HandleDeckControl(const cec_command &command); + virtual int HandleDeviceCecVersion(const cec_command &command); + virtual int HandleDeviceVendorCommandWithId(const cec_command &command); + virtual int HandleDeviceVendorId(const cec_command &command); + virtual int HandleFeatureAbort(const cec_command &command); + virtual int HandleGetCecVersion(const cec_command &command); + virtual int HandleGiveAudioStatus(const cec_command &command); + virtual int HandleGiveDeckStatus(const cec_command &command); + virtual int HandleGiveDevicePowerStatus(const cec_command &command); + virtual int HandleGiveDeviceVendorId(const cec_command &command); + virtual int HandleGiveOSDName(const cec_command &command); + virtual int HandleGivePhysicalAddress(const cec_command &command); + virtual int HandleGiveMenuLanguage(const cec_command &command); + virtual int HandleGiveSystemAudioModeStatus(const cec_command &command); + virtual int HandleImageViewOn(const cec_command &command); + virtual int HandleMenuRequest(const cec_command &command); virtual bool HandlePoll(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 HandleSystemAudioModeRequest(const cec_command &command); - virtual bool HandleStandby(const cec_command &command); - virtual bool HandleSystemAudioModeStatus(const cec_command &command); - virtual bool HandleSetSystemAudioMode(const cec_command &command); - virtual bool HandleTextViewOn(const cec_command &command); - virtual bool HandleUserControlPressed(const cec_command &command); - virtual bool HandleUserControlRelease(const cec_command &command); - virtual bool HandleVendorCommand(const cec_command &command); - virtual void UnhandledCommand(const cec_command &command); + virtual int HandleReportAudioStatus(const cec_command &command); + virtual int HandleReportPhysicalAddress(const cec_command &command); + virtual int HandleReportPowerStatus(const cec_command &command); + virtual int HandleRequestActiveSource(const cec_command &command); + virtual int HandleRoutingChange(const cec_command &command); + virtual int HandleRoutingInformation(const cec_command &command); + virtual int HandleSetMenuLanguage(const cec_command &command); + virtual int HandleSetOSDName(const cec_command &command); + virtual int HandleSetStreamPath(const cec_command &command); + virtual int HandleSystemAudioModeRequest(const cec_command &command); + virtual int HandleStandby(const cec_command &command); + virtual int HandleSystemAudioModeStatus(const cec_command &command); + virtual int HandleSetSystemAudioMode(const cec_command &command); + virtual int HandleTextViewOn(const cec_command &command); + virtual int HandleUserControlPressed(const cec_command &command); + virtual int HandleUserControlRelease(const cec_command &command); + virtual int HandleVendorCommand(const cec_command &command); + virtual int HandleVendorRemoteButtonDown(const cec_command &command) { return CEC_ABORT_REASON_REFUSED; } + virtual int HandleVendorRemoteButtonUp(const cec_command &command) { return CEC_ABORT_REASON_REFUSED; } + virtual void UnhandledCommand(const cec_command &command, const cec_abort_reason reason); virtual size_t GetMyDevices(std::vector &devices) const; virtual CCECBusDevice *GetDevice(cec_logical_address iLogicalAddress) const; diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index 6066d3b..8ddac56 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -103,7 +103,7 @@ bool CSLCommandHandler::InitHandler(void) return true; } -bool CSLCommandHandler::HandleActiveSource(const cec_command &command) +int CSLCommandHandler::HandleActiveSource(const cec_command &command) { if (command.parameters.size == 2) { @@ -122,13 +122,15 @@ bool CSLCommandHandler::HandleActiveSource(const cec_command &command) } primary->TransmitPowerState(CECDEVICE_TV); } + + return COMMAND_HANDLED; } - return true; + return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CSLCommandHandler::HandleDeviceVendorId(const cec_command &command) +int CSLCommandHandler::HandleDeviceVendorId(const cec_command &command) { SetVendorId(command); @@ -143,13 +145,15 @@ bool CSLCommandHandler::HandleDeviceVendorId(const cec_command &command) cec_command response; cec_command::Format(response, initiator, command.initiator, CEC_OPCODE_FEATURE_ABORT); - return Transmit(response); + Transmit(response); + return COMMAND_HANDLED; } } - return true; + + return CCECCommandHandler::HandleDeviceVendorId(command); } -bool CSLCommandHandler::HandleVendorCommand(const cec_command &command) +int CSLCommandHandler::HandleVendorCommand(const cec_command &command) { if (!m_processor->IsHandledByLibCEC(command.destination)) return true; @@ -158,28 +162,28 @@ bool CSLCommandHandler::HandleVendorCommand(const cec_command &command) command.parameters[0] == SL_COMMAND_UNKNOWN_01) { HandleVendorCommand01(command); - return true; + return COMMAND_HANDLED; } else if (command.parameters.size == 2 && command.parameters[0] == SL_COMMAND_POWER_ON) { HandleVendorCommandPowerOn(command); - return true; + return COMMAND_HANDLED; } else if (command.parameters.size == 2 && command.parameters[0] == SL_COMMAND_CONNECT_REQUEST) { HandleVendorCommandSLConnect(command); - return true; + return COMMAND_HANDLED; } else if (command.parameters.size == 1 && command.parameters[0] == SL_COMMAND_REQUEST_POWER_STATUS) { HandleVendorCommandPowerOnStatus(command); - return true; + return COMMAND_HANDLED; } - return false; + return CCECCommandHandler::HandleVendorCommand(command); } void CSLCommandHandler::HandleVendorCommand01(const cec_command &command) @@ -252,44 +256,41 @@ void CSLCommandHandler::TransmitVendorCommandSetDeviceMode(const cec_logical_add Transmit(response); } -bool CSLCommandHandler::HandleGiveDeckStatus(const cec_command &command) +int CSLCommandHandler::HandleGiveDeckStatus(const cec_command &command) { - if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) + if (!m_processor->CECInitialised() || + !m_processor->IsHandledByLibCEC(command.destination)) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; + + CCECPlaybackDevice *device = CCECBusDevice::AsPlaybackDevice(GetDevice(command.destination)); + if (!device || command.parameters.size == 0) + return CEC_ABORT_REASON_INVALID_OPERAND; + + device->SetDeckStatus(!device->IsActiveSource() ? CEC_DECK_INFO_OTHER_STATUS : CEC_DECK_INFO_OTHER_STATUS_LG); + if (command.parameters[0] == CEC_STATUS_REQUEST_ON) { - CCECBusDevice *device = GetDevice(command.destination); - if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)) - { - if (command.parameters.size > 0) - { - ((CCECPlaybackDevice *) device)->SetDeckStatus(!device->IsActiveSource() ? CEC_DECK_INFO_OTHER_STATUS : CEC_DECK_INFO_OTHER_STATUS_LG); - if (command.parameters[0] == CEC_STATUS_REQUEST_ON) - { - bool bReturn = ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator); - if (!ActiveSourceSent()) - ActivateSource(); - return bReturn; - } - else if (command.parameters[0] == CEC_STATUS_REQUEST_ONCE) - { - return ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator); - } - } - } - return CCECCommandHandler::HandleGiveDeckStatus(command); + device->TransmitDeckStatus(command.initiator); + if (!ActiveSourceSent()) + ActivateSource(); + return COMMAND_HANDLED; + } + else if (command.parameters[0] == CEC_STATUS_REQUEST_ONCE) + { + device->TransmitDeckStatus(command.initiator); + return COMMAND_HANDLED; } - return false; + return CCECCommandHandler::HandleGiveDeckStatus(command); } -bool CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) +int CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) { - bool bReturn(false); if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination) && command.initiator == CECDEVICE_TV) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetCurrentPowerStatus() != CEC_POWER_STATUS_ON) { - bReturn = device->TransmitPowerState(command.initiator); + device->TransmitPowerState(command.initiator); device->SetPowerStatus(CEC_POWER_STATUS_ON); } else @@ -297,7 +298,7 @@ bool CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) if (!ActiveSourceSent()) { device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); - bReturn = device->TransmitPowerState(command.initiator); + device->TransmitPowerState(command.initiator); ActivateSource(); } else if (m_resetPowerState.IsSet() && m_resetPowerState.TimeLeft() > 0) @@ -309,22 +310,24 @@ bool CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) m_bActiveSourceSent = false; } device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); - bReturn = device->TransmitPowerState(command.initiator); + device->TransmitPowerState(command.initiator); device->SetPowerStatus(CEC_POWER_STATUS_ON); m_resetPowerState.Init(5000); } else { - bReturn = device->TransmitPowerState(command.initiator); + device->TransmitPowerState(command.initiator); m_resetPowerState.Init(5000); } } + + return COMMAND_HANDLED; } - return bReturn; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CSLCommandHandler::HandleRequestActiveSource(const cec_command &command) +int CSLCommandHandler::HandleRequestActiveSource(const cec_command &command) { if (m_processor->CECInitialised()) { @@ -332,12 +335,12 @@ bool CSLCommandHandler::HandleRequestActiveSource(const cec_command &command) LIB_CEC->AddLog(CEC_LOG_DEBUG, ">> %i requests active source, ignored", (uint8_t) command.initiator); else ActivateSource(); - return true; + return COMMAND_HANDLED; } - return false; + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; } -bool CSLCommandHandler::HandleFeatureAbort(const cec_command &command) +int CSLCommandHandler::HandleFeatureAbort(const cec_command &command) { if (command.parameters.size == 0 && m_processor->GetPrimaryDevice()->GetCurrentPowerStatus() == CEC_POWER_STATUS_ON && !SLInitialised() && command.initiator == CECDEVICE_TV) @@ -349,7 +352,7 @@ bool CSLCommandHandler::HandleFeatureAbort(const cec_command &command) return CCECCommandHandler::HandleFeatureAbort(command); } -bool CSLCommandHandler::HandleStandby(const cec_command &command) +int CSLCommandHandler::HandleStandby(const cec_command &command) { if (command.initiator == CECDEVICE_TV) { diff --git a/src/lib/implementations/SLCommandHandler.h b/src/lib/implementations/SLCommandHandler.h index 0eb6c86..a59a2f2 100644 --- a/src/lib/implementations/SLCommandHandler.h +++ b/src/lib/implementations/SLCommandHandler.h @@ -45,9 +45,9 @@ namespace CEC bool InitHandler(void); protected: - bool HandleActiveSource(const cec_command &command); - bool HandleDeviceVendorId(const cec_command &command); - bool HandleVendorCommand(const cec_command &command); + int HandleActiveSource(const cec_command &command); + int HandleDeviceVendorId(const cec_command &command); + int HandleVendorCommand(const cec_command &command); void HandleVendorCommand01(const cec_command &command); void TransmitVendorCommand0205(const cec_logical_address iSource, const cec_logical_address iDestination); @@ -58,11 +58,11 @@ namespace CEC void HandleVendorCommandSLConnect(const cec_command &command); void TransmitVendorCommandSetDeviceMode(const cec_logical_address iSource, const cec_logical_address iDestination, const cec_device_type type); - bool HandleGiveDevicePowerStatus(const cec_command &command); - bool HandleGiveDeckStatus(const cec_command &command); - bool HandleRequestActiveSource(const cec_command &command); - bool HandleFeatureAbort(const cec_command &command); - bool HandleStandby(const cec_command &command); + int HandleGiveDevicePowerStatus(const cec_command &command); + int HandleGiveDeckStatus(const cec_command &command); + int HandleRequestActiveSource(const cec_command &command); + int HandleFeatureAbort(const cec_command &command); + int HandleStandby(const cec_command &command); bool TransmitMenuState(const cec_logical_address UNUSED(iInitiator), const cec_logical_address UNUSED(iDestination), cec_menu_state UNUSED(menuState)) { return true; } bool PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination); diff --git a/src/lib/implementations/VLCommandHandler.cpp b/src/lib/implementations/VLCommandHandler.cpp index 664de21..65f6c15 100644 --- a/src/lib/implementations/VLCommandHandler.cpp +++ b/src/lib/implementations/VLCommandHandler.cpp @@ -76,7 +76,7 @@ bool CVLCommandHandler::InitHandler(void) return CCECCommandHandler::InitHandler(); } -bool CVLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command) +int CVLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command) { if (command.initiator == CECDEVICE_TV && command.destination == CECDEVICE_BROADCAST && @@ -96,7 +96,7 @@ bool CVLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &comma else if (command.parameters.At(4) == VL_POWERED_DOWN) LIB_CEC->AddLog(CEC_LOG_DEBUG, "unknown vendor command"); - return true; + return COMMAND_HANDLED; } return CCECCommandHandler::HandleDeviceVendorCommandWithId(command); diff --git a/src/lib/implementations/VLCommandHandler.h b/src/lib/implementations/VLCommandHandler.h index f2bfc7e..8939057 100644 --- a/src/lib/implementations/VLCommandHandler.h +++ b/src/lib/implementations/VLCommandHandler.h @@ -43,7 +43,7 @@ namespace CEC bool InitHandler(void); - bool HandleDeviceVendorCommandWithId(const cec_command &command); + int HandleDeviceVendorCommandWithId(const cec_command &command); bool TransmitActiveSource(const cec_logical_address iInitiator, uint16_t iPhysicalAddress); bool TransmitPendingActiveSourceCommands(void); -- 2.34.1