Ticket #506: mythtv_audiosyncconsolid.patch
File mythtv_audiosyncconsolid.patch, 4.4 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.h
229 231 230 232 // Time Code adjustment stuff 231 233 long long AdjustAudioTimecodeOffset(long long v) 232 { audio_timecode_offset += v; return audio_timecode_offset; }234 { tc_wrap[TC_AUDIO] += v; return tc_wrap[TC_AUDIO]; } 233 235 long long ResetAudioTimecodeOffset(void) 234 { audio_timecode_offset = 0LL; return audio_timecode_offset; }236 { tc_wrap[TC_AUDIO] = 0LL; return tc_wrap[TC_AUDIO]; } 235 237 long long ResyncAudioTimecodeOffset(void) 236 { audio_timecode_offset = 0x8000LL << 12; return 0L; }238 { tc_wrap[TC_AUDIO] = LONG_LONG_MIN; return 0L; } 237 239 long long GetAudioTimecodeOffset(void) const 238 { return audio_timecode_offset; }240 { return tc_wrap[TC_AUDIO]; } 239 241 240 242 protected: 241 243 void DisplayPauseFrame(void); … … 514 516 int avsync_avg; 515 517 int avsync_oldavg; 516 518 int refreshrate; 517 long long lastaudiotime;518 long long audio_timecode_offset;519 519 bool lastsync; 520 520 bool m_playing_slower; 521 521 float m_stored_audio_stretchfactor; -
libs/libmythtv/NuppelVideoPlayer.cpp
143 143 vsynctol(30/4), avsync_delay(0), 144 144 avsync_adjustment(0), avsync_avg(0), 145 145 avsync_oldavg(0), refreshrate(0), 146 lastaudiotime(0), audio_timecode_offset(0),147 146 lastsync(false), m_playing_slower(false), 148 147 m_stored_audio_stretchfactor(1.0), 149 148 // Audio warping stuff … … 1449 1465 if (audioOutput && normal_speed) 1450 1466 { 1451 1467 long long currentaudiotime = audioOutput->GetAudiotime(); 1452 if (audio_timecode_offset == (long long)0x8000000000000000LL)1453 audio_timecode_offset = buffer->timecode - currentaudiotime;1454 1455 // ms, same scale as timecodes1456 lastaudiotime = currentaudiotime + audio_timecode_offset;1457 1468 #if 0 1458 1469 VERBOSE(VB_PLAYBACK, QString("A/V timecodes audio %1 video %2 frameinterval %3 avdel %4 avg %5 tcoffset %6") 1459 .arg( lastaudiotime)1470 .arg(currentaudiotime) 1460 1471 .arg(buffer->timecode) 1461 1472 .arg(frame_interval) 1462 .arg(buffer->timecode - lastaudiotime)1473 .arg(buffer->timecode - currentaudiotime) 1463 1474 .arg(avsync_avg) 1464 .arg( audio_timecode_offset)1475 .arg(tc_wrap[TC_AUDIO]) 1465 1476 ); 1466 1477 #endif 1467 1478 if (currentaudiotime != 0 && buffer->timecode != 0) … … 1482 1493 videosync->AdvanceTrigger(); 1483 1494 } 1484 1495 1485 avsync_delay = (buffer->timecode - lastaudiotime) * 1000; // uSecs1496 avsync_delay = (buffer->timecode - currentaudiotime) * 1000; // uSecs 1486 1497 avsync_avg = (avsync_delay + (avsync_avg * 3)) / 4; 1487 1498 if (!usevideotimebase) 1488 1499 { … … 1651 1662 1652 1663 void NuppelVideoPlayer::OutputVideoLoop(void) 1653 1664 { 1654 lastaudiotime = 0;1655 1665 delay = 0; 1656 1666 avsync_delay = 0; 1657 1667 avsync_avg = 0; … … 2188 2198 2189 2199 void NuppelVideoPlayer::WrapTimecode(long long &timecode, TCTypes tc_type) 2190 2200 { 2201 if ((tc_type == TC_AUDIO) && (tc_wrap[TC_AUDIO] == LONG_LONG_MIN)) 2202 { 2203 long long newaudio; 2204 newaudio = tc_lastval[TC_VIDEO] - tc_diff_estimate; 2205 tc_wrap[TC_AUDIO] = newaudio - timecode; 2206 timecode = newaudio; 2207 tc_lastval[TC_AUDIO] = timecode; 2208 VERBOSE(VB_IMPORTANT, "Manual Resync AV sync values"); 2209 } 2210 2191 2211 timecode += tc_wrap[tc_type]; 2192 2212 2193 2213 // wrapped … … 2206 2226 tc_avcheck_framecounter++; 2207 2227 if (tc_avcheck_framecounter == 30) 2208 2228 { 2229 #if 0 2209 2230 // something's terribly, terribly wrong. 2210 2231 if (tc_lastval[TC_AUDIO] < tc_lastval[TC_VIDEO] - 10000000 || 2211 2232 tc_lastval[TC_VIDEO] < tc_lastval[TC_AUDIO] - 10000000) … … 2217 2238 tc_lastval[TC_AUDIO] = timecode; 2218 2239 VERBOSE(VB_IMPORTANT, "Guessing at new AV sync values"); 2219 2240 } 2241 #endif 2220 2242 2221 2243 tc_diff_estimate = tc_lastval[TC_VIDEO] - tc_lastval[TC_AUDIO]; 2222 2244 tc_avcheck_framecounter = 0;