X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=cc5cd40573215beb827bf3979b42a4206444de0b;hb=994dbaaa5c1f32810f3b4266caf5d6dd72e21718;hp=2c0f876a989bb89bcf9678ab029b50e07dfd5689;hpb=83be070122f15d5d8fa878608131ba69845fcd75;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 2c0f876..cc5cd40 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -55,7 +55,6 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, cec m_strDeviceName(strDeviceName), m_controller(controller), m_bMonitor(false), - m_busScan(NULL), m_iStandardLineTimeout(3), m_iRetryLineTimeout(3), m_iLastTransmission(0) @@ -150,9 +149,23 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread"); return false; } - lock.Leave(); + if (m_logicalAddresses.IsEmpty() && !FindLogicalAddresses()) + { + m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addresses"); + StopThread(true); + return false; + } + else + { + /* only set our OSD name and active source for the primary device */ + m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_strDeviceName; + m_busDevices[m_logicalAddresses.primary]->m_bActiveSource = true; + + SetAckMask(m_logicalAddresses.AckMask()); + } + m_busDevices[CECDEVICE_TV]->GetVendorId(); if (SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true)) @@ -162,8 +175,6 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, m_busDevices[CECDEVICE_TV]->GetHandler()->InitHandler(); m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); - m_busScan = new CCECBusScan(this); - m_busScan->CreateThread(true); return true; } else @@ -251,21 +262,7 @@ void *CCECProcessor::Process(void) cec_command command; CCECAdapterMessage msg; - if (m_logicalAddresses.IsEmpty() && !FindLogicalAddresses()) { - CLockObject lock(&m_mutex); - m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addresses"); - m_startCondition.Signal(); - return NULL; - } - else - { - /* only set our OSD name and active source for the primary device */ - m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_strDeviceName; - m_busDevices[m_logicalAddresses.primary]->m_bActiveSource = true; - - SetAckMask(m_logicalAddresses.AckMask()); - CLockObject lock(&m_mutex); m_bStarted = true; m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); @@ -299,13 +296,6 @@ void *CCECProcessor::Process(void) m_controller->CheckKeypressTimeout(); } - if (m_busScan) - { - m_busScan->StopThread(); - delete m_busScan; - m_busScan = NULL; - } - if (m_communication) m_communication->Close(); @@ -334,12 +324,15 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE } m_busDevices[addr]->SetActiveSource(); - bReturn = m_busDevices[addr]->TransmitActiveSource(); - - if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || - m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)) + if (m_busDevices[addr]->GetPhysicalAddress(false) != 0xFFFF) { - bReturn = ((CCECPlaybackDevice *)m_busDevices[addr])->TransmitDeckStatus(CECDEVICE_TV); + bReturn = m_busDevices[addr]->TransmitActiveSource(); + + if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || + m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)) + { + bReturn = ((CCECPlaybackDevice *)m_busDevices[addr])->TransmitDeckStatus(CECDEVICE_TV); + } } return bReturn; @@ -552,24 +545,6 @@ bool CCECProcessor::SwitchMonitoring(bool bEnable) { CLockObject lock(&m_mutex); m_bMonitor = bEnable; - - if (!bEnable) - { - if (!m_busScan) - { - m_busScan = new CCECBusScan(this); - m_busScan->CreateThread(true); - } - } - else - { - if (m_busScan) - { - m_busScan->StopThread(); - delete m_busScan; - m_busScan = NULL; - } - } } if (bEnable) @@ -650,6 +625,15 @@ CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const return device; } +CCECBusDevice *CCECProcessor::GetPrimaryDevice(void) const +{ + CCECBusDevice *device(NULL); + cec_logical_address primary = m_logicalAddresses.primary; + if (primary != CECDEVICE_UNKNOWN) + device = m_busDevices[primary]; + return device; +} + cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress) { return m_busDevices[iAddress]->GetCecVersion(); @@ -1008,12 +992,12 @@ bool CCECProcessor::SetAckMask(uint16_t iMask) bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = true */) { - return m_busDevices[iDestination]->TransmitKeypress(key); + return m_busDevices[iDestination]->TransmitKeypress(key, bWait); } bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination, bool bWait /* = true */) { - return m_busDevices[iDestination]->TransmitKeyRelease(); + return m_busDevices[iDestination]->TransmitKeyRelease(bWait); } const char *CCECProcessor::ToString(const cec_menu_state state)