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)
+ CCECPlaybackDevice *device = CCECBusDevice::AsPlaybackDevice(GetDevice(command.destination));
+ if (device && command.parameters.size > 0)
{
- ((CCECPlaybackDevice *) device)->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]);
+ device->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]);
return true;
}
{
if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
- CCECBusDevice *device = GetDevice(command.destination);
- if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
- return ((CCECAudioSystem *) device)->TransmitAudioStatus(command.initiator);
+ CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.destination));
+ if (device)
+ return device->TransmitAudioStatus(command.initiator);
}
return false;
{
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))
- return ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator);
+ CCECPlaybackDevice *device = CCECBusDevice::AsPlaybackDevice(GetDevice(command.destination));
+ if (device)
+ return device->TransmitDeckStatus(command.initiator);
}
return false;
{
if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
- CCECBusDevice *device = GetDevice(command.destination);
- if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
- return ((CCECAudioSystem *) device)->TransmitSystemAudioModeStatus(command.initiator);
+ CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.destination));
+ if (device)
+ return device->TransmitSystemAudioModeStatus(command.initiator);
}
return false;
{
if (command.parameters.size == 1)
{
- CCECBusDevice *device = GetDevice(command.initiator);
- if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.initiator));
+ if (device)
{
- ((CCECAudioSystem *)device)->SetAudioStatus(command.parameters[0]);
+ device->SetAudioStatus(command.parameters[0]);
return true;
}
}
{
if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination))
{
- CCECBusDevice *device = GetDevice(command.destination);
- if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.destination));
+ if (device)
{
if (command.parameters.size >= 2)
{
device->SetPowerStatus(CEC_POWER_STATUS_ON);
- ((CCECAudioSystem *) device)->SetSystemAudioModeStatus(CEC_SYSTEM_AUDIO_STATUS_ON);
+ device->SetSystemAudioModeStatus(CEC_SYSTEM_AUDIO_STATUS_ON);
uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
CCECBusDevice *newActiveDevice = GetDeviceByPhysicalAddress(iNewAddress);
if (newActiveDevice)
newActiveDevice->MarkAsActiveSource();
- return ((CCECAudioSystem *) device)->TransmitSetSystemAudioMode(command.initiator);
+ return device->TransmitSetSystemAudioMode(command.initiator);
}
else
{
- ((CCECAudioSystem *) device)->SetSystemAudioModeStatus(CEC_SYSTEM_AUDIO_STATUS_OFF);
- return ((CCECAudioSystem *) device)->TransmitSetSystemAudioMode(command.initiator);
+ device->SetSystemAudioModeStatus(CEC_SYSTEM_AUDIO_STATUS_OFF);
+ return device->TransmitSetSystemAudioMode(command.initiator);
}
}
}
{
if (command.parameters.size == 1)
{
- CCECBusDevice *device = GetDevice(command.initiator);
- if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.initiator));
+ if (device)
{
- ((CCECAudioSystem *)device)->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]);
+ device->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]);
return true;
}
}
{
if (command.parameters.size == 1)
{
- CCECBusDevice *device = GetDevice(command.initiator);
- if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ CCECAudioSystem *device = CCECBusDevice::AsAudioSystem(GetDevice(command.initiator));
+ if (device)
{
- ((CCECAudioSystem *)device)->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]);
+ device->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]);
return true;
}
}
m_busDevice->TransmitImageViewOn();
m_busDevice->TransmitActiveSource();
m_busDevice->TransmitMenuState(CECDEVICE_TV);
- if ((m_busDevice->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
- m_busDevice->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) &&
- SendDeckStatusUpdateOnActiveSource())
- ((CCECPlaybackDevice *)m_busDevice)->TransmitDeckStatus(CECDEVICE_TV);
+
+ CCECPlaybackDevice *playbackDevice = m_busDevice->AsPlaybackDevice();
+ if (playbackDevice && SendDeckStatusUpdateOnActiveSource())
+ playbackDevice->TransmitDeckStatus(CECDEVICE_TV);
m_bHandlerInited = true;
}
return true;