| 361 | // |
| 362 | |
| 363 | HRESULT CBaseVideoRenderer2::SendQuality(REFERENCE_TIME trLate, |
| 364 | REFERENCE_TIME trRealStream) |
| 365 | { |
| 366 | Quality q; |
| 367 | HRESULT hr; |
| 368 | |
| 369 | // If we are the main user of time, then report this as Flood/Dry. |
| 370 | // If our suppliers are, then report it as Famine/Glut. |
| 371 | // |
| 372 | // We need to take action, but avoid hunting. Hunting is caused by |
| 373 | // 1. Taking too much action too soon and overshooting |
| 374 | // 2. Taking too long to react (so averaging can CAUSE hunting). |
| 375 | // |
| 376 | // The reason why we use trLate as well as Wait is to reduce hunting; |
| 377 | // if the wait time is coming down and about to go into the red, we do |
| 378 | // NOT want to rely on some average which is only telling is that it used |
| 379 | // to be OK once. |
| 380 | |
| 381 | q.TimeStamp = (REFERENCE_TIME)trRealStream; |
| 382 | |
| 383 | if (m_trFrameAvg<0) { |
| 384 | q.Type = Famine; // guess |
| 385 | } |
| 386 | // Is the greater part of the time taken bltting or something else |
| 387 | else if (m_trFrameAvg > 2*m_trRenderAvg) { |
| 388 | q.Type = Famine; // mainly other |
| 389 | } else { |
| 390 | q.Type = Flood; // mainly bltting |
| 391 | } |
| 392 | |
| 393 | q.Proportion = 1000; // default |
| 394 | |
| 395 | if (m_trFrameAvg<0) { |
| 396 | // leave it alone - we don't know enough |
| 397 | } |
| 398 | else if ( trLate> 0 ) { |
| 399 | // try to catch up over the next second |
| 400 | // We could be Really, REALLY late, but rendering all the frames |
| 401 | // anyway, just because it's so cheap. |
| 402 | |
| 403 | q.Proportion = 1000 - (int)((trLate)/(UNITS/1000)); |
| 404 | if (q.Proportion<500) { |
| 405 | q.Proportion = 500; // don't go daft. (could've been negative!) |
| 406 | } else { |
| 407 | } |
| 408 | |
| 409 | } else if ( m_trWaitAvg>20000 |
| 410 | && trLate<-20000 |
| 411 | ){ |
| 412 | // Go cautiously faster - aim at 2mSec wait. |
| 413 | if (m_trWaitAvg>=m_trFrameAvg) { |
| 414 | // This can happen because of some fudges. |
| 415 | // The waitAvg is how long we originally planned to wait |
| 416 | // The frameAvg is more honest. |
| 417 | // It means that we are spending a LOT of time waiting |
| 418 | q.Proportion = 2000; // double. |
| 419 | } else { |
| 420 | if (m_trFrameAvg+20000 > m_trWaitAvg) { |
nothing calls this directly
no test coverage detected