CEC_AUDIO_RATE_SLOW_RATE_MIN_99_9 = 6
} ECecAudioRate;
-typedef enum
+typedef enum cec_audio_status
{
CEC_AUDIO_MUTE_STATUS_MASK = 0x80,
CEC_AUDIO_VOLUME_STATUS_MASK = 0x7F,
CEC_AUDIO_VOLUME_MIN = 0x00,
CEC_AUDIO_VOLUME_MAX = 0x64,
CEC_AUDIO_VOLUME_STATUS_UNKNOWN = 0x7F
-} ECecAudioStatus;
+} cec_audio_status;
typedef enum
{
CEC_STATUS_REQUEST_ONCE = 3
} ECecStatusRequest;
-typedef enum
+typedef enum cec_system_audio_status
{
CEC_SYSTEM_AUDIO_STATUS_OFF = 0,
CEC_SYSTEM_AUDIO_STATUS_ON = 1
-} ECecSystemAudioStatus;
+} cec_system_audio_status;
typedef enum
{
using namespace CEC;
CCECAudioSystem::CCECAudioSystem(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress /* = 0 */) :
- CCECBusDevice(processor, address, iPhysicalAddress)
+ CCECBusDevice(processor, address, iPhysicalAddress),
+ m_systemAudioStatus(CEC_SYSTEM_AUDIO_STATUS_ON),
+ m_audioStatus(CEC_AUDIO_MUTE_STATUS_MASK)
{
m_type = CEC_DEVICE_TYPE_AUDIO_SYSTEM;
m_strDeviceName = "Audio";
}
+bool CCECAudioSystem::SetSystemAudioMode(const cec_command &command)
+{
+ m_systemAudioStatus = (command.parameters.size == 0) ?
+ CEC_SYSTEM_AUDIO_STATUS_OFF :
+ CEC_SYSTEM_AUDIO_STATUS_ON;
+
+ return TransmitAudioStatus(command.initiator);
+}
+
bool CCECAudioSystem::TransmitAudioStatus(cec_logical_address dest)
{
- // TODO
CStdString strLog;
- strLog.Format("<< %x -> %x: audio status feature abort", m_iLogicalAddress, dest);
+ strLog.Format("<< %x -> %x: audio status '%2x'", m_iLogicalAddress, dest, m_audioStatus);
AddLog(CEC_LOG_NOTICE, strLog);
- m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_AUDIO_STATUS);
- return false;
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_AUDIO_STATUS);
+ command.parameters.push_back((uint8_t) m_audioStatus);
+
+ return m_processor->Transmit(command);
}
bool CCECAudioSystem::TransmitSystemAudioModeStatus(cec_logical_address dest)
{
- // TODO
CStdString strLog;
- strLog.Format("<< %x -> %x: system audio mode status feature abort", m_iLogicalAddress, dest);
+ strLog.Format("<< %x -> %x: system audio mode '%2x'", m_iLogicalAddress, dest, m_systemAudioStatus);
AddLog(CEC_LOG_NOTICE, strLog);
- m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS);
- return false;
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS);
+ command.parameters.push_back((uint8_t) m_systemAudioStatus);
+
+ return m_processor->Transmit(command);
}
CCECAudioSystem(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0);
virtual ~CCECAudioSystem(void) {};
+ virtual bool SetSystemAudioMode(const cec_command &command);
virtual bool TransmitAudioStatus(cec_logical_address dest);
virtual bool TransmitSystemAudioModeStatus(cec_logical_address dest);
+
+ protected:
+ cec_system_audio_status m_systemAudioStatus;
+ cec_audio_status m_audioStatus;
};
}
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);
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);