From: Lars Op den Kamp Date: Sat, 26 Nov 2011 01:36:19 +0000 (+0100) Subject: cec: added bWait parameter to volume change methods. X-Git-Tag: upstream/2.2.0~1^2~44^2~91 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9f332fe262328ff230ae4ea69004f8f2e9f61e6f;p=deb_libcec.git cec: added bWait parameter to volume change methods. --- diff --git a/include/cec.h b/include/cec.h index 7ac25fd..1486b28 100644 --- a/include/cec.h +++ b/include/cec.h @@ -272,21 +272,24 @@ namespace CEC /*! * @brief Sends a volume up keypress to an audiosystem if it's present. + * @param bWait Wait for the response of the audiosystem when true. * @return The new audio status. */ - virtual uint8_t VolumeUp(void) = 0; + virtual uint8_t VolumeUp(bool bWait = true) = 0; /*! * @brief Sends a volume down keypress to an audiosystem if it's present. + * @param bWait Wait for the response of the audiosystem when true. * @return The new audio status. */ - virtual uint8_t VolumeDown(void) = 0; + virtual uint8_t VolumeDown(bool bWait = true) = 0; /*! * @brief Sends a mute keypress to an audiosystem if it's present. + * @param bWait Wait for the response of the audiosystem when true. * @return The new audio status. */ - virtual uint8_t MuteAudio(void) = 0; + virtual uint8_t MuteAudio(bool bWait = true) = 0; }; }; diff --git a/include/cecc.h b/include/cecc.h index c7e5ad4..d4765e0 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -187,11 +187,11 @@ extern DECLSPEC int cec_is_active_device_type(cec_device_type type); extern DECLSPEC int cec_set_hdmi_port(uint8_t iPort); -extern DECLSPEC int cec_volume_up(void); +extern DECLSPEC int cec_volume_up(int bWait = 1); -extern DECLSPEC int cec_volume_down(void); +extern DECLSPEC int cec_volume_down(int bWait = 1); -extern DECLSPEC int cec_mute_audio(void); +extern DECLSPEC int cec_mute_audio(int bWait = 1); #ifdef __cplusplus }; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 8f2ea98..d8fdb99 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -492,29 +492,29 @@ bool CCECProcessor::PollDevice(cec_logical_address iAddress) return false; } -uint8_t CCECProcessor::VolumeUp(void) +uint8_t CCECProcessor::VolumeUp(bool bWait /* = true */) { uint8_t status = 0; if (IsActiveDevice(CECDEVICE_AUDIOSYSTEM)) - status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeUp(); + status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeUp(bWait); return status; } -uint8_t CCECProcessor::VolumeDown(void) +uint8_t CCECProcessor::VolumeDown(bool bWait /* = true */) { uint8_t status = 0; if (IsActiveDevice(CECDEVICE_AUDIOSYSTEM)) - status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeDown(); + status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeDown(bWait); return status; } -uint8_t CCECProcessor::MuteAudio(void) +uint8_t CCECProcessor::MuteAudio(bool bWait /* = true */) { uint8_t status = 0; if (IsActiveDevice(CECDEVICE_AUDIOSYSTEM)) - status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->MuteAudio(); + status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->MuteAudio(bWait); return status; } diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 178978e..ea8f6a4 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -85,9 +85,9 @@ namespace CEC virtual bool SetStreamPath(uint16_t iStreamPath); virtual bool SwitchMonitoring(bool bEnable); virtual bool PollDevice(cec_logical_address iAddress); - virtual uint8_t VolumeUp(void); - virtual uint8_t VolumeDown(void); - virtual uint8_t MuteAudio(void); + virtual uint8_t VolumeUp(bool bWait = true); + virtual uint8_t VolumeDown(bool bWait = true); + virtual uint8_t MuteAudio(bool bWait = true); virtual bool Transmit(const cec_command &data); virtual bool Transmit(CCECAdapterMessage *output); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 2e9dac0..26fd7b0 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -280,25 +280,25 @@ bool CLibCEC::IsActiveDeviceType(cec_device_type type) return false; } -uint8_t CLibCEC::VolumeUp(void) +uint8_t CLibCEC::VolumeUp(bool bWait /* = true */) { if (m_cec) - return m_cec->VolumeUp(); + return m_cec->VolumeUp(bWait); return 0; } -uint8_t CLibCEC::VolumeDown(void) +uint8_t CLibCEC::VolumeDown(bool bWait /* = true */) { if (m_cec) - return m_cec->VolumeDown(); + return m_cec->VolumeDown(bWait); return 0; } -uint8_t CLibCEC::MuteAudio(void) +uint8_t CLibCEC::MuteAudio(bool bWait /* = true */) { if (m_cec) - return m_cec->MuteAudio(); + return m_cec->MuteAudio(bWait); return 0; } diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 5c9196b..ad3b1cd 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -88,9 +88,9 @@ namespace CEC virtual bool IsActiveDevice(cec_logical_address iAddress); virtual bool IsActiveDeviceType(cec_device_type type); virtual bool SetHDMIPort(uint8_t iPort = CEC_DEFAULT_HDMI_PORT); - virtual uint8_t VolumeUp(void); - virtual uint8_t VolumeDown(void); - virtual uint8_t MuteAudio(void); + virtual uint8_t VolumeUp(bool bWait = true); + virtual uint8_t VolumeDown(bool bWait = true); + virtual uint8_t MuteAudio(bool bWait = true); //@} virtual void AddLog(cec_log_level level, const std::string &strMessage); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index 08e6987..0193124 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -271,24 +271,24 @@ int cec_set_hdmi_port(uint8_t iPort) return -1; } -int cec_volume_up(void) +int cec_volume_up(int bWait /* = 1 */) { if (cec_parser) - return cec_parser->VolumeUp(); + return cec_parser->VolumeUp(bWait == 1); return -1; } -int cec_volume_down(void) +int cec_volume_down(int bWait /* = 1 */) { if (cec_parser) - return cec_parser->VolumeDown(); + return cec_parser->VolumeDown(bWait == 1); return -1; } -int cec_mute_audio(void) +int cec_mute_audio(int bWait /* = 1 */) { if (cec_parser) - return cec_parser->MuteAudio(); + return cec_parser->MuteAudio(bWait == 1); return -1; } diff --git a/src/lib/devices/CECAudioSystem.cpp b/src/lib/devices/CECAudioSystem.cpp index 4a4f11f..87735f4 100644 --- a/src/lib/devices/CECAudioSystem.cpp +++ b/src/lib/devices/CECAudioSystem.cpp @@ -109,22 +109,22 @@ bool CCECAudioSystem::TransmitSystemAudioModeStatus(cec_logical_address dest) return m_processor->Transmit(command); } -uint8_t CCECAudioSystem::VolumeUp(void) +uint8_t CCECAudioSystem::VolumeUp(bool bWait /* = true */) { - return SendKey(CEC_USER_CONTROL_CODE_VOLUME_UP); + return SendKey(CEC_USER_CONTROL_CODE_VOLUME_UP, bWait); } -uint8_t CCECAudioSystem::VolumeDown(void) +uint8_t CCECAudioSystem::VolumeDown(bool bWait /* = true */) { - return SendKey(CEC_USER_CONTROL_CODE_VOLUME_DOWN); + return SendKey(CEC_USER_CONTROL_CODE_VOLUME_DOWN, bWait); } -uint8_t CCECAudioSystem::MuteAudio(void) +uint8_t CCECAudioSystem::MuteAudio(bool bWait /* = true */) { - return SendKey(CEC_USER_CONTROL_CODE_MUTE); + return SendKey(CEC_USER_CONTROL_CODE_MUTE, bWait); } -uint8_t CCECAudioSystem::SendKey(cec_user_control_code key) +uint8_t CCECAudioSystem::SendKey(cec_user_control_code key, bool bWait /* = true */) { { CLockObject lock(&m_transmitMutex); @@ -134,8 +134,15 @@ uint8_t CCECAudioSystem::SendKey(cec_user_control_code key) m_processor->Transmit(command); cec_command::Format(command, m_processor->GetLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_USER_CONTROL_RELEASE); - if (m_processor->Transmit(command)) - m_condition.Wait(&m_transmitMutex, 1000); + if (bWait) + { + if (m_processor->Transmit(command)) + m_condition.Wait(&m_transmitMutex, 1000); + } + else + { + m_processor->Transmit(command); + } } CLockObject lock(&m_mutex); diff --git a/src/lib/devices/CECAudioSystem.h b/src/lib/devices/CECAudioSystem.h index 5602931..6c04ad9 100644 --- a/src/lib/devices/CECAudioSystem.h +++ b/src/lib/devices/CECAudioSystem.h @@ -47,10 +47,10 @@ namespace CEC virtual bool TransmitAudioStatus(cec_logical_address dest); virtual bool TransmitSystemAudioModeStatus(cec_logical_address dest); - virtual uint8_t VolumeUp(void); - virtual uint8_t VolumeDown(void); - virtual uint8_t MuteAudio(void); - virtual uint8_t SendKey(cec_user_control_code key); + virtual uint8_t VolumeUp(bool bWait = true); + virtual uint8_t VolumeDown(bool bWait = true); + virtual uint8_t MuteAudio(bool bWait = true); + virtual uint8_t SendKey(cec_user_control_code key, bool bWait = true); virtual bool TransmitActiveSource(void) { return false; } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index a073a3f..9debd5d 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -150,9 +150,7 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) break; } - if (command.destination == CECDEVICE_BROADCAST || m_busDevice->MyLogicalAddressContains(command.destination)) - m_busDevice->GetProcessor()->AddCommand(command); - + m_busDevice->GetProcessor()->AddCommand(command); return bHandled; } diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 671e46e..d9ad277 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -599,15 +599,21 @@ int main (int argc, char *argv[]) } else if (command == "volup") { - parser->VolumeUp(); + CStdString strLog; + strLog.Format("volume up: %2X", parser->VolumeUp()); + cout << strLog.c_str() << endl; } else if (command == "voldown") { - parser->VolumeDown(); + CStdString strLog; + strLog.Format("volume up: %2X", parser->VolumeDown()); + cout << strLog.c_str() << endl; } else if (command == "mute") { - parser->MuteAudio(); + CStdString strLog; + strLog.Format("mute: %2X", parser->MuteAudio()); + cout << strLog.c_str() << endl; } else if (command == "mon") {