Index: apps/codecs.c =================================================================== --- apps/codecs.c (revision 15412) +++ apps/codecs.c (working copy) @@ -158,0 +158,0 @@ /* new stuff at the end, sort into place next time the API gets incompatible */ - #ifdef CACHE_FUNCTIONS_AS_CALL flush_icache, invalidate_icache, #endif + NULL /* get_nsf_track */ }; void codec_get_full_path(char *path, const char *codec_root_fn) Index: apps/playlist.c =================================================================== --- apps/playlist.c (revision 15412) +++ apps/playlist.c (working copy) @@ -178,7 +178,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion); static int get_previous_directory(char *dir); static int check_subdir_for_music(char *dir, char *subdir); -static int format_track_path(char *dest, char *src, int buf_length, int max, +static int format_track_path(struct playlist_info* playlist, int index, char *dest, char *src, int buf_length, int max, char *dir); static void display_playlist_count(int count, const unsigned char *fmt, bool final); @@ -1401,2 +1401,2 @@ strncpy(dir_buf, playlist->filename, playlist->dirlen-1); dir_buf[playlist->dirlen-1] = 0; - return (format_track_path(buf, tmp_buf, buf_length, max, dir_buf)); + return (format_track_path(playlist, index, buf, tmp_buf, buf_length, max, dir_buf)); } static int get_next_directory(char *dir){ @@ -1633,9 +1633,10 @@ /* * Returns absolute path of track */ -static int format_track_path(char *dest, char *src, int buf_length, int max, +static int format_track_path(struct playlist_info* playlist, int index, char *dest, char *src, int buf_length, int max, char *dir) { int i = 0; int j; char *temp_ptr; + int nsf_track = -1; /* to be parsed if NSF playlist, left -1 if not */ /* Zero-terminate the file name */ while((src[i] != '\n') && @@ -1658,2 +1659,2 @@ if ( src[j] == '\\' ) src[j] = '/'; + if (strncmp(src,"nsf://",6) == 0) { /* working with a nsfe playlist */ + /* format is nsf://##:filename */ + strncpy(src, src+6,i); /* strip nsf:// */ + + temp_ptr = strchr(src,':'); + if (temp_ptr) + *temp_ptr = '\0'; + nsf_track = atoi(src); /* get track number */ + /*printf ("Number is %d",nsf_track);*/ + + strncpy(src, temp_ptr+1,i); /* get filename */ + } + if('/' == src[0]) { strncpy(dest, src, buf_length); @@ -1690,2 +1704,2 @@ } } + if (playlist) + playlist->nsf_tracks[index] = nsf_track; return 0; } @@ -2461,2 +2477,2 @@ return (index >= 0); } +int playlist_get_nsf_track(void) +{ + struct playlist_info* playlist = ¤t_playlist; + return playlist->nsf_tracks[playlist->index]; +} + /* get trackname of track that is "steps" away from current playing track. NULL is used to identify end of playlist */ char* playlist_peek(int steps) @@ -2992,0 +3014,0 @@ /* we need to format so that relative paths are correctly handled */ - if (format_track_path(trackname, temp_buf, sizeof(trackname), max, + if (format_track_path(NULL,1,trackname, temp_buf, sizeof(trackname), max, dir) < 0) { result = -1; @@ -3343,3 +3365,4 @@ int result = 0; bool overwrite_current = false; int* index_buf = NULL; + char nsf_name[MAX_PATH+1]; if (!playlist) playlist = ¤t_playlist; @@ -3351,1 +3374,1 @@ return -1; /* use current working directory as base for pathname */ - if (format_track_path(path, filename, sizeof(tmp_buf), + if (format_track_path(NULL,1,path, filename, sizeof(tmp_buf), strlen(filename)+1, getcwd(NULL, -1)) < 0) return -1; @@ -3414,2 +3437,2 @@ break; } + if (playlist->nsf_tracks[index] >= 0) + { + snprintf(nsf_name,sizeof(tmp_buf)+12, "nsf://%d:%s", + playlist->nsf_tracks[index],tmp_buf); + strncpy(tmp_buf,nsf_name,sizeof(nsf_name)); + } + if (overwrite_current) index_buf[count] = lseek(fd, 0, SEEK_CUR); Index: apps/codecs.h =================================================================== --- apps/codecs.h (revision 15412) +++ apps/codecs.h (working copy) @@ -234,4 +234,5 @@ void (*flush_icache)(void); void (*invalidate_icache)(void); #endif + int (*get_nsf_track)(void); /* for NSF playlists */ }; /* codec header */ Index: apps/playlist.h =================================================================== --- apps/playlist.h (revision 15412) +++ apps/playlist.h (working copy) @@ -101,1 +101,1 @@ bool pending_control_sync; /* control file needs to be synced */ struct mutex control_mutex; /* mutex for control file access */ + int nsf_tracks[10000]; /* how do I get the current max playlist size? */ }; struct playlist_track_info @@ -165,3 +166,4 @@ int (*callback)(char*, void*), void* context); int remove_all_tracks(struct playlist_info *playlist); +int playlist_get_nsf_track(void); #endif /* __PLAYLIST_H__ */ Index: apps/playback.c =================================================================== --- apps/playback.c (revision 15412) +++ apps/playback.c (working copy) @@ -1690,2 +1690,2 @@ } } +int codec_get_nsf_track(void) +{ + return playlist_get_nsf_track(); +} + static inline void codec_gapless_track_change(void) { /* callback keeps the progress bar moving while the pcmbuf empties */ @@ -3200,3 +3205,4 @@ ci.set_offset = codec_set_offset_callback; ci.configure = codec_configure_callback; ci.discard_codec = codec_discard_codec_callback; + ci.get_nsf_track = codec_get_nsf_track; /* Initialize voice codec api. */ #ifdef PLAYBACK_VOICE Index: apps/codecs/nsf.c =================================================================== --- apps/codecs/nsf.c (revision 15412) +++ apps/codecs/nsf.c (working copy) @@ -4319,3 +4319,4 @@ int dontresettrack; char last_path[MAX_PATH]; int usingplaylist; + int nsf_track = -1; /* Track to be forced by playlist */ /* we only render 16 bits */ ci->configure(DSP_SET_SAMPLE_DEPTH, 16); @@ -4367,2 +4368,2 @@ if(!LoadNSF(nDataBufferSize)) { DEBUGF("NSF: LoadNSF failed\n"); return CODEC_ERROR;} + nsf_track = ci->get_nsf_track(); /* If playlist, force this track */ ci->id3->title=szGameTitle; ci->id3->artist=szArtist; ci->id3->album=szCopyright; @@ -4385,16 +4387,26 @@ /* decide to use the playlist */ usingplaylist=1; track=0; - set_codec_track(nPlaylist[0],0); + if (nsf_track < 0) + set_codec_track(nPlaylist[0],0); + else set_codec_track(nsf_track,nsf_track); } else { /* simply use the initial track */ track=nInitialTrack; - set_codec_track(track,track); + if (nsf_track < 0) + set_codec_track(track,track); + else set_codec_track(nsf_track,nsf_track); } } else { /* if we've already been running this file assume track is set already */ - if (usingplaylist) set_codec_track(nPlaylist[track],track); - else set_codec_track(track,track); + if (usingplaylist) + if (nsf_track < 0) + set_codec_track(nPlaylist[track],track); + else set_codec_track(nsf_track,nsf_track); + else + if (nsf_track < 0) + set_codec_track(track,track); + else set_codec_track(nsf_track,nsf_track); } strcpy(last_path,ci->id3->path); @@ -4419,6 +4431,7 @@ } else { if (track>=nTrackCount) break; } + if (nsf_track >= 0) break; ci->seek_complete(); dontresettrack=1; goto init_nsf; @@ -4438,6 +4451,7 @@ } else { if (track>=nTrackCount) break; } + if (nsf_track >= 0) break; dontresettrack=1; goto init_nsf; } @@ -4448,1 +4462,1 @@ print_timers(last_path,track); if (ci->request_next_track()) { - if (ci->global_settings->repeat_mode==REPEAT_ONE) { + if (ci->global_settings->repeat_mode==REPEAT_ONE) { /* in repeat one mode just advance to the next track */ track++; if (track>=nTrackCount) track=0; dontresettrack=1; /* at this point we can't tell if another file has been selected */ goto next_track; - } else { + } else { /* otherwise do a proper load of the next file */ dontresettrack=0; last_path[0]='\0'; + } + goto next_track; /* when we fall through here we'll reload the file */ } - goto next_track; /* when we fall through here we'll reload the file */ - } return CODEC_OK; }