Index: apps/codecs.c =================================================================== --- apps/codecs.c (revision 15975) +++ apps/codecs.c (working copy) @@ -165,6 +165,7 @@ event_wait, event_set_state, #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 15975) +++ 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); @@ -1443,7 +1443,7 @@ 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){ @@ -1675,12 +1675,13 @@ /* * 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') && @@ -1700,6 +1701,19 @@ 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); @@ -1732,6 +1746,8 @@ } } + if (playlist) + playlist->nsf_tracks[index] = nsf_track; return 0; } @@ -2503,6 +2519,12 @@ 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) @@ -3049,7 +3071,7 @@ /* 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; @@ -3400,6 +3422,7 @@ int result = 0; bool overwrite_current = false; int* index_buf = NULL; + char nsf_name[MAX_PATH+1]; if (!playlist) playlist = ¤t_playlist; @@ -3408,7 +3431,7 @@ 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; @@ -3471,6 +3494,13 @@ 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 15975) +++ apps/codecs.h (working copy) @@ -241,6 +241,7 @@ void (*event_wait)(struct event *e, unsigned int for_state); void (*event_set_state)(struct event *e, unsigned int state); #endif /* NUM_CORES */ + int (*get_nsf_track)(void); /* for NSF playlists */ }; /* codec header */ Index: apps/playlist.h =================================================================== --- apps/playlist.h (revision 15975) +++ apps/playlist.h (working copy) @@ -101,6 +101,7 @@ 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,5 +166,6 @@ 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 15975) +++ apps/playback.c (working copy) @@ -1146,6 +1146,11 @@ } } +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 */ @@ -2566,6 +2571,7 @@ ci.discard_codec = codec_discard_codec_callback; ci.dsp = (struct dsp_config *)dsp_configure(NULL, DSP_MYDSP, CODEC_IDX_AUDIO); + ci.get_nsf_track = codec_get_nsf_track; /* initialize the buffer */ filebuf = audiobuf; Index: apps/codecs/nsf.c =================================================================== --- apps/codecs/nsf.c (revision 15975) +++ apps/codecs/nsf.c (working copy) @@ -4319,6 +4319,7 @@ 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,6 +4368,7 @@ 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,17 +4387,27 @@ /* 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,20 +4462,20 @@ 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; }