]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aft.c
Move mmap_full_file from osl.c to fd.c.
[paraslash.git] / aft.c
diff --git a/aft.c b/aft.c
index d77d7eafac98ade6cd7ccadac571681e9afdfd11..aae6d66b0bfbd511fb7a7aabbf14f2c1dbab74a7 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -6,6 +6,7 @@
 
 /** \file aft.c Audio file table functions. */
 
+#include <dirent.h> /* readdir() */
 #include "para.h"
 #include "error.h"
 #include "string.h"
@@ -15,6 +16,7 @@
 #include "afs.h"
 #include "net.h"
 #include "vss.h"
+#include "fd.h"
 
 static struct osl_table *audio_file_table;
 
@@ -619,6 +621,7 @@ int open_and_update_audio_file(struct osl_row *aft_row, struct audio_file_data *
        struct osl_object afsi_obj;
        struct afs_info new_afsi;
        int ret = get_hash_of_row(aft_row, &aft_hash);
+       struct afsi_change_event_data aced;
 
        if (ret < 0)
                return ret;
@@ -637,7 +640,8 @@ int open_and_update_audio_file(struct osl_row *aft_row, struct audio_file_data *
        ret = get_chunk_table_of_row(aft_row, &afd->afhi);
        if (ret < 0)
                return ret;
-       ret = mmap_full_file(afd->path, O_RDONLY, &afd->map);
+       ret = mmap_full_file(afd->path, O_RDONLY, &afd->map.data,
+               &afd->map.size, NULL);
        if (ret < 0)
                goto err;
        hash_function(afd->map.data, afd->map.size, file_hash);
@@ -648,13 +652,11 @@ int open_and_update_audio_file(struct osl_row *aft_row, struct audio_file_data *
        new_afsi.num_played++;
        new_afsi.last_played = time(NULL);
        save_afsi(&new_afsi, &afsi_obj); /* in-place update */
-       if (afd->current_play_mode == PLAY_MODE_PLAYLIST)
-               ret = playlist_update_audio_file(aft_row);
-       else {
-               struct afsi_change_event_data aced = {.aft_row = aft_row,
-                       .old_afsi = &afd->afsi};
-               afs_event(AFSI_CHANGE, NULL, &aced);
-       }
+
+       aced.aft_row = aft_row;
+       aced.old_afsi = &afd->afsi;
+       afs_event(AFSI_CHANGE, NULL, &aced);
+
        return ret;
 err:
        free(afd->afhi.chunk_table);
@@ -1572,7 +1574,7 @@ static int add_one_audio_file(const char *path, const void *private_data)
                goto out_free;
        }
        /* We still want to add this file. Compute its hash. */
-       ret = mmap_full_file(path, O_RDONLY, &map);
+       ret = mmap_full_file(path, O_RDONLY, &map.data, &map.size, NULL);
        if (ret < 0)
                goto out_free;
        hash_function(map.data, map.size, hash);