From f20b10fdd4a85aa30789a690c5115b699f617bf0 Mon Sep 17 00:00:00 2001 From: areff Date: Tue, 19 Feb 2008 19:59:35 +0000 Subject: [PATCH] Most of the Repeat logic is in place (needs some brush up here and there). Still missing Repeat Album. Disabled some annoying debug output from MADDecoder. Updated KnownIssues. --- Application/PlaybackController.m | 14 +++++++++----- KnownIssues | 8 +++----- Playlist/PlaylistController.h | 1 + Playlist/PlaylistController.m | 26 +++++++++++++++++++++++--- Plugins/MAD/MADDecoder.m | 6 +++--- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index 95a058ac6..4c96849d4 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -489,11 +489,15 @@ if ([playlistController repeat] == RepeatOne) pe = curEntry; - // either this needs to be moved, or we need to determine a way to handle shuffle - // from here. - else if (([playlistController repeat] == RepeatAll) && - ([[curEntry index] intValue] == [[playlistController arrangedObjects]count]-1)) - pe = [playlistController entryAtIndex:0]; + + else if ([playlistController repeat] == RepeatAll) + { + if ([[curEntry index] intValue] == [[playlistController arrangedObjects] count] - 1) + if ([playlistController shuffle] == YES) + pe = [playlistController shuffledEntryAtIndex:0]; + else + pe = [playlistController entryAtIndex:0]; + } else pe = [playlistController getNextEntry:curEntry]; diff --git a/KnownIssues b/KnownIssues index c6b1403fe..97eceb5f6 100644 --- a/KnownIssues +++ b/KnownIssues @@ -6,11 +6,9 @@ so we can escape ugly event* functions (the problem is that the AppController needs access to seeker functions because of apple remote seeking incrementally) -Repeat state Repeat Album is missing. Repeat All is -naively implemented in the playbackController, and -does not heed Shuffle. +Shuffle list is not reshuffled when shuffling reaches +start or end of it (in Repeat All mode) -Shuffle parts of the playlistController need rewrite, -they still go by the old repeat code. +Repeat Album isn't implemented. mp3 bitrate is a tad off. diff --git a/Playlist/PlaylistController.h b/Playlist/PlaylistController.h index aa8036fb5..cc75a0241 100644 --- a/Playlist/PlaylistController.h +++ b/Playlist/PlaylistController.h @@ -85,6 +85,7 @@ typedef enum { - (void)addShuffledListToFront; - (void)resetShuffleList; +- (PlaylistEntry *)shuffledEntryAtIndex:(int)i; - (PlaylistEntry *)entryAtIndex:(int)i; @end diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index e146697fa..d0b5c3ef8 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -422,9 +422,20 @@ { PlaylistEntry *pe; - pe = [self getNextEntry:[self currentEntry]]; - if (pe == nil) + if (repeat == RepeatOne) return NO; + + pe = [self getNextEntry:[self currentEntry]]; + + /* needs to reshuffle playlist for added greatness */ + if (pe == nil) + { + // we are at end of shuffle list, and repeat all is requested + if ((shuffle = YES) && (repeat == RepeatAll)) + pe = [self shuffledEntryAtIndex:0]; + else + return NO; + } [self setCurrentEntry:pe]; @@ -435,9 +446,18 @@ { PlaylistEntry *pe; + if (repeat == RepeatOne) + return NO; + pe = [self getPrevEntry:[self currentEntry]]; if (pe == nil) - return NO; + { + // we are at end of shuffle list, and repeat all is requested + if ((shuffle = YES) && (repeat == RepeatAll)) + pe = [self shuffledEntryAtIndex:[shuffleList count]-1]; + else + return NO; + } [self setCurrentEntry:pe]; diff --git a/Plugins/MAD/MADDecoder.m b/Plugins/MAD/MADDecoder.m index 967fcb978..bf03e5476 100644 --- a/Plugins/MAD/MADDecoder.m +++ b/Plugins/MAD/MADDecoder.m @@ -311,7 +311,7 @@ int r; do { r = [self decodeMPEGFrame]; - NSLog(@"Decoding frame: %i", r); + NSLog(@"Decoding first frame: %i", r); } while (r == 0); return (r == -1 ? NO : YES); @@ -504,7 +504,7 @@ static inline signed int scale (mad_fixed_t sample) } else if (MAD_ERROR_BUFLEN == _stream.error) { - NSLog(@"Bufferlen"); + //NSLog(@"Bufferlen"); return 0; } else @@ -564,7 +564,7 @@ static inline signed int scale (mad_fixed_t sample) break; int r = [self decodeMPEGFrame]; - NSLog(@"Decoding frame: %i", r); + //NSLog(@"Decoding frame: %i", r); if (r == 0) //Recoverable error. continue; else if (r == -1) //Unrecoverable error