+CCECAudioSystem *CCECBusDevice::AsAudioSystem(CCECBusDevice *device)
+{
+ if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ return static_cast<CCECAudioSystem *>(device);
+ return NULL;
+}
+
+CCECPlaybackDevice *CCECBusDevice::AsPlaybackDevice(CCECBusDevice *device)
+{
+ if (device &&
+ (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
+ device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
+ return static_cast<CCECPlaybackDevice *>(device);
+ return NULL;
+}
+
+CCECRecordingDevice *CCECBusDevice::AsRecordingDevice(CCECBusDevice *device)
+{
+ if (device && device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)
+ return static_cast<CCECRecordingDevice *>(device);
+ return NULL;
+}
+
+CCECTuner *CCECBusDevice::AsTuner(CCECBusDevice *device)
+{
+ if (device && device->GetType() == CEC_DEVICE_TYPE_TUNER)
+ return static_cast<CCECTuner *>(device);
+ return NULL;
+}
+
+CCECTV *CCECBusDevice::AsTV(CCECBusDevice *device)
+{
+ if (device && device->GetType() == CEC_DEVICE_TYPE_TV)
+ return static_cast<CCECTV *>(device);
+ return NULL;
+}
+
+void CCECBusDevice::MarkBusy(void)
+{
+ CLockObject handlerLock(m_handlerMutex);
+ ++m_iHandlerUseCount;
+}
+
+void CCECBusDevice::MarkReady(void)
+{
+ CLockObject handlerLock(m_handlerMutex);
+ if (m_iHandlerUseCount > 0)
+ --m_iHandlerUseCount;
+}
+
+bool CCECBusDevice::TryLogicalAddress(void)
+{
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "trying logical address '%s'", GetLogicalAddressName());
+
+ if (!TransmitPoll(m_iLogicalAddress))
+ {
+ LIB_CEC->AddLog(CEC_LOG_NOTICE, "using logical address '%s'", GetLogicalAddressName());
+ SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC);
+
+ return true;
+ }
+
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "logical address '%s' already taken", GetLogicalAddressName());
+ SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT);
+ return false;
+}
+
+CCECClient *CCECBusDevice::GetClient(void)
+{
+ return m_processor->GetClient(m_iLogicalAddress);
+}