diff --git a/Playlist/PlaylistController.h b/Playlist/PlaylistController.h index 75cfc2a35..062cc3108 100644 --- a/Playlist/PlaylistController.h +++ b/Playlist/PlaylistController.h @@ -22,6 +22,11 @@ typedef enum { RepeatAll } RepeatMode; +static BOOL IsRepeatOneSet() +{ + return [[NSUserDefaults standardUserDefaults] integerForKey:@"repeat"] == RepeatOne; +} + typedef enum { ShuffleOff = 0, ShuffleAlbums, diff --git a/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj b/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj index fadf28234..2239700f7 100644 --- a/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj +++ b/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj @@ -96,6 +96,7 @@ 83527EE918243029002F170E /* mo3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mo3.h; path = mo3/mo3.h; sourceTree = ""; }; 83527EEA18243069002F170E /* mo3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mo3.c; path = mo3/mo3.c; sourceTree = ""; }; 8384912B1808155E00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; + 83FAF8A418ADD45600057CAF /* PlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaylistController.h; path = ../../Playlist/PlaylistController.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Dumb.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Dumb.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -150,6 +151,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83FAF8A418ADD45600057CAF /* PlaylistController.h */, 8337AAE317FFA0000081AFF8 /* archive */, 8384912B1808155E00E7332D /* Logging.h */, 8335FF6517FF6FD9002D8DD2 /* DumbContainer.h */, diff --git a/Plugins/Dumb/DumbDecoder.m b/Plugins/Dumb/DumbDecoder.m index 9e2da173a..83052b860 100755 --- a/Plugins/Dumb/DumbDecoder.m +++ b/Plugins/Dumb/DumbDecoder.m @@ -19,6 +19,8 @@ #include #include +#import "PlaylistController.h" + @implementation DumbDecoder struct MEMANDFREEFILE @@ -260,7 +262,7 @@ int callbackLoop(void *data) ((float *)buf)[(total * 2) + i] = (float)sampptr[0][i] * scale; } - if ( loops >= 2 ) { + if ( !IsRepeatOneSet() && loops >= 2 ) { float * sampleBuf = ( float * ) buf + total * 2; long fadeEnd = fadeRemain - rendered; if ( fadeEnd < 0 ) diff --git a/Plugins/GME/GME.xcodeproj/project.pbxproj b/Plugins/GME/GME.xcodeproj/project.pbxproj index 5a10c0df5..5f4e20552 100644 --- a/Plugins/GME/GME.xcodeproj/project.pbxproj +++ b/Plugins/GME/GME.xcodeproj/project.pbxproj @@ -69,6 +69,7 @@ 17DA34B90CC052030003F6B2 /* GameMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameMetadataReader.m; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* GME_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GME_Prefix.pch; sourceTree = ""; }; 8384912E1808175400E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; + 83FAF8A518ADD4D100057CAF /* PlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaylistController.h; path = ../../Playlist/PlaylistController.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* GME.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GME.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -120,6 +121,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83FAF8A518ADD4D100057CAF /* PlaylistController.h */, 8384912E1808175400E7332D /* Logging.h */, 17C8F3470CBED3C7008D969D /* Plugin.h */, 17C8F33B0CBED3BE008D969D /* GameContainer.h */, diff --git a/Plugins/GME/GameDecoder.m b/Plugins/GME/GameDecoder.m index 774a50a37..cf268e67c 100755 --- a/Plugins/GME/GameDecoder.m +++ b/Plugins/GME/GameDecoder.m @@ -10,6 +10,8 @@ #import "Logging.h" +#import "PlaylistController.h" + @implementation GameDecoder gme_err_t readCallback( void* data, void* out, long count ) @@ -103,8 +105,6 @@ gme_err_t readCallback( void* data, void* out, long count ) return NO; } - gme_set_fade( emu, length, 8000 ); - length += 8000; @@ -134,6 +134,11 @@ gme_err_t readCallback( void* data, void* out, long count ) if (gme_track_ended(emu)) { return 0; } + + if ( IsRepeatOneSet() ) + gme_set_fade( emu, INT_MAX, 0 ); + else + gme_set_fade( emu, length - 8000, 8000 ); gme_play(emu, numSamples, (short int *)buf); diff --git a/Plugins/HighlyComplete/HighlyComplete.xcodeproj/project.pbxproj b/Plugins/HighlyComplete/HighlyComplete.xcodeproj/project.pbxproj index f41a5ccee..222877755 100644 --- a/Plugins/HighlyComplete/HighlyComplete.xcodeproj/project.pbxproj +++ b/Plugins/HighlyComplete/HighlyComplete.xcodeproj/project.pbxproj @@ -181,6 +181,7 @@ 83D4481B18ACA5AD000F443A /* lazyusf */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = lazyusf; path = ../../ThirdParty/lazyusf/lazyusf; sourceTree = ""; }; 83DE0C34180A9BD400269051 /* vio2sf.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = vio2sf.xcodeproj; path = ../../Frameworks/vio2sf/vio2sf.xcodeproj; sourceTree = ""; }; 83DE0CBF180B27C200269051 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + 83FAF8A318ADD27F00057CAF /* PlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaylistController.h; path = ../../../Playlist/PlaylistController.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -283,6 +284,7 @@ 8360EEED17F92AC8005208A4 /* HighlyComplete */ = { isa = PBXGroup; children = ( + 83FAF8A318ADD27F00057CAF /* PlaylistController.h */, 8324C584181513A10046F78F /* circular_buffer.h */, 834379A717F9818400584396 /* HCDecoder.mm */, 8343786117F944BD00584396 /* hebios.h */, diff --git a/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm b/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm index c17733d92..e95bac88b 100644 --- a/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm +++ b/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm @@ -34,6 +34,8 @@ #include +#import "PlaylistController.h" + // #define USF_LOG @interface psf_file_container : NSObject { @@ -1428,6 +1430,8 @@ static int usf_info(void * context, const char * name, const char * value) long frames_left = totalFrames - framesRead - silence_test_buffer.data_available() / 2; if ( partial ) frames_left = 1024; long free_space = silence_test_buffer.free_space() / 2; + if ( IsRepeatOneSet() ) + frames_left = free_space; if ( free_space > frames_left ) free_space = frames_left; while ( free_space > 0 ) @@ -1550,14 +1554,14 @@ static int usf_info(void * context, const char * name, const char * value) unsigned long written = silence_test_buffer.data_available() / 2; if ( written > frames ) written = frames; - if ( written > totalFrames - framesRead ) + if ( !IsRepeatOneSet() && written > totalFrames - framesRead ) written = totalFrames - framesRead; if ( written == 0 ) return 0; silence_test_buffer.read( (int16_t *) buf, written * 2 ); - if ( framesRead + written > framesLength ) { + if ( !IsRepeatOneSet() && framesRead + written > framesLength ) { long fadeStart = (framesLength > framesRead) ? framesLength : framesRead; long fadeEnd = framesRead + written; long fadeTotal = totalFrames - framesLength; diff --git a/Plugins/Hively/Hively.xcodeproj/project.pbxproj b/Plugins/Hively/Hively.xcodeproj/project.pbxproj index 9026aacf3..0cf21b187 100644 --- a/Plugins/Hively/Hively.xcodeproj/project.pbxproj +++ b/Plugins/Hively/Hively.xcodeproj/project.pbxproj @@ -47,6 +47,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 831C7F6918ADD73F00CE4A69 /* PlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaylistController.h; path = ../../../Playlist/PlaylistController.h; sourceTree = ""; }; 836FB52D1820538700B3AD2D /* Hively.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Hively.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 836FB5301820538700B3AD2D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 836FB5331820538700B3AD2D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -118,6 +119,7 @@ 836FB5361820538700B3AD2D /* Hively */ = { isa = PBXGroup; children = ( + 831C7F6918ADD73F00CE4A69 /* PlaylistController.h */, 836FB5A31820557E00B3AD2D /* Plugin.h */, 836FB59A1820556F00B3AD2D /* HVLDecoder.h */, 836FB59B1820556F00B3AD2D /* HVLDecoder.m */, diff --git a/Plugins/Hively/Hively/HVLDecoder.m b/Plugins/Hively/Hively/HVLDecoder.m index b1c8a2bdb..8283d0acf 100755 --- a/Plugins/Hively/Hively/HVLDecoder.m +++ b/Plugins/Hively/Hively/HVLDecoder.m @@ -8,6 +8,8 @@ #import "HVLDecoder.h" +#import "PlaylistController.h" + @implementation HVLDecoder void oneTimeInit() @@ -99,7 +101,9 @@ void oneTimeInit() - (int)readAudio:(void *)buf frames:(UInt32)frames { - if (framesRead >= totalFrames) + BOOL repeatone = IsRepeatOneSet(); + + if (!repeatone && framesRead >= totalFrames) return 0; int total = 0; @@ -128,7 +132,7 @@ void oneTimeInit() framesInBuffer = 44100 / 50; } - if ( framesRead + total > framesLength ) { + if ( !repeatone && framesRead + total > framesLength ) { long fadeStart = (framesLength > framesRead) ? framesLength : framesRead; long fadeEnd = (framesRead + total) > totalFrames ? totalFrames : (framesRead + total); long fadePos; diff --git a/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj b/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj index 6e4fd6b67..c70be6242 100644 --- a/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj +++ b/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj @@ -99,6 +99,7 @@ 83C35701180EDB74007E9DF0 /* MIDIContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIContainer.h; sourceTree = ""; }; 83C35703180EDD1C007E9DF0 /* MIDIMetadataReader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MIDIMetadataReader.mm; sourceTree = ""; }; 83C35704180EDD1C007E9DF0 /* MIDIMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIMetadataReader.h; sourceTree = ""; }; + 83FAF8A618ADD60100057CAF /* PlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaylistController.h; path = ../../../Playlist/PlaylistController.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -162,6 +163,7 @@ 83B06690180D5668008E3612 /* MIDI */ = { isa = PBXGroup; children = ( + 83FAF8A618ADD60100057CAF /* PlaylistController.h */, 83C35703180EDD1C007E9DF0 /* MIDIMetadataReader.mm */, 83C35704180EDD1C007E9DF0 /* MIDIMetadataReader.h */, 83C35700180EDB74007E9DF0 /* MIDIContainer.mm */, diff --git a/Plugins/MIDI/MIDI/MIDIDecoder.mm b/Plugins/MIDI/MIDI/MIDIDecoder.mm index 077a55f10..bebe191d3 100755 --- a/Plugins/MIDI/MIDI/MIDIDecoder.mm +++ b/Plugins/MIDI/MIDI/MIDIDecoder.mm @@ -14,6 +14,8 @@ #import +#import "PlaylistController.h" + @implementation MIDIDecoder + (NSInteger)testExtensions:(NSString *)pathMinusExtension extensions:(NSArray *)extensionsToTest @@ -148,7 +150,9 @@ - (int)readAudio:(void *)buf frames:(UInt32)frames { - if ( framesRead >= totalFrames ) + BOOL repeatone = IsRepeatOneSet(); + + if ( !repeatone && framesRead >= totalFrames ) return 0; if ( !soundFontsAssigned ) { @@ -163,7 +167,7 @@ player->Play( (float *) buf, frames ); - if ( framesRead + frames > framesLength ) { + if ( !repeatone && framesRead + frames > framesLength ) { if ( framesFade ) { long fadeStart = (framesLength > framesRead) ? framesLength : framesRead; long fadeEnd = (framesRead + frames > totalFrames) ? totalFrames : (framesRead + frames); diff --git a/Plugins/playptmod/playptmod.xcodeproj/project.pbxproj b/Plugins/playptmod/playptmod.xcodeproj/project.pbxproj index 334654ecf..3b5dcf6cd 100644 --- a/Plugins/playptmod/playptmod.xcodeproj/project.pbxproj +++ b/Plugins/playptmod/playptmod.xcodeproj/project.pbxproj @@ -58,6 +58,7 @@ 83A0F4DD1816D09000119DB4 /* ptmodDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ptmodDecoder.m; sourceTree = ""; }; 83A0F4DF1816D0AF00119DB4 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../../Audio/Plugin.h; sourceTree = ""; }; 83A0F4E01816D13000119DB4 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../../Utils/Logging.h; sourceTree = ""; }; + 83FAF8A718ADD65200057CAF /* PlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaylistController.h; path = ../../../Playlist/PlaylistController.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -113,6 +114,7 @@ 83A0F4781816CE5E00119DB4 /* playptmod */ = { isa = PBXGroup; children = ( + 83FAF8A718ADD65200057CAF /* PlaylistController.h */, 83A0F4E01816D13000119DB4 /* Logging.h */, 83A0F4DF1816D0AF00119DB4 /* Plugin.h */, 83A0F4DC1816D09000119DB4 /* ptmodDecoder.h */, diff --git a/Plugins/playptmod/playptmod/ptmodDecoder.m b/Plugins/playptmod/playptmod/ptmodDecoder.m index dfe324152..06d89b825 100755 --- a/Plugins/playptmod/playptmod/ptmodDecoder.m +++ b/Plugins/playptmod/playptmod/ptmodDecoder.m @@ -31,12 +31,23 @@ BOOL probe_length( unsigned long * intro_length, unsigned long * loop_length, in unsigned long length_total = 0; unsigned long length_saved; - while ( playptmod_LoopCounter( ptmod ) < 1 ) + const long length_safety = 44100 * 60 * 30; + + while ( playptmod_LoopCounter( ptmod ) < 1 && length_total < length_safety ) { playptmod_Render( ptmod, NULL, 512 ); length_total += 512; } + if ( playptmod_LoopCounter( ptmod ) < 1 ) + { + *loop_length = 0; + *intro_length = 44100 * 60 * 3; + playptmod_Stop( ptmod ); + playptmod_Free( ptmod ); + return YES; + } + length_saved = length_total; while ( playptmod_LoopCounter( ptmod ) < 2 )