bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
- m_processor->TransmitAbort(m_busDevice->GetLogicalAddress(), command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED);
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
+ m_processor->TransmitAbort(command.destination, command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED);
return true;
}
bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device)
bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device)
bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device)
bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device)
bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device)
bool CCECCommandHandler::HandleGiveMenuLanguage(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device)
bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device)
bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command)
{
- if (m_processor->IsRunning())
+ if (m_processor->CECInitialised())
{
LIB_CEC->AddLog(CEC_LOG_DEBUG, ">> %i requests active source", (uint8_t) command.initiator);
m_processor->GetDevice(command.initiator)->SetPowerStatus(CEC_POWER_STATUS_ON);
bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
{
- if (m_processor->IsRunning() && command.parameters.size >= 2)
+ if (m_processor->CECInitialised() && 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);
bool CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command)
{
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command)
{
- if (m_processor->IsRunning() &&
+ if (m_processor->CECInitialised() &&
m_processor->IsHandledByLibCEC(command.destination) &&
command.parameters.size > 0)
{
{
LIB_CEC->AddLog(CEC_LOG_DEBUG, "unhandled command with opcode %02x from address %d", command.opcode, command.initiator);
- if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination))
+ 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(iAddress))
{
- CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress);
- bool bOurAddress(device && device->GetLogicalAddress() != m_busDevice->GetLogicalAddress() &&
- device->IsHandledByLibCEC());
-
- GetDevice(iAddress)->SetPhysicalAddress(iNewAddress);
+ CCECBusDevice *otherDevice = m_processor->GetDeviceByPhysicalAddress(iNewAddress);
+ CCECClient *client = otherDevice ? otherDevice->GetClient() : NULL;
- if (bOurAddress)
+ CCECBusDevice *device = m_processor->GetDevice(iAddress);
+ if (device)
+ device->SetPhysicalAddress(iNewAddress);
+ else
{
- /* another device reported the same physical address as ours
- * since we don't have physical address detection yet, we'll just use the
- * given address, increased by 0x100 for now */
- CCECClient *client = device->GetClient();
- if (client)
- client->SetPhysicalAddress(iNewAddress + 0x100);
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "device with logical address %X not found", iAddress);
}
+
+ /* another device reported the same physical address as ours */
+ if (client)
+ client->ResetPhysicalAddress();
+ }
+ else
+ {
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "ignore physical address report for device %s (%X) because it's marked as handled by libCEC", ToString(iAddress), iAddress);
}
}