Mark some unused variables as such.
[paraslash.git] / playlist.c
index 56e19fed307459fb7fd487bfa82c02db7c7b2f8b..62fd831acfa1bff04097b59dad33b3b22cee41f6 100644 (file)
@@ -1,3 +1,9 @@
+/*
+ * Copyright (C) 2007 Andre Noll <maan@systemlinux.org>
+ *
+ * Licensed under the GPL v2. For licencing details see COPYING.
+ */
+
 #include "para.h"
 #include "error.h"
 #include "string.h"
 #include "para.h"
 #include "error.h"
 #include "string.h"
@@ -78,18 +84,6 @@ err:
        return 1;
 }
 
        return 1;
 }
 
-static int load_first_available_playlist(struct playlist_info *playlist)
-{
-       int ret = osl_rbtree_loop(playlists_table, BLOBCOL_NAME, playlist,
-               load_playlist);
-       if (ret == -E_PLAYLIST_LOADED) /* success */
-               return 1;
-       if (ret < 0)
-               return ret; /* error */
-       PARA_NOTICE_LOG("no valid playlist found\n");
-       return -E_NO_PLAYLIST;
-}
-
 static int check_playlist_path(char *path, void *data)
 {
        struct para_buffer *pb = data;
 static int check_playlist_path(char *path, void *data)
 {
        struct para_buffer *pb = data;
@@ -150,6 +144,8 @@ int playlist_check_callback(__a_unused const struct osl_object *query,
  */
 void playlist_close(void)
 {
  */
 void playlist_close(void)
 {
+       if (!current_playlist.name)
+               return;
        free(current_playlist.name);
        current_playlist.name = NULL;
 }
        free(current_playlist.name);
        current_playlist.name = NULL;
 }
@@ -159,12 +155,10 @@ void playlist_close(void)
  *
  * \param name The name of the playlist to open.
  *
  *
  * \param name The name of the playlist to open.
  *
- * If name is \p NULL, load the first available playlist. Files which are
- * listed in the playlist, but not contained in the database are ignored.
- * This is not considered an error.
+ * Files which are listed in the playlist, but not contained in the database
+ * are ignored.  This is not considered an error.
  *
  *
- * \return Positive on success, negative on errors. Possible errors
- * include: Given playlist not found, -E_NO_PLAYLIST (no playlist defined).
+ * \return Standard.
  */
 int playlist_open(char *name)
 {
  */
 int playlist_open(char *name)
 {
@@ -172,8 +166,6 @@ int playlist_open(char *name)
        int ret;
        struct osl_row *row;
 
        int ret;
        struct osl_row *row;
 
-       if (!name)
-               return load_first_available_playlist(&current_playlist);
        obj.data = name;
        obj.size = strlen(obj.data);
        ret = osl_get_row(playlists_table, BLOBCOL_NAME, &obj, &row);
        obj.data = name;
        obj.size = strlen(obj.data);
        ret = osl_get_row(playlists_table, BLOBCOL_NAME, &obj, &row);
@@ -181,8 +173,9 @@ int playlist_open(char *name)
                PARA_NOTICE_LOG("failed to load playlist %s\n", name);
                return ret;
        }
                PARA_NOTICE_LOG("failed to load playlist %s\n", name);
                return ret;
        }
+       playlist_close();
        ret = load_playlist(row, &current_playlist);
        ret = load_playlist(row, &current_playlist);
-       return (ret == -E_PLAYLIST_LOADED)? 1 : ret;
+       return (ret == -E_PLAYLIST_LOADED)? current_playlist.length : ret;
 }
 
 static int search_path(char *path, void *data)
 }
 
 static int search_path(char *path, void *data)
@@ -230,8 +223,8 @@ static int handle_audio_file_event(enum afs_events event, void *data)
        return score_add(row, 0); /* play it immediately */
 }
 
        return score_add(row, 0); /* play it immediately */
 }
 
-int playlists_event_handler(enum afs_events event, struct para_buffer *pb,
-               void *data)
+int playlists_event_handler(enum afs_events event,
+       __a_unused struct para_buffer *pb, void *data)
 {
        int ret;
 
 {
        int ret;