From a3dfee75f8e1764ef03fa274a9d6fc3415b97796 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Tue, 29 Oct 2013 17:32:41 -0700 Subject: [PATCH] Cleaned up minor warnings and removed unnecessary imports --- .../Hively/Hively.xcodeproj/project.pbxproj | 3 +-- Plugins/Hively/Hively/HVLContainer.m | 7 ++++--- Plugins/Hively/Hively/HVLDecoder.h | 2 +- Plugins/Hively/Hively/HVLDecoder.m | 20 +++++++++++-------- Plugins/Hively/Hively/HVLMetadataReader.m | 7 ++++--- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Plugins/Hively/Hively.xcodeproj/project.pbxproj b/Plugins/Hively/Hively.xcodeproj/project.pbxproj index 599828fd1..262cb9442 100644 --- a/Plugins/Hively/Hively.xcodeproj/project.pbxproj +++ b/Plugins/Hively/Hively.xcodeproj/project.pbxproj @@ -63,7 +63,6 @@ 836FB59E1820556F00B3AD2D /* HVLContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HVLContainer.h; sourceTree = ""; }; 836FB59F1820556F00B3AD2D /* HVLContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HVLContainer.m; sourceTree = ""; }; 836FB5A31820557E00B3AD2D /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../../Audio/Plugin.h; sourceTree = ""; }; - 836FB5A41820558900B3AD2D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../../Utils/Logging.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -119,7 +118,6 @@ 836FB5361820538700B3AD2D /* Hively */ = { isa = PBXGroup; children = ( - 836FB5A41820558900B3AD2D /* Logging.h */, 836FB5A31820557E00B3AD2D /* Plugin.h */, 836FB59A1820556F00B3AD2D /* HVLDecoder.h */, 836FB59B1820556F00B3AD2D /* HVLDecoder.m */, @@ -371,6 +369,7 @@ 836FB5411820538700B3AD2D /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Plugins/Hively/Hively/HVLContainer.m b/Plugins/Hively/Hively/HVLContainer.m index 592189011..7f226d55c 100755 --- a/Plugins/Hively/Hively/HVLContainer.m +++ b/Plugins/Hively/Hively/HVLContainer.m @@ -9,8 +9,6 @@ #import "HVLContainer.h" #import "HVLDecoder.h" -#import "Logging.h" - @implementation HVLContainer + (NSArray *)fileTypes @@ -43,10 +41,13 @@ long size = [source tell]; [source seek:0 whence:SEEK_SET]; + if ( size > UINT_MAX ) + return nil; + void * data = malloc(size); [source read:data amount:size]; - struct hvl_tune * tune = hvl_LoadTune( data, size, 44100, 2 ); + struct hvl_tune * tune = hvl_LoadTune( data, (uint32_t) size, 44100, 2 ); free( data ); if ( !tune ) return nil; diff --git a/Plugins/Hively/Hively/HVLDecoder.h b/Plugins/Hively/Hively/HVLDecoder.h index 9aadde922..8130a8c1d 100755 --- a/Plugins/Hively/Hively/HVLDecoder.h +++ b/Plugins/Hively/Hively/HVLDecoder.h @@ -15,7 +15,7 @@ @interface HVLDecoder : NSObject { struct hvl_tune *tune; int32_t *buffer; - long trackNumber; + int trackNumber; long totalFrames; long framesLength; diff --git a/Plugins/Hively/Hively/HVLDecoder.m b/Plugins/Hively/Hively/HVLDecoder.m index 66a0305af..b1c8a2bdb 100755 --- a/Plugins/Hively/Hively/HVLDecoder.m +++ b/Plugins/Hively/Hively/HVLDecoder.m @@ -8,8 +8,6 @@ #import "HVLDecoder.h" -#import "Logging.h" - @implementation HVLDecoder void oneTimeInit() @@ -34,10 +32,13 @@ void oneTimeInit() long size = [s tell]; [s seek:0 whence:SEEK_SET]; + if (size > UINT_MAX) + return NO; + void * data = malloc(size); [s read:data amount:size]; - tune = hvl_LoadTune( data, size, 44100, 2 ); + tune = hvl_LoadTune( data, (uint32_t) size, 44100, 2 ); free( data ); if ( !tune ) return NO; @@ -88,9 +89,9 @@ void oneTimeInit() [NSNumber numberWithInt:0], @"bitrate", [NSNumber numberWithFloat:44100], @"sampleRate", [NSNumber numberWithDouble:totalFrames], @"totalFrames", - [NSNumber numberWithInt:32], @"bitsPerSample", //Samples are short + [NSNumber numberWithInt:32], @"bitsPerSample", [NSNumber numberWithBool:YES], @"floatingPoint", - [NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo + [NSNumber numberWithInt:2], @"channels", [NSNumber numberWithBool:YES], @"seekable", @"host", @"endian", nil]; @@ -98,6 +99,9 @@ void oneTimeInit() - (int)readAudio:(void *)buf frames:(UInt32)frames { + if (framesRead >= totalFrames) + return 0; + int total = 0; while ( total < frames ) { if ( framesInBuffer ) @@ -105,7 +109,7 @@ void oneTimeInit() float * outbuffer = (( float * ) buf) + total * 2; int framesToCopy = frames - total; if ( framesToCopy > framesInBuffer ) - framesToCopy = framesInBuffer; + framesToCopy = (int) framesInBuffer; for ( int i = 0; i < framesToCopy; ++i ) { outbuffer[ 0 ] = buffer[ i * 2 + 0 ] * (1.0f / 16777216.0f); @@ -120,7 +124,7 @@ void oneTimeInit() break; } } - hvl_DecodeFrame( tune, buffer, buffer + 1, 8 ); + hvl_DecodeFrame( tune, (int8_t *) buffer, ((int8_t *) buffer) + 4, 8 ); framesInBuffer = 44100 / 50; } @@ -140,7 +144,7 @@ void oneTimeInit() fadeScale -= fadeStep; if (fadeScale <= 0.0) break; } - total = fadePos - fadeStart; + total = (int)(fadePos - fadeStart); } framesRead += total; diff --git a/Plugins/Hively/Hively/HVLMetadataReader.m b/Plugins/Hively/Hively/HVLMetadataReader.m index 10a532058..071fd5f1e 100644 --- a/Plugins/Hively/Hively/HVLMetadataReader.m +++ b/Plugins/Hively/Hively/HVLMetadataReader.m @@ -9,8 +9,6 @@ #import "HVLMetadataReader.h" #import "HVLDecoder.h" -#import "Logging.H" - @implementation HVLMetadataReader + (NSArray *)fileTypes @@ -38,10 +36,13 @@ long size = [source tell]; [source seek:0 whence:SEEK_SET]; + if ( size > UINT_MAX ) + return nil; + void * data = malloc(size); [source read:data amount:size]; - struct hvl_tune * tune = hvl_LoadTune( data, size, 44100, 2 ); + struct hvl_tune * tune = hvl_LoadTune( data, (uint32_t) size, 44100, 2 ); free( data ); if ( !tune ) return nil;