X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=afs.c;h=23ba2ad60cc9b133017ed006ce89ce2e91899808;hb=10596c5a763716368579b6313953ae0861b03ad4;hp=d9cddeb87b356103164bee70ddf2534122c7923a;hpb=05a15e80c5dae4f94c417210549d07a94a0acc16;p=paraslash.git diff --git a/afs.c b/afs.c index d9cddeb8..23ba2ad6 100644 --- 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: @@ -447,7 +447,6 @@ no_admissible_files: return write_all(server_socket, buf, 8); } -/* Never fails if arg == NULL */ static int activate_mood_or_playlist(const char *arg, int *num_admissible, char **errmsg) { @@ -455,8 +454,13 @@ static int activate_mood_or_playlist(const char *arg, int *num_admissible, int ret; if (!arg) { - ret = change_current_mood(NULL, NULL); /* always successful */ mode = PLAY_MODE_MOOD; + ret = change_current_mood(NULL, errmsg); + if (ret < 0) { + if (num_admissible) + *num_admissible = 0; + return ret; + } } else { if (!strncmp(arg, "p/", 2)) { ret = playlist_open(arg + 2); @@ -615,10 +619,10 @@ static void init_admissible_files(const char *arg) { int ret = activate_mood_or_playlist(arg, NULL, NULL); if (ret < 0) { - assert(arg); PARA_WARNING_LOG("could not activate %s: %s\n", arg, para_strerror(-ret)); - activate_mood_or_playlist(NULL, NULL, NULL); + if (arg) + activate_mood_or_playlist(NULL, NULL, NULL); } } @@ -1043,7 +1047,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; }