mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
fix the problem of audio when video fps is low
This commit is contained in:
parent
779afcb771
commit
3baba93ed2
|
@ -2520,8 +2520,8 @@ void CClient::Update()
|
|||
if (IVideo::Current()->frameRendered())
|
||||
{
|
||||
IVideo::Current()->nextVideoFrame();
|
||||
IVideo::Current()->nextAudioFrame_timeline();
|
||||
}
|
||||
IVideo::Current()->nextAudioFrame_timeline();
|
||||
}
|
||||
else if(m_ButtonRender)
|
||||
Disconnect();
|
||||
|
|
|
@ -202,24 +202,24 @@ void CVideo::stop()
|
|||
|
||||
void CVideo::nextVideoFrame_thread()
|
||||
{
|
||||
if (m_NextFrame && m_Recording)
|
||||
if (m_NextFrame && m_Recording && !m_ProcessingAudioFrame)
|
||||
{
|
||||
m_ProcessingVideoFrame = true;
|
||||
// #ifdef CONF_PLATFORM_MACOSX
|
||||
// CAutoreleasePool AutoreleasePool;
|
||||
// #endif
|
||||
m_vseq += 1;
|
||||
if(m_vseq >= 2)
|
||||
{
|
||||
m_ProcessingVideoFrame = true;
|
||||
m_VideoStream.frame->pts = (int64_t)m_VideoStream.enc->frame_number;
|
||||
dbg_msg("video_recorder", "vframe: %d", m_VideoStream.enc->frame_number);
|
||||
|
||||
read_rgb_from_gl();
|
||||
fill_video_frame();
|
||||
write_frame(&m_VideoStream);
|
||||
m_ProcessingVideoFrame = false;
|
||||
}
|
||||
|
||||
m_ProcessingVideoFrame = false;
|
||||
m_NextFrame = false;
|
||||
// sync_barrier();
|
||||
// m_Semaphore.signal();
|
||||
|
@ -252,7 +252,8 @@ void CVideo::nextAudioFrame_timeline()
|
|||
{
|
||||
if (m_Recording && m_HasAudio && !m_NextaFrame)
|
||||
{
|
||||
if ((double)(m_vframe/m_FPS) >= m_AudioStream.enc->frame_number*m_AudioStream.enc->frame_size/m_AudioStream.enc->sample_rate)
|
||||
//if (m_vframe * m_AudioStream.enc->sample_rate / m_FPS >= m_AudioStream.enc->frame_number*m_AudioStream.enc->frame_size)
|
||||
if (m_VideoStream.enc->frame_number * (double)m_AudioStream.enc->sample_rate / m_FPS >= (double)m_AudioStream.enc->frame_number*m_AudioStream.enc->frame_size)
|
||||
{
|
||||
m_NextaFrame = true;
|
||||
}
|
||||
|
@ -261,7 +262,7 @@ void CVideo::nextAudioFrame_timeline()
|
|||
|
||||
void CVideo::nextAudioFrame(void (*Mix)(short *pFinalOut, unsigned Frames))
|
||||
{
|
||||
if (m_NextaFrame && m_Recording && m_HasAudio)
|
||||
if (m_NextaFrame && m_Recording && m_HasAudio && !m_ProcessingVideoFrame)
|
||||
{
|
||||
m_ProcessingAudioFrame = true;
|
||||
//dbg_msg("video recorder", "video_frame: %lf", (double)(m_vframe/m_FPS));
|
||||
|
|
Loading…
Reference in a new issue