From: Lars Op den Kamp Date: Sun, 6 Nov 2011 16:25:28 +0000 (+0100) Subject: cec: added more audio control commands X-Git-Tag: upstream/2.2.0~1^2~95 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e5e86c76b70975d8a8c03c58a230a70726399906;p=deb_libcec.git cec: added more audio control commands --- diff --git a/include/cectypes.h b/include/cectypes.h index 6b9e0b5..8c6cf9c 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -82,14 +82,14 @@ typedef enum 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 { @@ -310,11 +310,11 @@ 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 { diff --git a/src/lib/devices/CECAudioSystem.cpp b/src/lib/devices/CECAudioSystem.cpp index a6d000f..8740694 100644 --- a/src/lib/devices/CECAudioSystem.cpp +++ b/src/lib/devices/CECAudioSystem.cpp @@ -36,30 +36,45 @@ 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); } diff --git a/src/lib/devices/CECAudioSystem.h b/src/lib/devices/CECAudioSystem.h index e65d134..82718f9 100644 --- a/src/lib/devices/CECAudioSystem.h +++ b/src/lib/devices/CECAudioSystem.h @@ -41,7 +41,12 @@ namespace CEC 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; }; } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index d2c6020..e30810c 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -99,6 +99,9 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) 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); @@ -323,6 +326,17 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &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); diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index c578119..b5c168b 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -63,6 +63,7 @@ namespace CEC virtual bool HandleRoutingChange(const cec_command &command); virtual bool HandleSetMenuLanguage(const cec_command &command); virtual bool HandleSetStreamPath(const cec_command &command); + virtual bool HandleSetSystemAudioModeRequest(const cec_command &command); virtual bool HandleGiveSystemAudioModeStatus(const cec_command &command); virtual bool HandleUserControlPressed(const cec_command &command); virtual bool HandleUserControlRelease(const cec_command &command);