- Timestamp:
- 03/28/09 14:24:21 (15 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.cpp
r1463 r1525 76 76 , m_scratch_buffer_size_bytes( 0 ) 77 77 , m_ticks_per_frame( 0 ) 78 , m_dll_bandwidth_hz ( STREAMPROCESSOR_DLL_BW_HZ ) 78 79 , m_sync_delay( 0 ) 79 80 , m_in_xrun( false ) … … 136 137 137 138 int StreamProcessor::getMaxFrameLatency() { 138 if (getType() == ePT_Receive) { 139 return (int)(m_IsoHandlerManager.getPacketLatencyForStream( this ) * TICKS_PER_CYCLE); 140 } else { 141 return (int)(m_IsoHandlerManager.getPacketLatencyForStream( this ) * TICKS_PER_CYCLE); 142 } 139 return (int)(m_IsoHandlerManager.getPacketLatencyForStream( this ) * TICKS_PER_CYCLE); 143 140 } 144 141 … … 282 279 283 280 bool 281 StreamProcessor::setDllBandwidth(float bw) 282 { 283 m_dll_bandwidth_hz = bw; 284 return true; 285 } 286 287 bool 284 288 StreamProcessor::canClientTransferFrames(unsigned int nbframes) 285 289 { … … 397 401 398 402 if (result == eCRV_OK) { 403 #ifdef DEBUG 404 if (m_last_timestamp > 0 && m_last_timestamp2 > 0) { 405 int64_t tsp_diff = diffTicks(m_last_timestamp, m_last_timestamp2); 406 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "TSP diff: %lld\n", tsp_diff); 407 double tsp_diff_d = tsp_diff; 408 double fs_syt = 1.0/tsp_diff_d; 409 fs_syt *= (double)getNominalFramesPerPacket() * (double)TICKS_PER_USEC * 1e6; 410 double fs_nom = (double)m_StreamProcessorManager.getNominalRate(); 411 double fs_diff = fs_nom - fs_syt; 412 double fs_diff_norm = fs_diff/fs_nom; 413 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "Nom fs: %12f, Instantanous fs: %12f, diff: %12f (%12f)\n", 414 fs_nom, fs_syt, fs_diff, fs_diff_norm); 415 if (fs_diff_norm > 0.01 || fs_diff_norm < -0.01) { 416 debugWarning( "Instantanous samplerate more than 1%% off nominal. [Nom fs: %12f, Instantanous fs: %12f, diff: %12f (%12f)]\n", 417 fs_nom, fs_syt, fs_diff, fs_diff_norm); 418 } 419 } 420 #endif 421 399 422 // #ifdef DEBUG 400 423 int ticks_per_packet = (int)(getTicksPerFrame() * getNominalFramesPerPacket()); … … 702 725 } 703 726 #ifdef DEBUG 727 if (m_last_timestamp > 0 && m_last_timestamp2 > 0) { 728 int64_t tsp_diff = diffTicks(m_last_timestamp, m_last_timestamp2); 729 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "TSP diff: %lld\n", tsp_diff); 730 double tsp_diff_d = tsp_diff; 731 double fs_syt = 1.0/tsp_diff_d; 732 fs_syt *= (double)getNominalFramesPerPacket() * (double)TICKS_PER_USEC * 1e6; 733 double fs_nom = (double)m_StreamProcessorManager.getNominalRate(); 734 double fs_diff = fs_nom - fs_syt; 735 double fs_diff_norm = fs_diff/fs_nom; 736 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "Nom fs: %12f, Instantanous fs: %12f, diff: %12f (%12f)\n", 737 fs_nom, fs_syt, fs_diff, fs_diff_norm); 738 if (fs_diff_norm > 0.01 || fs_diff_norm < -0.01) { 739 debugWarning( "Instantanous samplerate more than 1%% off nominal. [Nom fs: %12f, Instantanous fs: %12f, diff: %12f (%12f)]\n", 740 fs_nom, fs_syt, fs_diff, fs_diff_norm); 741 } 742 } 743 704 744 int ticks_per_packet = (int)(getTicksPerFrame() * getNominalFramesPerPacket()); 705 745 int diff = diffTicks(m_last_timestamp, m_last_timestamp2); … … 1097 1137 1098 1138 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); 1099 debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d \n",1100 m_StreamProcessorManager.getNominalRate() );1139 debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d [DLL Bandwidth: %f Hz]\n", 1140 m_StreamProcessorManager.getNominalRate(), m_dll_bandwidth_hz); 1101 1141 debugOutput( DEBUG_LEVEL_VERBOSE, " PeriodSize: %d, NbBuffers: %d\n", 1102 1142 m_StreamProcessorManager.getPeriodSize(), m_StreamProcessorManager.getNbBuffers()); … … 1358 1398 m_correct_last_timestamp = false; 1359 1399 1360 debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing remote ticks/frame to %f\n", ticks_per_frame);1400 debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing remote ticks/frame to %f\n", ticks_per_frame); 1361 1401 1362 1402 // initialize internal buffer … … 1372 1412 result &= m_data_buffer->setNominalRate(ticks_per_frame); 1373 1413 result &= m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 1414 result &= m_data_buffer->setBandwidth(m_dll_bandwidth_hz / (double)TICKS_PER_SECOND); 1374 1415 result &= m_data_buffer->prepare(); // FIXME: the name 1416 1417 debugOutput(DEBUG_LEVEL_VERBOSE, "DLL info: nominal tpf: %f, update period: %d, bandwidth: %e 1/ticks (%e Hz)\n", 1418 m_data_buffer->getNominalRate(), m_data_buffer->getUpdatePeriod(), m_data_buffer->getBandwidth(), m_data_buffer->getBandwidth() * TICKS_PER_SECOND); 1375 1419 1376 1420 break;