solve sync between video and audio by magic number

This commit is contained in:
sirius 2019-10-31 17:37:38 +08:00
parent 99df692e00
commit 99f6b66fbd
2 changed files with 3 additions and 2 deletions

View file

@ -287,7 +287,7 @@ static void Mix(short *pFinalOut, unsigned Frames)
#if defined(CONF_VIDEORECORDER)
if (IVideo::Current())
{
if(m_LastBreak <= IVideo::Current()->GetBreak()+0.005)
if(m_LastBreak <= IVideo::Current()->GetBreak())
{
IVideo::Current()->nextAudioFrame(pFinalOut);
m_LastBreak += 1;

View file

@ -25,7 +25,8 @@ public:
static void SetLocalStartTime(int64 LocalStartTime) { ms_LocalStartTime = LocalStartTime; }
static void SetFPS(int fps) { ms_TickTime = time_freq() / fps; }
void SetBreak(double Speed) { m_Break += 4.0/Speed; } // I think this 4 is related to `Len/2/2` in `Mix` function of /expand/teeworlds/demo/video_3/src/engine/client/sound.cpp
void SetBreak(double Speed) { m_Break += 3.75/Speed; } // I think this 4 is related to `Len/2/2` in `Mix` function of /expand/teeworlds/demo/video_3/src/engine/client/sound.cpp
// and for sync video and audio, it was changed to 3.75 as a magic number, hope someone can make it work without such magic number
double GetBreak() { return m_Break; }
protected: