X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FCECCommandHandler.cpp;h=e30810c6671c7c564721c0906ed5db94630db0c1;hb=c0b1d868c775f3b2d8246b183a31fe34a1ad30f5;hp=625ed010c3b42b23500179f22524d76e27e44237;hpb=f8513317a5f4bb2d9d0843193c3c98eca19f8e8a;p=deb_libcec.git diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 625ed01..e30810c 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -32,6 +32,7 @@ #include "CECCommandHandler.h" #include "../devices/CECBusDevice.h" +#include "../devices/CECAudioSystem.h" #include "../CECProcessor.h" using namespace CEC; @@ -92,6 +93,15 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) case CEC_OPCODE_USER_CONTROL_RELEASE: HandleUserControlRelease(command); break; + case CEC_OPCODE_GIVE_AUDIO_STATUS: + HandleGiveAudioStatus(command); + break; + case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS: + HandleGiveSystemAudioModeStatus(command); + break; + case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST: + HandleSetSystemAudioModeRequest(command); + break; default: UnhandledCommand(command); m_busDevice->GetProcessor()->AddCommand(command); @@ -177,7 +187,16 @@ bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->ReportCECVersion(command.initiator); + return device->TransmitCECVersion(command.initiator); + + return false; +} + +bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command) +{ + CCECBusDevice *device = GetDevice(command.destination); + if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) + return ((CCECAudioSystem *) device)->TransmitAudioStatus(command.initiator); return false; } @@ -186,7 +205,7 @@ bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->ReportDeckStatus(command.initiator); + return device->TransmitDeckStatus(command.initiator); return false; } @@ -195,7 +214,7 @@ bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->ReportPowerState(command.initiator); + return device->TransmitPowerState(command.initiator); return false; } @@ -204,7 +223,7 @@ bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->ReportVendorID(command.initiator); + return device->TransmitVendorID(command.initiator); return false; } @@ -213,7 +232,7 @@ bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->ReportOSDName(command.initiator); + return device->TransmitOSDName(command.initiator); return false; } @@ -222,7 +241,7 @@ bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->BroadcastPhysicalAddress(); + return device->TransmitPhysicalAddress(); return false; } @@ -233,7 +252,7 @@ bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->ReportMenuState(command.initiator); + return device->TransmitMenuState(command.initiator); } return false; } @@ -256,7 +275,7 @@ bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str()); CCECBusDevice *device = m_busDevice->GetProcessor()->m_busDevices[m_busDevice->GetMyLogicalAddress()]; if (device) - return device->BroadcastActiveSource(); + return device->TransmitActiveSource(); return false; } @@ -300,17 +319,33 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) CStdString strLog; strLog.Format(">> %i requests stream path from physical address %04x", command.initiator, streamaddr); m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str()); - if (streamaddr == m_busDevice->GetMyPhysicalAddress()) - { - CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->BroadcastActiveSource(); - return false; - } + CCECBusDevice *device = GetDeviceByPhysicalAddress(streamaddr); + if (device) + return device->TransmitActiveSource(); + } + return true; +} + +bool CCECCommandHandler::HandleSetSystemAudioModeRequest(const cec_command &command) +{ + if (command.parameters.size >= 1) + { + CCECBusDevice *device = GetDevice(command.destination); + if (device&& device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) + return ((CCECAudioSystem *) device)->SetSystemAudioMode(command); } return true; } +bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command) +{ + CCECBusDevice *device = GetDevice(command.destination); + if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) + return ((CCECAudioSystem *) device)->TransmitSystemAudioModeStatus(command.initiator); + + return false; +} + bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) { if (command.parameters.size > 0) @@ -351,3 +386,19 @@ CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress return device; } + +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; +}