diff --git a/changelog.txt b/changelog.txt index 1b6a581..06f97ee 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,6 +12,8 @@ chg: with r_backend GL3, depth fade with MSAA now requires GLSL 4.00 at a minimu chg: with r_backend GL3, alpha to coverage now requires GLSL 4.00 at a minimum +fix: /video produced .avi files that started with silence when they were not first in the sequence + fix: with r_backend D3D11, some device reset scenarios caused fatal errors instead of video restarts fix: CVar slots that have been freed (e.g. through unset/cvar_trim/cvar_reset) can now be re-used diff --git a/code/client/cl_avi.cpp b/code/client/cl_avi.cpp index 8337971..6730c52 100644 --- a/code/client/cl_avi.cpp +++ b/code/client/cl_avi.cpp @@ -67,6 +67,12 @@ typedef struct aviFileData_s byte *cBuffer, *eBuffer; // capture and encoding buffers } aviFileData_t; +typedef enum closeMode_s +{ + CM_SEQUENCE_COMPLETE, // last in the sequence -> safe to clear sounds etc. + CM_SEQUENCE_INCOMPLETE // NOT last in the sequence -> we'll open a new one +} closeMode_t; + static aviFileData_t afd; #define MAX_AVI_BUFFER 2048 @@ -74,6 +80,8 @@ static aviFileData_t afd; static byte buffer[ MAX_AVI_BUFFER ]; static int bufIndex; +static qbool CloseAVI( closeMode_t closeMode ); + /* =============== SafeFS_Write @@ -334,7 +342,7 @@ qbool CL_OpenAVIForWriting( const char* fileNameNoExt, qbool reOpen ) static int avi_fileNameIndex; if ( reOpen ) - CL_CloseAVI(); + CloseAVI( CM_SEQUENCE_INCOMPLETE ); if ( afd.fileOpen ) return qfalse; @@ -578,7 +586,7 @@ CL_CloseAVI Closes the AVI file and writes an index chunk =============== */ -qbool CL_CloseAVI( void ) +static qbool CloseAVI( closeMode_t closeMode ) { int indexRemainder; int indexSize = afd.numIndices * 16; @@ -642,11 +650,17 @@ qbool CL_CloseAVI( void ) Com_Printf( "Wrote %d:%d frames to %s\n", afd.numVideoFrames, afd.numAudioFrames, afd.fileName ); - S_StopAllSounds(); + if ( closeMode == CM_SEQUENCE_COMPLETE ) + S_StopAllSounds(); return qtrue; } +qbool CL_CloseAVI( void ) +{ + return CloseAVI( CM_SEQUENCE_COMPLETE ); +} + /* =============== CL_VideoRecording diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 7157dfc..3f5b782 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -767,9 +767,7 @@ void CL_Disconnect( qbool showMainMenu ) { FS_ClearPakReferences( FS_CGAME_REF | FS_UI_REF | FS_GENERAL_REF ); // Stop recording any video - if( CL_VideoRecording( ) ) { - CL_CloseAVI( ); - } + CL_CloseAVI(); } @@ -1801,9 +1799,7 @@ doesn't know what graphics to reload static void CL_Vid_Restart_f() { // Settings may have changed so stop recording now - if( CL_VideoRecording( ) ) { - CL_CloseAVI( ); - } + CL_CloseAVI(); S_StopAllSounds(); // don't let them loop during the restart