| 1225 | } |
| 1226 | |
| 1227 | bool CCECCommandHandler::Transmit(cec_command &command, bool bSuppressWait, bool bIsReply) |
| 1228 | { |
| 1229 | bool bReturn(false); |
| 1230 | cec_opcode expectedResponse(cec_command::GetResponseOpcode(command.opcode)); |
| 1231 | bool bExpectResponse(expectedResponse != CEC_OPCODE_NONE && !bSuppressWait); |
| 1232 | command.transmit_timeout = m_iTransmitTimeout; |
| 1233 | |
| 1234 | if (command.initiator == CECDEVICE_UNKNOWN) |
| 1235 | { |
| 1236 | LIB_CEC->AddLog(CEC_LOG_ERROR, "not transmitting a command without a valid initiator"); |
| 1237 | return bReturn; |
| 1238 | } |
| 1239 | |
| 1240 | // check whether the destination is not marked as not present or handled by libCEC |
| 1241 | if (command.destination != CECDEVICE_BROADCAST && command.opcode_set) |
| 1242 | { |
| 1243 | CCECBusDevice* destinationDevice = m_processor->GetDevice(command.destination); |
| 1244 | cec_bus_device_status status = destinationDevice ? destinationDevice->GetStatus() : CEC_DEVICE_STATUS_NOT_PRESENT; |
| 1245 | if (status == CEC_DEVICE_STATUS_NOT_PRESENT) |
| 1246 | { |
| 1247 | LIB_CEC->AddLog(CEC_LOG_DEBUG, "not sending command '%s': destination device '%s' marked as not present", ToString(command.opcode),ToString(command.destination)); |
| 1248 | return bReturn; |
| 1249 | } |
| 1250 | else if (status == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC) |
| 1251 | { |
| 1252 | LIB_CEC->AddLog(CEC_LOG_DEBUG, "not sending command '%s': destination device '%s' marked as handled by libCEC", ToString(command.opcode),ToString(command.destination)); |
| 1253 | return bReturn; |
| 1254 | } |
| 1255 | else if (destinationDevice->IsUnsupportedFeature(command.opcode)) |
| 1256 | { |
| 1257 | return true; |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | { |
| 1262 | uint8_t iTries(0), iMaxTries(m_iTransmitRetries + 1); |
| 1263 | while (!bReturn && ++iTries <= iMaxTries) |
| 1264 | { |
| 1265 | if ((bReturn = m_processor->Transmit(command, bIsReply)) == true) |
| 1266 | { |
| 1267 | #ifdef CEC_DEBUGGING |
| 1268 | LIB_CEC->AddLog(CEC_LOG_DEBUG, "command transmitted"); |
| 1269 | #endif |
| 1270 | if (bExpectResponse) |
| 1271 | { |
| 1272 | bReturn = m_busDevice->WaitForOpcode(expectedResponse); |
| 1273 | LIB_CEC->AddLog(CEC_LOG_DEBUG, bReturn ? "expected response received (%X: %s)" : "expected response not received (%X: %s)", (int)expectedResponse, ToString(expectedResponse)); |
| 1274 | } |
| 1275 | } |
| 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | return bReturn; |
| 1280 | } |
| 1281 | |
| 1282 | bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = false */) |
| 1283 | { |
nothing calls this directly
no test coverage detected