X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECPlaybackDevice.cpp;h=f9689cbe81a5ffb8816f12bed4995802f382a5b0;hb=f00ff009cfc5dfefdf09ca241b9560e74575b3f5;hp=02b9d43bbac89a7661e69da4be0f9eab3dbe14f1;hpb=28fa6c976a4c91b515be4cb119f92e2000bbd90e;p=deb_libcec.git diff --git a/src/lib/devices/CECPlaybackDevice.cpp b/src/lib/devices/CECPlaybackDevice.cpp index 02b9d43..f9689cb 100644 --- a/src/lib/devices/CECPlaybackDevice.cpp +++ b/src/lib/devices/CECPlaybackDevice.cpp @@ -35,6 +35,9 @@ #include "../CECProcessor.h" using namespace CEC; +using namespace PLATFORM; + +#define ToString(p) m_processor->ToString(p) CCECPlaybackDevice::CCECPlaybackDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress /* = 0 */) : CCECBusDevice(processor, address, iPhysicalAddress), @@ -44,24 +47,38 @@ CCECPlaybackDevice::CCECPlaybackDevice(CCECProcessor *processor, cec_logical_add m_type = CEC_DEVICE_TYPE_PLAYBACK_DEVICE; } +cec_deck_info CCECPlaybackDevice::GetDeckStatus(void) +{ + CLockObject lock(m_mutex); + return m_deckStatus; +} + void CCECPlaybackDevice::SetDeckStatus(cec_deck_info deckStatus) { - if (m_deckStatus != deckStatus) + CLockObject lock(m_mutex); + if (m_deckStatus != deckStatus && m_deckStatus != CEC_DECK_INFO_OTHER_STATUS_LG) { CStdString strLog; - strLog.Format(">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(m_deckStatus), CCECCommandHandler::ToString(deckStatus)); + strLog.Format(">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckStatus), ToString(deckStatus)); AddLog(CEC_LOG_DEBUG, strLog.c_str()); m_deckStatus = deckStatus; } } +cec_deck_control_mode CCECPlaybackDevice::GetDeckControlMode(void) +{ + CLockObject lock(m_mutex); + return m_deckControlMode; +} + void CCECPlaybackDevice::SetDeckControlMode(cec_deck_control_mode mode) { + CLockObject lock(m_mutex); if (m_deckControlMode != mode) { CStdString strLog; - strLog.Format(">> %s (%X): deck control mode changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(m_deckControlMode), CCECCommandHandler::ToString(mode)); + strLog.Format(">> %s (%X): deck control mode changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckControlMode), ToString(mode)); AddLog(CEC_LOG_DEBUG, strLog.c_str()); m_deckControlMode = mode; @@ -70,13 +87,14 @@ void CCECPlaybackDevice::SetDeckControlMode(cec_deck_control_mode mode) bool CCECPlaybackDevice::TransmitDeckStatus(cec_logical_address dest) { - CStdString strLog; - strLog.Format("<< %s (%X) -> %s (%X): deck status '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest, CCECCommandHandler::ToString(m_deckStatus)); - AddLog(CEC_LOG_NOTICE, strLog); - - cec_command command; - cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_DECK_STATUS); - command.push_back((uint8_t)m_deckStatus); + cec_deck_info state; + { + CLockObject lock(m_mutex); + CStdString strLog; + strLog.Format("<< %s (%X) -> %s (%X): deck status '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_deckStatus)); + AddLog(CEC_LOG_NOTICE, strLog); + state = m_deckStatus; + } - return m_processor->Transmit(command); + return m_handler->TransmitDeckStatus(m_iLogicalAddress, dest, state); }