X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=playlist.c;h=5cfe1a75196d5baf446507b21ee551044ecf446a;hb=b36883d75a07842740562eb654d5642914042d4b;hp=4b2d17c0b782bc677b69f08cac58402bfc3c0cb6;hpb=59a4f545566f77a22a8c27ece5155ecd154d4145;p=paraslash.git diff --git a/playlist.c b/playlist.c index 4b2d17c0..5cfe1a75 100644 --- a/playlist.c +++ b/playlist.c @@ -1,11 +1,8 @@ -/* - * Copyright (C) 2007 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2007 Andre Noll , see file COPYING. */ #include #include +#include #include "para.h" #include "error.h" @@ -131,26 +128,15 @@ static int check_playlist(struct osl_row *row, void *data) */ int playlist_check_callback(struct afs_callback_arg *aca) { - int ret; - struct para_buffer pb = { - .max_size = shm_get_shmmax(), - .private_data = &(struct afs_max_size_handler_data) { - .fd = aca->fd, - .band = SBD_OUTPUT - }, - .max_size_handler = afs_max_size_handler, - }; - para_printf(&pb, "checking playlists...\n"); - ret = osl(osl_rbtree_loop(playlists_table, BLOBCOL_ID, &pb, + para_printf(&aca->pbout, "checking playlists...\n"); + return osl(osl_rbtree_loop(playlists_table, BLOBCOL_ID, &aca->pbout, check_playlist)); - flush_and_free_pb(&pb); - return ret; } /** * Close the current playlist. * - * \sa playlist_open(). + * \sa \ref playlist_open(). */ void playlist_close(void) { @@ -161,26 +147,30 @@ void playlist_close(void) } /** - * Open the given playlist. + * Open and load the given playlist. * * \param name The name of the playlist to open. + * \param errmsg To be sent to the client (if called via select command). * * Files which are listed in the playlist, but not contained in the database * are ignored. This is not considered an error. * - * \return Standard. + * \return The length of the loaded playlist on success, negative error code + * else. */ -int playlist_open(char *name) +int playlist_open(const char *name, char **errmsg) { struct osl_object obj; int ret; struct osl_row *row; - obj.data = name; + obj.data = (char *)name; obj.size = strlen(obj.data); ret = osl(osl_get_row(playlists_table, BLOBCOL_NAME, &obj, &row)); if (ret < 0) { - PARA_NOTICE_LOG("failed to load playlist %s\n", name); + if (errmsg) + *errmsg = make_message("could not open playlist %s", + name); return ret; } playlist_close(); @@ -197,13 +187,12 @@ static int search_path(char *path, void *data) static int handle_audio_file_event(enum afs_events event, void *data) { - int ret, was_admissible = 0, is_admissible; + int ret; + bool was_admissible = false, is_admissible; struct osl_object playlist_def; char *new_path; const struct osl_row *row = data; - if (!current_playlist.name) - return 1; if (event == AUDIO_FILE_RENAME) { ret = row_belongs_to_score_table(row, NULL); if (ret < 0) @@ -248,7 +237,9 @@ int playlists_event_handler(enum afs_events event, int ret; struct afsi_change_event_data *aced = data; - switch(event) { + if (!current_playlist.name) + return 1; + switch (event) { case AFSI_CHANGE: return playlist_update_audio_file(aced->aft_row); case AUDIO_FILE_RENAME: