]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - afs.c
Remove unused error code E_OGG_STREAM_FLUSH.
[paraslash.git] / afs.c
diff --git a/afs.c b/afs.c
index 538606add432aef4710c09d5b2826df3d123c933..b6cce36f42e30cd5672d7e5cc9934cc2d659ca8f 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -366,8 +366,8 @@ int for_each_matching_row(struct pattern_match_data *pmd)
  */
 int string_compare(const struct osl_object *obj1, const struct osl_object *obj2)
 {
-       const char *str1 = (const char *)obj1->data;
-       const char *str2 = (const char *)obj2->data;
+       const char *str1 = obj1->data;
+       const char *str2 = obj2->data;
        return strncmp(str1, str2, PARA_MIN(obj1->size, obj2->size));
 }
 
@@ -418,13 +418,13 @@ static int pass_afd(int fd, char *buf, size_t size)
  */
 static int open_next_audio_file(void)
 {
-       struct audio_file_data afd;
-       int ret, shmid;
+       int ret, shmid, fd;
        char buf[8];
 
-       ret = open_and_update_audio_file(&afd);
+       ret = open_and_update_audio_file(&fd);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+               if (ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
+                       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                goto no_admissible_files;
        }
        shmid = ret;
@@ -434,8 +434,8 @@ static int open_next_audio_file(void)
        }
        *(uint32_t *)buf = NEXT_AUDIO_FILE;
        *(uint32_t *)(buf + 4) = (uint32_t)shmid;
-       ret = pass_afd(afd.fd, buf, 8);
-       close(afd.fd);
+       ret = pass_afd(fd, buf, 8);
+       close(fd);
        if (ret >= 0)
                return ret;
 destroy:
@@ -589,8 +589,9 @@ static int com_select_callback(struct afs_callback_arg *aca)
        para_printf(&aca->pbout, "activating dummy mood\n");
        activate_mood_or_playlist(NULL, &num_admissible, NULL);
 out:
-       para_printf(&aca->pbout, "activated %s (%d admissible files)\n",
-               current_mop? current_mop : "dummy mood", num_admissible);
+       para_printf(&aca->pbout, "activated %s (%d admissible file%s)\n",
+               current_mop? current_mop : "dummy mood", num_admissible,
+                       num_admissible == 1? "" : "s");
 free_lpr:
        lls_free_parse_result(aca->lpr, cmd);
        return ret;
@@ -638,16 +639,18 @@ static int setup_command_socket_or_die(void)
        return socket_fd;
 }
 
+static char *database_dir;
+
 static void close_afs_tables(void)
 {
        int i;
        PARA_NOTICE_LOG("closing afs_tables\n");
        for (i = 0; i < NUM_AFS_TABLES; i++)
                afs_tables[i].close();
+       free(database_dir);
+       database_dir = NULL;
 }
 
-static char *database_dir;
-
 static void get_database_dir(void)
 {
        if (!database_dir) {
@@ -1002,9 +1005,14 @@ __noreturn void afs_init(int socket_fd)
        }
        ret = schedule(&s);
        sched_shutdown(&s);
+       close_current_mood();
 out_close:
        close_afs_tables();
 out:
+       signal_shutdown(signal_task);
+       free_status_items();
+       free(current_mop);
+       free_lpr();
        if (ret < 0)
                PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        exit(EXIT_FAILURE);
@@ -1016,6 +1024,7 @@ static int com_init_callback(struct afs_callback_arg *aca)
        int i, ret;
 
        close_afs_tables();
+       get_database_dir();
        for (i = 0; i < NUM_AFS_TABLES; i++) {
                struct afs_table *t = &afs_tables[i];
 
@@ -1034,7 +1043,8 @@ static int com_init_callback(struct afs_callback_arg *aca)
        }
        ret = open_afs_tables();
        if (ret < 0)
-               para_printf(&aca->pbout, "cannot open afs tables\n");
+               para_printf(&aca->pbout, "cannot open afs tables: %s\n",
+                       para_strerror(-ret));
 out:
        return ret;
 }