Bug fix for audio stream header still being written to AVI file even though audio capture has been disabled (for Qt GUI using old libgwavi).

This commit is contained in:
mjbudd77 2021-09-27 20:55:11 -04:00
parent 672dcac6b2
commit 2b9b2386d3
3 changed files with 17 additions and 5 deletions

View File

@ -2153,7 +2153,7 @@ int aviRecordOpenFile( const char *filepath )
{ {
gwavi = new gwavi_t(); gwavi = new gwavi_t();
if ( gwavi->open( fileName, nes_shm->video.ncol, nes_shm->video.nrow, fourcc, fps, &audioConfig ) ) if ( gwavi->open( fileName, nes_shm->video.ncol, nes_shm->video.nrow, fourcc, fps, recordAudio ? &audioConfig : NULL ) )
{ {
char msg[512]; char msg[512];
fprintf( avLogFp, "Error: Failed to open AVI file.\n"); fprintf( avLogFp, "Error: Failed to open AVI file.\n");

View File

@ -82,6 +82,7 @@ gwavi_t::gwavi_t(void)
movi_fpos = 0; movi_fpos = 0;
bits_per_pixel = 24; bits_per_pixel = 24;
avi_std = 2; avi_std = 2;
audioEnabled = false;
} }
gwavi_t::~gwavi_t(void) gwavi_t::~gwavi_t(void)
@ -212,6 +213,8 @@ gwavi_t::open(const char *filename, unsigned int width, unsigned int height,
strcpy( stream_index_v.chunkId, "00dc"); strcpy( stream_index_v.chunkId, "00dc");
stream_index_v.streamId = 0; stream_index_v.streamId = 0;
audioEnabled = false;
if (audio) if (audio)
{ {
/* set stream header */ /* set stream header */
@ -242,6 +245,7 @@ gwavi_t::open(const char *filename, unsigned int width, unsigned int height,
strcpy( stream_index_a.chunkId, "01wb"); strcpy( stream_index_a.chunkId, "01wb");
stream_index_a.streamId = 1; stream_index_a.streamId = 1;
audioEnabled = true;
} }
std_index_base_ofs_v = 0; std_index_base_ofs_v = 0;
std_index_base_ofs_a = 0; std_index_base_ofs_a = 0;
@ -326,9 +330,13 @@ gwavi_t::add_frame( unsigned char *buffer, size_t len, unsigned int flags)
{ {
return -1; return -1;
} }
if ( write_stream_std_indx( out, &stream_index_a ) == -1 )
if ( audioEnabled )
{ {
return -1; if ( write_stream_std_indx( out, &stream_index_a ) == -1 )
{
return -1;
}
} }
offsets.clear(); offsets.clear();
@ -496,9 +504,12 @@ gwavi_t::close(void)
{ {
return -1; return -1;
} }
if ( write_stream_std_indx( out, &stream_index_a ) == -1 ) if ( audioEnabled )
{ {
return -1; if ( write_stream_std_indx( out, &stream_index_a ) == -1 )
{
return -1;
}
} }
} }

View File

@ -216,6 +216,7 @@ class gwavi_t
int bits_per_pixel; int bits_per_pixel;
int avi_std; int avi_std;
char fourcc[8]; char fourcc[8];
char audioEnabled;
// helper functions // helper functions
long long ftell(FILE *fp); long long ftell(FILE *fp);