Skip to content

Commit b7ef948

Browse files
committed
Ensure constant framerate for demo video
The AVI framerate is fixed, so don't change the recording rate in response to later cl_aviFrameRate changes.
1 parent 3d55f9a commit b7ef948

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/engine/RefAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ struct refimport_t {
217217
int ( *FS_FOpenFileRead )( const char* qpath, fileHandle_t* file );
218218

219219
// XreaL BEGIN
220-
bool( *CL_VideoRecording )( );
220+
int ( *CL_VideoRecording )( );
221221
void ( *CL_WriteAVIVideoFrame )( const byte* buffer, int size );
222222
// XreaL END
223223

src/engine/client/cl_avi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ bool CL_CloseAVI()
612612
CL_VideoRecording
613613
===============
614614
*/
615-
bool CL_VideoRecording()
615+
int CL_VideoRecording()
616616
{
617-
return afd.fileOpen;
617+
return afd.fileOpen ? afd.frameRate : 0;
618618
}

src/engine/client/cl_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,15 +2013,16 @@ void CL_Frame( int msec )
20132013
}
20142014

20152015
// if recording an avi, lock to a fixed fps
2016-
if ( CL_VideoRecording() && cl_aviFrameRate->integer && msec )
2016+
int framerate;
2017+
if ( ( framerate = CL_VideoRecording() ) && msec )
20172018
{
20182019
// save the current screen
20192020
if ( cls.state == connstate_t::CA_ACTIVE )
20202021
{
20212022
CL_TakeVideoFrame();
20222023

20232024
// fixed time for next frame
2024-
msec = ( int ) ceil( ( 1000.0f / cl_aviFrameRate->value ) * com_timescale->value );
2025+
msec = ( int ) ceil( ( 1000.0f / framerate ) * com_timescale->value );
20252026

20262027
if ( msec == 0 )
20272028
{

src/engine/client/client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ bool CL_OpenAVIForWriting( const char *filename );
667667
void CL_TakeVideoFrame();
668668
void CL_WriteAVIVideoFrame( const byte *imageBuffer, int size );
669669
bool CL_CloseAVI();
670-
bool CL_VideoRecording();
670+
int CL_VideoRecording();
671671

672672
// XreaL END
673673

0 commit comments

Comments
 (0)