mirror of
https://github.com/thestk/stk
synced 2026-05-03 04:18:12 +00:00
Merge pull request #1 from tmatth/filewrite_fix_warnings
FileWrite: fix warnings
This commit is contained in:
@@ -247,9 +247,7 @@ bool FileWrite :: setWavFile( std::string fileName )
|
|||||||
hdr.bytesPerSecond = (SINT32) (hdr.sampleRate * hdr.bytesPerSample);
|
hdr.bytesPerSecond = (SINT32) (hdr.sampleRate * hdr.bytesPerSample);
|
||||||
|
|
||||||
unsigned int bytesToWrite = 36;
|
unsigned int bytesToWrite = 36;
|
||||||
bool useExtensible = false;
|
|
||||||
if ( channels_ > 2 || hdr.bitsPerSample > 16 ) { // use extensible format
|
if ( channels_ > 2 || hdr.bitsPerSample > 16 ) { // use extensible format
|
||||||
useExtensible = true;
|
|
||||||
bytesToWrite = 72;
|
bytesToWrite = 72;
|
||||||
hdr.chunkSize += 24;
|
hdr.chunkSize += 24;
|
||||||
hdr.formatCode = 0xFFFE;
|
hdr.formatCode = 0xFFFE;
|
||||||
@@ -459,7 +457,7 @@ bool FileWrite :: setAifFile( std::string fileName )
|
|||||||
#ifdef __LITTLE_ENDIAN__
|
#ifdef __LITTLE_ENDIAN__
|
||||||
swap16((unsigned char *)&i);
|
swap16((unsigned char *)&i);
|
||||||
#endif
|
#endif
|
||||||
*(SINT16 *)(hdr.srate) = (SINT16) i;
|
memcpy( hdr.srate, &i, sizeof(SINT16) );
|
||||||
|
|
||||||
for ( i=32; i; i-- ) {
|
for ( i=32; i; i-- ) {
|
||||||
if ( rate & 0x80000000 ) break;
|
if ( rate & 0x80000000 ) break;
|
||||||
@@ -469,7 +467,7 @@ bool FileWrite :: setAifFile( std::string fileName )
|
|||||||
#ifdef __LITTLE_ENDIAN__
|
#ifdef __LITTLE_ENDIAN__
|
||||||
swap32((unsigned char *)&rate);
|
swap32((unsigned char *)&rate);
|
||||||
#endif
|
#endif
|
||||||
*(unsigned long *)(hdr.srate+2) = (unsigned long) rate;
|
memcpy( hdr.srate + 2, &rate, sizeof(rate) );
|
||||||
|
|
||||||
byteswap_ = false;
|
byteswap_ = false;
|
||||||
#ifdef __LITTLE_ENDIAN__
|
#ifdef __LITTLE_ENDIAN__
|
||||||
@@ -690,7 +688,11 @@ void FileWrite :: closeMatFile( void )
|
|||||||
|
|
||||||
SINT32 headsize, temp;
|
SINT32 headsize, temp;
|
||||||
fseek(fd_, 196, SEEK_SET); // jump to header size
|
fseek(fd_, 196, SEEK_SET); // jump to header size
|
||||||
fread(&headsize, 4, 1, fd_);
|
if (fread(&headsize, 4, 1, fd_) < 4) {
|
||||||
|
oStream_ << "FileWrite: could not read MAT-file header size.";
|
||||||
|
goto close_file;
|
||||||
|
}
|
||||||
|
|
||||||
temp = headsize;
|
temp = headsize;
|
||||||
headsize += (SINT32) (frameCounter_ * 8 * channels_);
|
headsize += (SINT32) (frameCounter_ * 8 * channels_);
|
||||||
fseek(fd_, 196, SEEK_SET);
|
fseek(fd_, 196, SEEK_SET);
|
||||||
@@ -701,6 +703,7 @@ void FileWrite :: closeMatFile( void )
|
|||||||
temp = frameCounter_ * 8 * channels_;
|
temp = frameCounter_ * 8 * channels_;
|
||||||
fwrite(&temp, 4, 1, fd_);
|
fwrite(&temp, 4, 1, fd_);
|
||||||
|
|
||||||
|
close_file:
|
||||||
fclose(fd_);
|
fclose(fd_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user