312 | | m_data_buffer->getBufferTailTimestamp(&ts,&fc); |
---|
313 | | |
---|
314 | | debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", |
---|
315 | | next_period_boundary, ts, fc, getTicksPerFrame() |
---|
316 | | ); |
---|
317 | | #endif |
---|
318 | | |
---|
319 | | return (uint64_t)next_period_boundary; |
---|
320 | | } |
---|
321 | | |
---|
322 | | bool ReceiveStreamProcessor::canClientTransferFrames(unsigned int nbframes) { |
---|
323 | | return m_data_buffer->getFrameCounter() >= (int) nbframes; |
---|
324 | | } |
---|
325 | | |
---|
326 | | uint64_t TransmitStreamProcessor::getTimeAtPeriod() { |
---|
327 | | ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); |
---|
328 | | |
---|
329 | | #ifdef DEBUG |
---|
330 | | ffado_timestamp_t ts; |
---|
331 | | signed int fc; |
---|
332 | | m_data_buffer->getBufferTailTimestamp(&ts,&fc); |
---|
333 | | |
---|
334 | | debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", |
---|
335 | | next_period_boundary, ts, fc, getTicksPerFrame() |
---|
336 | | ); |
---|
337 | | #endif |
---|
338 | | |
---|
339 | | return (uint64_t)next_period_boundary; |
---|
340 | | } |
---|
341 | | |
---|
342 | | bool TransmitStreamProcessor::canClientTransferFrames(unsigned int nbframes) { |
---|
343 | | bool can_transfer; |
---|
344 | | // there has to be enough space to put the frames in |
---|
345 | | can_transfer = m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; |
---|
346 | | // or the buffer is transparent |
---|
347 | | can_transfer |= m_data_buffer->isTransparent(); |
---|
348 | | return can_transfer; |
---|
349 | | } |
---|
350 | | |
---|
351 | | |
---|
352 | | } |
---|
| 322 | #ifdef DEBUG |
---|
| 323 | ffado_timestamp_t ts; |
---|
| 324 | signed int fc; |
---|
| 325 | m_data_buffer->getBufferTailTimestamp(&ts,&fc); |
---|
| 326 | |
---|
| 327 | debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", |
---|
| 328 | next_period_boundary, ts, fc, getTicksPerFrame() |
---|
| 329 | ); |
---|
| 330 | #endif |
---|
| 331 | return (uint64_t)next_period_boundary; |
---|
| 332 | } else { |
---|
| 333 | ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); |
---|
| 334 | |
---|
| 335 | #ifdef DEBUG |
---|
| 336 | ffado_timestamp_t ts; |
---|
| 337 | signed int fc; |
---|
| 338 | m_data_buffer->getBufferTailTimestamp(&ts,&fc); |
---|
| 339 | |
---|
| 340 | debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", |
---|
| 341 | next_period_boundary, ts, fc, getTicksPerFrame() |
---|
| 342 | ); |
---|
| 343 | #endif |
---|
| 344 | return (uint64_t)next_period_boundary; |
---|
| 345 | } |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | bool |
---|
| 349 | StreamProcessor::canClientTransferFrames(unsigned int nbframes) { |
---|
| 350 | if (getType() == ePT_Receive) { |
---|
| 351 | return m_data_buffer->getFrameCounter() >= (int) nbframes; |
---|
| 352 | } else { |
---|
| 353 | bool can_transfer; |
---|
| 354 | // there has to be enough space to put the frames in |
---|
| 355 | can_transfer = m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; |
---|
| 356 | // or the buffer is transparent |
---|
| 357 | can_transfer |= m_data_buffer->isTransparent(); |
---|
| 358 | return can_transfer; |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | const char * |
---|
| 363 | StreamProcessor::ePSToString(enum eProcessorState s) { |
---|
| 364 | switch (s) { |
---|
| 365 | case ePS_Created: return "ePS_Created"; |
---|
| 366 | case ePS_Initialized: return "ePS_Initialized"; |
---|
| 367 | case ePS_WaitingForRunningStream: return "ePS_WaitingForRunningStream"; |
---|
| 368 | case ePS_DryRunning: return "ePS_DryRunning"; |
---|
| 369 | case ePS_WaitingForEnabledStream: return "ePS_WaitingForEnabledStream"; |
---|
| 370 | case ePS_StreamEnabled: return "ePS_StreamEnabled"; |
---|
| 371 | case ePS_WaitingForDisabledStream: return "ePS_WaitingForDisabledStream"; |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | |
---|
| 375 | } // end of namespace |
---|