diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index b5b9b4d7a6..83fea8c73c 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -218,7 +218,7 @@ void draw_playlist_viewer_list(struct gui_wps *gwps, struct playlistviewer *view int x, length, alignment = SKIN_TOKEN_ALIGN_LEFT; struct mp3entry *pid3; - char buf[MAX_PATH*2], tempbuf[MAX_PATH]; + char buf[MAX_PATH*2], tempbuf[MAX_PATH], filename_buf[MAX_PATH + 1]; const char *filename; #if CONFIG_TUNER if (current_screen() == GO_TO_FM) @@ -249,7 +249,8 @@ void draw_playlist_viewer_list(struct gui_wps *gwps, struct playlistviewer *view else #endif { - filename = playlist_peek(i-cur_pos); + filename = playlist_peek(i-cur_pos, filename_buf, + sizeof(filename_buf)); if (i == cur_pos) { pid3 = state->id3; diff --git a/apps/playback.c b/apps/playback.c index e8a6efc109..4c55c857bc 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1113,6 +1113,7 @@ static bool audio_loadcodec(bool start_play) actually loaded by the buffering thread. */ static bool audio_load_track(size_t offset, bool start_play) { + char name_buf[MAX_PATH + 1]; const char *trackname; int fd = -1; @@ -1140,7 +1141,8 @@ static bool audio_load_track(size_t offset, bool start_play) logf("Buffering track: r%d/w%d", track_ridx, track_widx); /* Get track name from current playlist read position. */ - while ((trackname = playlist_peek(last_peek_offset)) != NULL) + while ((trackname = playlist_peek(last_peek_offset, name_buf, + sizeof(name_buf))) != NULL) { /* Handle broken playlists. */ fd = open(trackname, O_RDONLY); diff --git a/apps/playlist.c b/apps/playlist.c index 2896f62e76..df39ecfd64 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -144,7 +144,6 @@ struct directory_search_context { }; static struct playlist_info current_playlist; -static char now_playing[MAX_PATH+1]; static void empty_playlist(struct playlist_info* playlist, bool resume); static void new_playlist(struct playlist_info* playlist, const char *dir, @@ -2456,7 +2455,7 @@ bool playlist_check(int steps) /* get trackname of track that is "steps" away from current playing track. NULL is used to identify end of playlist */ -const char* playlist_peek(int steps) +const char* playlist_peek(int steps, char* buf, size_t buf_size) { struct playlist_info* playlist = ¤t_playlist; int seek; @@ -2471,11 +2470,11 @@ const char* playlist_peek(int steps) control_file = playlist->indices[index] & PLAYLIST_INSERT_TYPE_MASK; seek = playlist->indices[index] & PLAYLIST_SEEK_MASK; - if (get_filename(playlist, index, seek, control_file, now_playing, - MAX_PATH+1) < 0) + if (get_filename(playlist, index, seek, control_file, buf, + buf_size) < 0) return NULL; - temp_ptr = now_playing; + temp_ptr = buf; if (!playlist->in_ram || control_file) { @@ -2494,7 +2493,7 @@ const char* playlist_peek(int steps) /* Even though this is an invalid file, we still need to pass a file name to the caller because NULL is used to indicate end of playlist */ - return now_playing; + return buf; } } diff --git a/apps/playlist.h b/apps/playlist.h index 3ff32c7682..fb30b7ac8c 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -127,7 +127,7 @@ int playlist_add(const char *filename); int playlist_shuffle(int random_seed, int start_index); void playlist_start(int start_index, int offset); bool playlist_check(int steps); -const char *playlist_peek(int steps); +const char *playlist_peek(int steps, char* buf, size_t buf_size); int playlist_next(int steps); bool playlist_next_dir(int direction); int playlist_get_resume_info(int *resume_index); diff --git a/apps/tree.c b/apps/tree.c index c2ec4ca3ec..f8874f684e 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -1075,6 +1075,7 @@ bool bookmark_play(char *resume_file, int index, int offset, int seed, lastdir[0]='\0'; if (playlist_create(resume_file, NULL) != -1) { + char filename_buf[MAX_PATH + 1]; const char* peek_filename; resume_directory(resume_file); if (global_settings.playlist_shuffle) @@ -1082,13 +1083,15 @@ bool bookmark_play(char *resume_file, int index, int offset, int seed, /* Check if the file is at the same spot in the directory, else search for it */ - peek_filename = playlist_peek(index); + peek_filename = playlist_peek(index, filename_buf, + sizeof(filename_buf)); if (peek_filename == NULL) { /* playlist has shrunk, search from the top */ index = 0; - peek_filename = playlist_peek(index); + peek_filename = playlist_peek(index, filename_buf, + sizeof(filename_buf)); if (peek_filename == NULL) return false; } @@ -1097,7 +1100,8 @@ bool bookmark_play(char *resume_file, int index, int offset, int seed, { for ( i=0; i < playlist_amount(); i++ ) { - peek_filename = playlist_peek(i); + peek_filename = playlist_peek(i, filename_buf, + sizeof(filename_buf)); if (peek_filename == NULL) return false;