| 1280 | } |
| 1281 | |
| 1282 | bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = false */) |
| 1283 | { |
| 1284 | if (m_busDevice->IsActiveSource() && |
| 1285 | m_busDevice->IsHandledByLibCEC()) |
| 1286 | { |
| 1287 | { |
| 1288 | CLockObject lock(m_mutex); |
| 1289 | // check if we need to send a delayed source switch |
| 1290 | if (bTransmitDelayedCommandsOnly) |
| 1291 | { |
| 1292 | if (m_iActiveSourcePending == 0 || GetTimeMs() < m_iActiveSourcePending) |
| 1293 | return false; |
| 1294 | |
| 1295 | #ifdef CEC_DEBUGGING |
| 1296 | LIB_CEC->AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command"); |
| 1297 | #endif |
| 1298 | } |
| 1299 | } |
| 1300 | |
| 1301 | // update the power state and menu state |
| 1302 | if (!bTransmitDelayedCommandsOnly) |
| 1303 | { |
| 1304 | m_busDevice->SetPowerStatus(CEC_POWER_STATUS_ON); |
| 1305 | m_busDevice->SetMenuState(CEC_MENU_STATE_ACTIVATED); |
| 1306 | } |
| 1307 | |
| 1308 | // vendor specific hook |
| 1309 | VendorPreActivateSourceHook(); |
| 1310 | |
| 1311 | // power on the TV |
| 1312 | CCECBusDevice* tv = m_processor->GetDevice(CECDEVICE_TV); |
| 1313 | bool bTvPresent = (tv && tv->GetStatus() == CEC_DEVICE_STATUS_PRESENT); |
| 1314 | bool bActiveSourceFailed(false); |
| 1315 | if (bTvPresent) |
| 1316 | tv->PowerOn(m_busDevice->GetLogicalAddress()); |
| 1317 | else |
| 1318 | LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV not present, not sending 'image view on'"); |
| 1319 | |
| 1320 | // check if we're allowed to switch sources |
| 1321 | bool bSourceSwitchAllowed = SourceSwitchAllowed(); |
| 1322 | if (!bSourceSwitchAllowed) |
| 1323 | LIB_CEC->AddLog(CEC_LOG_DEBUG, "source switch is currently not allowed by command handler"); |
| 1324 | |
| 1325 | // switch sources (if allowed) |
| 1326 | if (!bActiveSourceFailed && bSourceSwitchAllowed) |
| 1327 | { |
| 1328 | bActiveSourceFailed = !m_busDevice->TransmitActiveSource(false); |
| 1329 | if (bTvPresent && !bActiveSourceFailed) |
| 1330 | m_busDevice->TransmitMenuState(CECDEVICE_TV, false); |
| 1331 | |
| 1332 | // update the deck status for playback devices |
| 1333 | if (bTvPresent && !bActiveSourceFailed) |
| 1334 | { |
| 1335 | CCECPlaybackDevice *playbackDevice = m_busDevice->AsPlaybackDevice(); |
| 1336 | if (playbackDevice && SendDeckStatusUpdateOnActiveSource()) |
| 1337 | bActiveSourceFailed = !playbackDevice->TransmitDeckStatus(CECDEVICE_TV, false); |
| 1338 | } |
| 1339 |
no test coverage detected