| 251 | } |
| 252 | |
| 253 | void *CAOCECAdapterCommunication::Process(void) |
| 254 | { |
| 255 | uint8_t buffer[CEC_MAX_FRAME_SIZE]; |
| 256 | uint32_t size; |
| 257 | fd_set rfds; |
| 258 | cec_logical_address initiator, destination; |
| 259 | struct timeval tv; |
| 260 | |
| 261 | if (!IsOpen()) |
| 262 | return 0; |
| 263 | |
| 264 | while (!IsStopped()) |
| 265 | { |
| 266 | if (m_fd == INVALID_SOCKET_VALUE) |
| 267 | { |
| 268 | break; |
| 269 | } |
| 270 | |
| 271 | FD_ZERO(&rfds); |
| 272 | FD_SET(m_fd, &rfds); |
| 273 | |
| 274 | tv.tv_sec = 1; |
| 275 | tv.tv_usec = 0; |
| 276 | |
| 277 | if (select(m_fd + 1, &rfds, NULL, NULL, &tv) >= 0 ) |
| 278 | { |
| 279 | |
| 280 | if (!FD_ISSET(m_fd, &rfds)) |
| 281 | continue; |
| 282 | |
| 283 | size = read(m_fd, buffer, CEC_MAX_FRAME_SIZE); |
| 284 | |
| 285 | if (size > 0) |
| 286 | { |
| 287 | initiator = cec_logical_address(buffer[0] >> 4); |
| 288 | destination = cec_logical_address(buffer[0] & 0x0f); |
| 289 | |
| 290 | cec_command cmd; |
| 291 | |
| 292 | cec_command::Format( |
| 293 | cmd, initiator, destination, |
| 294 | ( size > 1 ) ? cec_opcode(buffer[1]) : CEC_OPCODE_NONE); |
| 295 | |
| 296 | for (uint8_t i = 2; i < size; i++ ) |
| 297 | cmd.parameters.PushBack(buffer[i]); |
| 298 | |
| 299 | if (!IsStopped()) |
| 300 | m_callback->OnCommandReceived(cmd); |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | #endif // HAVE_AOCEC_API |
nothing calls this directly
no test coverage detected