/** The number of entries currently in the playlist. */
unsigned length;
};
-static struct playlist_info playlist;
+static struct playlist_info current_playlist;
/**
* Re-insert an audio file into the tree of admissible files.
return score_update(aft_row, 0);
}
-static int add_playlist_entry(char *line, void *private_data)
+static int add_playlist_entry(char *line, void *data)
{
+ struct playlist_info *playlist = data;
struct osl_row *aft_row;
- struct playlist_info *pli = private_data;
int ret = aft_get_row_of_path(line, &aft_row);
if (ret < 0) {
line);
return 1;
}
- ret = score_add(aft_row, -pli->length);
+ ret = score_add(aft_row, -playlist->length);
if (ret < 0) {
PARA_ERROR_LOG("failed to add %s: %d\n", line, ret);
return ret;
}
- pli->length++;
+ playlist->length++;
return 1;
}
-static int load_playlist(struct osl_row *row)
+static int load_playlist(struct osl_row *row, struct playlist_info *playlist)
{
struct osl_object obj;
int ret;
ret = osl_get_object(playlists_table, row, BLOBCOL_NAME, &obj);
if (ret < 0)
return ret;
- playlist.name = para_strdup(obj.data);
- playlist.length = 0;
+ playlist->name = para_strdup(obj.data);
+ playlist->length = 0;
ret = osl_open_disk_object(playlists_table, row, BLOBCOL_DEF, &obj);
if (ret < 0)
goto err;
ret = for_each_line_ro(obj.data, obj.size, add_playlist_entry,
- &playlist);
+ playlist);
osl_close_disk_object(&obj);
if (ret < 0)
goto err;
ret = -E_PLAYLIST_EMPTY;
- if (!playlist.length)
+ if (!playlist->length)
goto err;
- PARA_NOTICE_LOG("loaded playlist %s (%u files)\n", playlist.name,
- playlist.length);
+ PARA_NOTICE_LOG("loaded playlist %s (%u files)\n", playlist->name,
+ playlist->length);
return 1;
err:
- free(playlist.name);
+ free(playlist->name);
return ret;
}
/* returns -E_PLAYLIST_LOADED on _success_ to terminate the loop */
-static int playlist_loop(struct osl_row *row, __a_unused void *private_data)
+static int playlist_loop(struct osl_row *row, void *data)
{
- int ret = load_playlist(row);
+ struct playlist_info *playlist = data;
+ int ret = load_playlist(row, playlist);
if (ret < 0) {
if (ret != -E_DUMMY_ROW)
PARA_NOTICE_LOG("unable to load playlist, trying next\n");
return -E_PLAYLIST_LOADED;
}
-static int load_first_available_playlist(void)
+static int load_first_available_playlist(struct playlist_info *playlist)
{
- int ret = osl_rbtree_loop(playlists_table, BLOBCOL_NAME, NULL,
+ int ret = osl_rbtree_loop(playlists_table, BLOBCOL_NAME, playlist,
playlist_loop);
if (ret == -E_PLAYLIST_LOADED) /* success */
return 1;
*/
void playlist_close(void)
{
- free(playlist.name);
- playlist.name = NULL;
+ free(current_playlist.name);
+ current_playlist.name = NULL;
}
/**
struct osl_row *row;
if (!name)
- return load_first_available_playlist();
+ return load_first_available_playlist(¤t_playlist);
obj.data = name;
obj.size = strlen(obj.data);
ret = osl_get_row(playlists_table, BLOBCOL_NAME, &obj, &row);
PARA_NOTICE_LOG("failed to load playlist %s\n", name);
return ret;
}
- return load_playlist(row);
+ return load_playlist(row, ¤t_playlist);
}