summaryrefslogtreecommitdiff
path: root/firmware/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/playlist.c')
-rw-r--r--firmware/playlist.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/firmware/playlist.c b/firmware/playlist.c
index 67b7834449..50d7313136 100644
--- a/firmware/playlist.c
+++ b/firmware/playlist.c
@@ -31,7 +31,7 @@
31 */ 31 */
32int reload_playlist_info( playlist_info_t *playlist ) 32int reload_playlist_info( playlist_info_t *playlist )
33{ 33{
34 debug( "reload_playlist_info()\n" ); 34 DEBUGF( "reload_playlist_info()\n" );
35 35
36 /* this is a TEMP stub version */ 36 /* this is a TEMP stub version */
37 37
@@ -60,22 +60,16 @@ int reload_playlist_info( playlist_info_t *playlist )
60void load_playlist( playlist_info_t *playlist, const char *filename ) { 60void load_playlist( playlist_info_t *playlist, const char *filename ) {
61 61
62 char *m3u_buf = NULL; 62 char *m3u_buf = NULL;
63 char debug_message[128];
64 63
65 snprintf( debug_message, sizeof(debug_message), 64 DEBUGF( "load_playlist( %s )\n", filename );
66 "load_playlist( %s )\n", filename );
67 debug( debug_message );
68 65
69 /* read file */ 66 /* read file */
70
71 read_file_into_buffer( &m3u_buf, filename ); 67 read_file_into_buffer( &m3u_buf, filename );
72 68
73 /* store playlist filename */ 69 /* store playlist filename */
74
75 strncpy( playlist->filename, filename, sizeof(playlist->filename) ); 70 strncpy( playlist->filename, filename, sizeof(playlist->filename) );
76 71
77 /* add track indices to playlist data structure */ 72 /* add track indices to playlist data structure */
78
79 add_indices_to_playlist( m3u_buf, playlist ); 73 add_indices_to_playlist( m3u_buf, playlist );
80} 74}
81 75
@@ -84,7 +78,7 @@ void load_playlist( playlist_info_t *playlist, const char *filename ) {
84 */ 78 */
85void empty_playlist( playlist_info_t *playlist ) { 79void empty_playlist( playlist_info_t *playlist ) {
86 80
87 debug( "empty_playlist()\n" ); 81 DEBUGF( "empty_playlist()\n" );
88 82
89 playlist->filename[0] = '\0'; 83 playlist->filename[0] = '\0';
90 playlist->indices_count = 0; 84 playlist->indices_count = 0;
@@ -101,7 +95,7 @@ void add_indices_to_playlist( char *buf, playlist_info_t *playlist )
101 char *p; 95 char *p;
102 int i = 0; 96 int i = 0;
103 97
104 /*debug( "add_indices_to_playlist()\n" ); */ 98 /*DEBUGF( "add_indices_to_playlist()\n" ); */
105 99
106 p = buf; 100 p = buf;
107 101
@@ -141,8 +135,7 @@ void add_indices_to_playlist( char *buf, playlist_info_t *playlist )
141 */ 135 */
142void extend_indices( playlist_info_t *playlist, int new_index ) 136void extend_indices( playlist_info_t *playlist, int new_index )
143{ 137{
144 /*sprintf( debug_message, "extend_indices(%d)\n", new_index ); 138 /*DEBUGF( "extend_indices(%d)\n", new_index ); */
145 debug( debug_message );*/
146 139
147 /* increase array size count */ 140 /* increase array size count */
148 141
@@ -157,8 +150,8 @@ void extend_indices( playlist_info_t *playlist, int new_index )
157 playlist->indices[ playlist->indices_count - 1 ] = new_index; 150 playlist->indices[ playlist->indices_count - 1 ] = new_index;
158} 151}
159 152
160track_t next_playlist_track( playlist_info_t *playlist ) { 153track_t next_playlist_track( playlist_info_t *playlist )
161 154{
162 track_t track; 155 track_t track;
163 strncpy( track.filename, "boogie", sizeof(track.filename) ); 156 strncpy( track.filename, "boogie", sizeof(track.filename) );
164 return track; 157 return track;
@@ -167,8 +160,8 @@ track_t next_playlist_track( playlist_info_t *playlist ) {
167/* 160/*
168 * randomly rearrange the array of indices for the playlist 161 * randomly rearrange the array of indices for the playlist
169 */ 162 */
170void randomise_playlist( playlist_info_t *playlist ) { 163void randomise_playlist( playlist_info_t *playlist )
171 164{
172 unsigned seed; 165 unsigned seed;
173 int count = 0; 166 int count = 0;
174 int candidate; 167 int candidate;
@@ -178,7 +171,7 @@ void randomise_playlist( playlist_info_t *playlist ) {
178 int *randomised_list; 171 int *randomised_list;
179 int i; 172 int i;
180 173
181 debug( "randomise_playlist()\n" ); 174 DEBUGF( "randomise_playlist()\n" );
182 175
183 /* create dynamic storage for randomised list so it can be freed later */ 176 /* create dynamic storage for randomised list so it can be freed later */
184 177
@@ -279,7 +272,7 @@ int is_unused_random_in_list( int number, int *new_list, int count )
279 */ 272 */
280void display_playlist_track( track_t *track ) 273void display_playlist_track( track_t *track )
281{ 274{
282 debugf( "track: %s\n", track->filename ); 275 DEBUGF( "track: %s\n", track->filename );
283} 276}
284 277
285/* 278/*
@@ -290,14 +283,14 @@ void display_current_playlist( playlist_info_t *playlist )
290 char indices[2048]; 283 char indices[2048];
291 indices[0]='\0'; 284 indices[0]='\0';
292 285
293 /*debug( "\ndisplay_current_playlist()\n" ); */ 286 /*DEBUGF( "\ndisplay_current_playlist()\n" ); */
294 287
295 if( playlist->indices_count != 0 ) 288 if( playlist->indices_count != 0 )
296 { 289 {
297 get_indices_as_string( indices, playlist ); 290 get_indices_as_string( indices, playlist );
298 } 291 }
299 292
300 debugf( "\nfilename:\t%s\ntotal:\t\t%d\nindices:\t%s\ncurrent index:\t%d\n\n", 293 DEBUGF( "\nfilename:\t%s\ntotal:\t\t%d\nindices:\t%s\ncurrent index:\t%d\n\n",
301 playlist->filename, 294 playlist->filename,
302 playlist->indices_count, 295 playlist->indices_count,
303 indices, 296 indices,
@@ -313,7 +306,7 @@ void get_indices_as_string( char *string, playlist_info_t *playlist )
313 int count = 0; 306 int count = 0;
314 int *p = playlist->indices; 307 int *p = playlist->indices;
315 308
316 /*debug( "get_indices_as_string()\n" ); */ 309 /*DEBUGF( "get_indices_as_string()\n" ); */
317 310
318 while( count < playlist->indices_count ) { 311 while( count < playlist->indices_count ) {
319 312