http_send.c: Only pass the fd to host_in_access_perm_list().
[paraslash.git] / playlist.c
index c6f09bef78bb6e0712a81dea8b4e373788298aca..5dcac73cbb7c3adf7f77afecb4479b08d502b174 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2008 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -28,7 +28,7 @@ static struct playlist_info current_playlist;
  *
  * \return The return value of score_update().
  */
-int playlist_update_audio_file(struct osl_row *aft_row)
+static int playlist_update_audio_file(const struct osl_row *aft_row)
 {
        /* always re-insert to the top of the tree */
        return score_update(aft_row, 0);
@@ -41,12 +41,12 @@ static int add_playlist_entry(char *path, void *data)
        int ret = aft_get_row_of_path(path, &aft_row);
 
        if (ret < 0) {
-               PARA_NOTICE_LOG("%s: %s\n", path, PARA_STRERROR(-ret));
+               PARA_NOTICE_LOG("%s: %s\n", path, para_strerror(-ret));
                return 1;
        }
        ret = score_add(aft_row, -playlist->length);
        if (ret < 0) {
-               PARA_ERROR_LOG("failed to add %s: %s\n", path, PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("failed to add %s: %s\n", path, para_strerror(-ret));
                return ret;
        }
        playlist->length++;
@@ -80,7 +80,7 @@ static int load_playlist(struct osl_row *row, void *data)
 err:
        if (ret != -E_DUMMY_ROW)
                PARA_NOTICE_LOG("unable to load playlist (%s)\n",
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
        return 1;
 }
 
@@ -91,7 +91,7 @@ static int check_playlist_path(char *path, void *data)
        int ret = aft_get_row_of_path(path, &aft_row);
 
        if (ret < 0)
-               para_printf(pb, "%s: %s\n", path, PARA_STRERROR(-ret));
+               para_printf(pb, "%s: %s\n", path, para_strerror(-ret));
        return 1;
 }
 
@@ -104,7 +104,7 @@ static int check_playlist(struct osl_row *row, void *data)
 
        if (ret < 0) {
                para_printf(pb, "failed to get playlist data: %s\n",
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
                return 1;
        }
        if (*playlist_name) { /* skip dummy row */
@@ -223,12 +223,24 @@ static int handle_audio_file_event(enum afs_events event, void *data)
        return score_add(row, 0); /* play it immediately */
 }
 
-int playlists_event_handler(enum afs_events event, struct para_buffer *pb,
-               void *data)
+/**
+ * Handle afs events relevant to playlists.
+ *
+ * \param event The event type.
+ * \param pb Unused.
+ * \param data Depends on the event type.
+ *
+ * \return Standard.
+ */
+int playlists_event_handler(enum afs_events event,
+       __a_unused struct para_buffer *pb, void *data)
 {
        int ret;
+       struct afsi_change_event_data *aced = data;
 
        switch(event) {
+       case AFSI_CHANGE:
+               return playlist_update_audio_file(aced->aft_row);
        case AUDIO_FILE_RENAME:
        case AUDIO_FILE_ADD:
                return handle_audio_file_event(event, data);