return false;
}
-bool CCECAudioSystem::SetSystemAudioMode(const cec_system_audio_status mode)
+bool CCECAudioSystem::SetSystemAudioModeStatus(const cec_system_audio_status mode)
{
CLockObject lock(&m_writeMutex);
if (m_systemAudioStatus != mode)
{
CStdString strLog;
- strLog.Format(">> %s (%X): system audio mode changed from %s to %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_systemAudioStatus), ToString(mode));
+ strLog.Format(">> %s (%X): system audio mode status changed from %s to %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_systemAudioStatus), ToString(mode));
AddLog(CEC_LOG_DEBUG, strLog.c_str());
m_systemAudioStatus = mode;
return false;
}
-bool CCECAudioSystem::SetSystemAudioMode(const cec_command &command)
-{
- SetSystemAudioMode((command.parameters.size == 0) ?
- CEC_SYSTEM_AUDIO_STATUS_OFF :
- CEC_SYSTEM_AUDIO_STATUS_ON);
-
- if (MyLogicalAddressContains(m_iLogicalAddress))
- return TransmitAudioStatus(command.initiator);
- return true;
-}
-
bool CCECAudioSystem::TransmitAudioStatus(cec_logical_address dest)
{
CLockObject lock(&m_writeMutex);
return m_processor->Transmit(command);
}
+bool CCECAudioSystem::TransmitSetSystemAudioMode(cec_logical_address dest)
+{
+ CLockObject lock(&m_writeMutex);
+ CStdString strLog;
+ strLog.Format("<< %x -> %x: set system audio mode '%2x'", m_iLogicalAddress, dest, m_audioStatus);
+ AddLog(CEC_LOG_NOTICE, strLog);
+
+ cec_command command;
+ cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_SYSTEM_AUDIO_MODE);
+ command.parameters.PushBack(m_systemAudioStatus);
+
+ return m_processor->Transmit(command);
+}
+
bool CCECAudioSystem::TransmitSystemAudioModeStatus(cec_logical_address dest)
{
CLockObject lock(&m_writeMutex);
virtual ~CCECAudioSystem(void) {};
virtual bool SetAudioStatus(uint8_t status);
- virtual bool SetSystemAudioMode(const cec_system_audio_status mode);
- virtual bool SetSystemAudioMode(const cec_command &command);
+ virtual bool SetSystemAudioModeStatus(const cec_system_audio_status mode);
virtual bool TransmitAudioStatus(cec_logical_address dest);
+ virtual bool TransmitSetSystemAudioMode(cec_logical_address dest);
virtual bool TransmitSystemAudioModeStatus(cec_logical_address dest);
virtual uint8_t VolumeUp(bool bWait = true);
HandleGiveSystemAudioModeStatus(command);
break;
case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
- HandleSetSystemAudioModeRequest(command);
+ HandleSystemAudioModeRequest(command);
+ break;
+ case CEC_OPCODE_REPORT_AUDIO_STATUS:
+ HandleReportAudioStatus(command);//YYY
+ break;
+ case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS:
+ HandleSystemAudioModeStatus(command);//YYY
+ break;
+ case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE:
+ HandleSetSystemAudioMode(command);//YYY
break;
case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
HandleRequestActiveSource(command);
case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS:
HandleReportPhysicalAddress(command);
break;
- case CEC_OPCODE_REPORT_AUDIO_STATUS:
- HandleReportAudioStatus(command);
- break;
- case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS:
- HandleSystemAudioStatus(command);
- break;
case CEC_OPCODE_SET_OSD_NAME:
HandleSetOSDName(command);
break;
return false;
}
-bool CCECCommandHandler::HandleSetSystemAudioModeRequest(const cec_command &command)
+bool CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command)
{
- if (m_busDevice->MyLogicalAddressContains(command.destination) && command.parameters.size >= 1)
+ if (m_busDevice->MyLogicalAddressContains(command.destination))
{
CCECBusDevice *device = GetDevice(command.destination);
- if (device&& device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
- return ((CCECAudioSystem *) device)->SetSystemAudioMode(command);
+ if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ {
+ if (command.parameters.size >= 2)
+ {
+ device->SetPowerStatus(CEC_POWER_STATUS_ON);
+ ((CCECAudioSystem *) 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)
+ m_busDevice->GetProcessor()->SetActiveSource(newActiveDevice->GetLogicalAddress());
+ return ((CCECAudioSystem *) device)->TransmitSetSystemAudioMode(command.initiator);
+ }
+ else
+ {
+ ((CCECAudioSystem *) device)->SetSystemAudioModeStatus(CEC_SYSTEM_AUDIO_STATUS_OFF);
+ return ((CCECAudioSystem *) device)->TransmitSetSystemAudioMode(command.initiator);
+ }
+ }
}
return false;
}
return true;
}
-bool CCECCommandHandler::HandleSystemAudioStatus(const cec_command &command)
+bool CCECCommandHandler::HandleSystemAudioModeStatus(const cec_command &command)
{
- CCECBusDevice *device = GetDevice(command.initiator);
- if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ if (command.parameters.size == 1)
{
- ((CCECAudioSystem *)device)->SetSystemAudioMode(command);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ {
+ ((CCECAudioSystem *)device)->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool CCECCommandHandler::HandleSetSystemAudioMode(const cec_command &command)
+{
+ if (command.parameters.size == 1)
+ {
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ {
+ ((CCECAudioSystem *)device)->SetSystemAudioModeStatus((cec_system_audio_status)command.parameters[0]);
+ return true;
+ }
}
return false;
virtual bool HandleSetMenuLanguage(const cec_command &command);
virtual bool HandleSetOSDName(const cec_command &command);
virtual bool HandleSetStreamPath(const cec_command &command);
- virtual bool HandleSetSystemAudioModeRequest(const cec_command &command);
+ virtual bool HandleSystemAudioModeRequest(const cec_command &command);
virtual bool HandleStandby(const cec_command &command);
- virtual bool HandleSystemAudioStatus(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);