195 | | |
---|
196 | | int dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; |
---|
197 | | if (dropped_cycles < 0) debugWarning("(%p) dropped < 1 (%d)\n", this, dropped_cycles); |
---|
198 | | else m_dropped += dropped_cycles; |
---|
199 | | if (dropped_cycles > 0) debugWarning("(%p) dropped %d packets on cycle %u\n", this, dropped_cycles, cycle); |
---|
200 | | m_last_cycle = cycle; |
---|
| 195 | int dropped_cycles = 0; |
---|
| 196 | if (m_last_cycle != (int)cycle && m_last_cycle != -1) { |
---|
| 197 | dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; |
---|
| 198 | if (dropped_cycles < 0) debugWarning("(%p) dropped < 1 (%d)\n", this, dropped_cycles); |
---|
| 199 | if (dropped_cycles > 0) { |
---|
| 200 | debugWarning("(%p) dropped %d packets on cycle %u\n", this, dropped_cycles, cycle); |
---|
| 201 | m_dropped += dropped_cycles; |
---|
| 202 | } |
---|
| 203 | m_last_cycle = cycle; |
---|
| 204 | } |
---|
303 | | // we don't want this sample to be written |
---|
304 | | return RAW1394_ISO_OK; |
---|
305 | | } |
---|
306 | | |
---|
307 | | // for all states that reach this we are allowed to |
---|
308 | | // do protocol specific data reception |
---|
309 | | bool ok = processPacketData(data, length, channel, tag, sy, cycle, dropped_cycles); |
---|
310 | | |
---|
311 | | // if an xrun occured, switch to the dryRunning state and |
---|
312 | | // allow for the xrun to be picked up |
---|
313 | | if (!ok) { |
---|
314 | | debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to DryRunning due to xrun\n"); |
---|
315 | | m_next_state = ePS_DryRunning; |
---|
| 305 | |
---|
| 306 | // this is an xrun situation |
---|
| 307 | m_in_xrun = true; |
---|
| 308 | debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packet xrun\n"); |
---|
| 309 | m_cycle_to_switch_state = cycle + 1; // switch in the next cycle |
---|
| 310 | m_next_state = ePS_WaitingForStreamDisable; |
---|
| 318 | |
---|
| 319 | // for all states that reach this we are allowed to |
---|
| 320 | // do protocol specific data reception |
---|
| 321 | enum eChildReturnValue result2 = processPacketData(data, length, channel, tag, sy, cycle, dropped_cycles); |
---|
| 322 | |
---|
| 323 | // if an xrun occured, switch to the dryRunning state and |
---|
| 324 | // allow for the xrun to be picked up |
---|
| 325 | if (result2 == eCRV_XRun) { |
---|
| 326 | m_in_xrun = true; |
---|
| 327 | debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to data xrun\n"); |
---|
| 328 | m_cycle_to_switch_state = cycle+1; // switch in the next cycle |
---|
| 329 | m_next_state = ePS_WaitingForStreamDisable; |
---|
| 330 | // execute the requested change |
---|
| 331 | if (!updateState()) { // we are allowed to change the state directly |
---|
| 332 | debugError("Could not update state!\n"); |
---|
| 333 | return RAW1394_ISO_ERROR; |
---|
| 334 | } |
---|
| 335 | return RAW1394_ISO_DEFER; |
---|
| 336 | } else if(result2 == eCRV_OK) { |
---|
| 337 | // no problem here |
---|
| 338 | return RAW1394_ISO_OK; |
---|
| 339 | } else { |
---|
| 340 | debugError("Invalid response\n"); |
---|
| 341 | return RAW1394_ISO_ERROR; |
---|
| 342 | } |
---|
| 343 | } else if(result == eCRV_Invalid) { |
---|
| 344 | // apparently we don't have to do anything when the packets are not valid |
---|
| 345 | return RAW1394_ISO_OK; |
---|
340 | | int dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; |
---|
341 | | if (dropped_cycles < 0) debugWarning("(%p) dropped < 1 (%d)\n", this, dropped_cycles); |
---|
342 | | else m_dropped += dropped_cycles; |
---|
343 | | if (dropped_cycles > 0) debugWarning("(%p) dropped %d packets on cycle %u\n", this, dropped_cycles, cycle); |
---|
344 | | m_last_cycle = cycle; |
---|
| 365 | int dropped_cycles = 0; |
---|
| 366 | if (m_last_cycle != cycle && m_last_cycle != -1) { |
---|
| 367 | dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; |
---|
| 368 | if (dropped_cycles < 0) debugWarning("(%p) dropped < 1 (%d)\n", this, dropped_cycles); |
---|
| 369 | if (dropped_cycles > 0) { |
---|
| 370 | debugWarning("(%p) dropped %d packets on cycle %u\n", this, dropped_cycles, cycle); |
---|
| 371 | m_dropped += dropped_cycles; |
---|
| 372 | } |
---|
| 373 | m_last_cycle = cycle; |
---|
| 374 | } |
---|
433 | | if (generatePacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length)) { |
---|
| 463 | enum eChildReturnValue result = generatePacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); |
---|
| 464 | if (result == eCRV_Packet) { |
---|
466 | | } else { // pick up the possible xruns |
---|
467 | | |
---|
| 499 | } else if (result == eCRV_XRun) { // pick up the possible xruns |
---|
| 500 | debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to header xrun\n"); |
---|
| 501 | m_in_xrun = true; |
---|
| 502 | m_cycle_to_switch_state = cycle+1; // switch in the next cycle |
---|
| 503 | m_next_state = ePS_WaitingForStreamDisable; |
---|
| 504 | // execute the requested change |
---|
| 505 | if (!updateState()) { // we are allowed to change the state directly |
---|
| 506 | debugError("Could not update state!\n"); |
---|
| 507 | return RAW1394_ISO_ERROR; |
---|
| 508 | } |
---|
| 509 | } else if (result == eCRV_EmptyPacket) { |
---|
| 510 | if(m_state != m_next_state) { |
---|
| 511 | debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n", |
---|
| 512 | ePSToString(m_state), ePSToString(m_next_state)); |
---|
| 513 | // execute the requested change |
---|
| 514 | if (!updateState()) { // we are allowed to change the state directly |
---|
| 515 | debugError("Could not update state!\n"); |
---|
| 516 | return RAW1394_ISO_ERROR; |
---|
| 517 | } |
---|
| 518 | } |
---|
| 519 | goto send_empty_packet; |
---|
| 520 | } else if (result == eCRV_Again) { |
---|
| 521 | debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "have to retry cycle %d\n", cycle); |
---|
| 522 | if(m_state != m_next_state) { |
---|
| 523 | debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n", |
---|
| 524 | ePSToString(m_state), ePSToString(m_next_state)); |
---|
| 525 | // execute the requested change |
---|
| 526 | if (!updateState()) { // we are allowed to change the state directly |
---|
| 527 | debugError("Could not update state!\n"); |
---|
| 528 | return RAW1394_ISO_ERROR; |
---|
| 529 | } |
---|
| 530 | } |
---|
| 531 | // force some delay |
---|
| 532 | usleep(125); |
---|
| 533 | return RAW1394_ISO_AGAIN; |
---|
| 534 | } else { |
---|
| 535 | debugError("Invalid return value: %d\n", result); |
---|
| 536 | return RAW1394_ISO_ERROR; |
---|