diff --git a/src/drivers/Qt/AviRecord.cpp b/src/drivers/Qt/AviRecord.cpp index 8168412e..f5051cfe 100644 --- a/src/drivers/Qt/AviRecord.cpp +++ b/src/drivers/Qt/AviRecord.cpp @@ -2153,7 +2153,7 @@ int aviRecordOpenFile( const char *filepath ) { 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]; fprintf( avLogFp, "Error: Failed to open AVI file.\n"); diff --git a/src/drivers/Qt/avi/gwavi.cpp b/src/drivers/Qt/avi/gwavi.cpp index d8b95376..753f9f5e 100644 --- a/src/drivers/Qt/avi/gwavi.cpp +++ b/src/drivers/Qt/avi/gwavi.cpp @@ -82,6 +82,7 @@ gwavi_t::gwavi_t(void) movi_fpos = 0; bits_per_pixel = 24; avi_std = 2; + audioEnabled = false; } 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"); stream_index_v.streamId = 0; + audioEnabled = false; + if (audio) { /* 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"); stream_index_a.streamId = 1; + audioEnabled = true; } std_index_base_ofs_v = 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; } - 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(); @@ -496,9 +504,12 @@ gwavi_t::close(void) { 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; + } } } diff --git a/src/drivers/Qt/avi/gwavi.h b/src/drivers/Qt/avi/gwavi.h index c2b8eff1..d45727e2 100644 --- a/src/drivers/Qt/avi/gwavi.h +++ b/src/drivers/Qt/avi/gwavi.h @@ -216,6 +216,7 @@ class gwavi_t int bits_per_pixel; int avi_std; char fourcc[8]; + char audioEnabled; // helper functions long long ftell(FILE *fp);