- Timestamp:
- 01/01/08 11:31:39 (16 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
r795 r796 21 21 * 22 22 */ 23 #include "config.h" 23 24 24 25 #include "StreamProcessorManager.h" … … 32 33 #include <assert.h> 33 34 #include <math.h> 34 35 #define RUNNING_TIMEOUT_MSEC 400036 #define PREPARE_TIMEOUT_MSEC 400037 #define ENABLE_TIMEOUT_MSEC 400038 39 // allows to add some processing margin. This shifts the time40 // at which the buffer is transfer()'ed, making things somewhat41 // more robust. It should be noted though that shifting the transfer42 // time to a later time instant also causes the xmit buffer fill to be43 // lower on average.44 #define FFADO_SIGNAL_DELAY_TICKS (3072*1)45 35 46 36 namespace Streaming { … … 257 247 // wait for the syncsource to start running. 258 248 // that will block the waitForPeriod call until everyone has started (theoretically) 259 #define CYCLES_FOR_DRYRUN 40000 260 int cnt = CYCLES_FOR_DRYRUN; // by then it should have started 249 int cnt = STREAMPROCESSORMANAGER_CYCLES_FOR_DRYRUN; // by then it should have started 261 250 bool all_dry_running = false; 262 251 while (!all_dry_running && cnt) { … … 319 308 // time to a later time instant also causes the xmit buffer fill to be 320 309 // lower on average. 321 max_of_min_delay += FFADO_SIGNAL_DELAY_TICKS;310 max_of_min_delay += STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS; 322 311 debugOutput( DEBUG_LEVEL_VERBOSE, " sync delay = %d ticks (%03us %04uc %04ut)...\n", 323 312 max_of_min_delay, … … 361 350 (unsigned int)TICKS_TO_OFFSET(time_of_first_sample)); 362 351 363 #define CYCLES_FOR_STARTUP 2000 364 // start wet-running in CYCLES_FOR_STARTUP cycles 352 // start wet-running in STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP cycles 365 353 // this is the time window we have to setup all SP's such that they 366 354 // can start wet-running correctly. 367 355 time_of_first_sample = addTicks(time_of_first_sample, 368 CYCLES_FOR_STARTUP * TICKS_PER_CYCLE);356 STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP * TICKS_PER_CYCLE); 369 357 370 358 debugOutput( DEBUG_LEVEL_VERBOSE, " => first sample at TS=%011llu (%03us %04uc %04ut)...\n", … … 376 364 // we should start wet-running the transmit SP's some cycles in advance 377 365 // such that we know it is wet-running when it should output its first sample 378 #define PRESTART_CYCLES_FOR_XMIT 20379 366 uint64_t time_to_start_xmit = substractTicks(time_of_first_sample, 380 PRESTART_CYCLES_FOR_XMIT * TICKS_PER_CYCLE); 381 382 #define PRESTART_CYCLES_FOR_RECV 0 367 STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_XMIT * TICKS_PER_CYCLE); 368 383 369 uint64_t time_to_start_recv = substractTicks(time_of_first_sample, 384 PRESTART_CYCLES_FOR_RECV * TICKS_PER_CYCLE);370 STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_RECV * TICKS_PER_CYCLE); 385 371 debugOutput( DEBUG_LEVEL_VERBOSE, " => xmit starts at TS=%011llu (%03us %04uc %04ut)...\n", 386 372 time_to_start_xmit, … … 421 407 // wait for the syncsource to start running. 422 408 // that will block the waitForPeriod call until everyone has started (theoretically) 423 int cnt = CYCLES_FOR_STARTUP * 20; // by then it should have started409 int cnt = STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP * 20; // by then it should have started 424 410 while (!m_SyncSource->isRunning() && cnt) { 425 411 SleepRelativeUsec(125); … … 444 430 { 445 431 if(m_SyncSource == NULL) return false; 446 #define ALIGN_AVERAGE_TIME_MSEC 200447 #define NB_ALIGN_TRIES 40448 432 debugOutput( DEBUG_LEVEL_VERBOSE, "Aligning received streams...\n"); 449 433 unsigned int nb_sync_runs; … … 454 438 unsigned int i; 455 439 456 unsigned int periods_per_align_try = ( ALIGN_AVERAGE_TIME_MSEC * getNominalRate());440 unsigned int periods_per_align_try = (STREAMPROCESSORMANAGER_ALIGN_AVERAGE_TIME_MSEC * getNominalRate()); 457 441 periods_per_align_try /= 1000; 458 442 periods_per_align_try /= getPeriodSize(); … … 460 444 461 445 bool aligned = false; 462 int cnt = NB_ALIGN_TRIES;446 int cnt = STREAMPROCESSORMANAGER_NB_ALIGN_TRIES; 463 447 while (!aligned && cnt--) { 464 448 nb_sync_runs = periods_per_align_try;