X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=playlist_selector.c;h=632e2a2a972c6aa386ff0a67417f554a62354bac;hb=c44b4b4d6b229e64389947ede9c4716969f2a780;hp=d0c64cc232d2b75b9abc524156e79a35e4252c2a;hpb=b661f91b340f1c5e2f58de2609d27c096a4fb711;p=paraslash.git diff --git a/playlist_selector.c b/playlist_selector.c index d0c64cc2..632e2a2a 100644 --- a/playlist_selector.c +++ b/playlist_selector.c @@ -1,25 +1,13 @@ /* * Copyright (C) 2006-2007 Andre Noll * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file playlist_selector.c The playlist audio file selector of paraslash */ #include "server.h" -#include "db.h" +#include "afs_common.h" #include "error.h" #include "net.h" #include "string.h" @@ -154,7 +142,7 @@ int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[]) unsigned i; PARA_DEBUG_LOG("sending playlist to client (%d entries)\n", playlist_len); - for (i = 0; i < playlist_len; i++) { + for (i = 1; i <= playlist_len; i++) { int ret = send_va_buffer(fd, "%s\n", playlist[ (i + current_playlist_entry) % playlist_len]); if (ret < 0) @@ -229,6 +217,7 @@ static void pls_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds) PARA_NOTICE_LOG("new playlist (%d entries)\n", playlist_len); sprintf(mmd->selector_info, "dbinfo1:new playlist: %d files\n" "dbinfo2:\ndbinfo3:\n", playlist_len); + current_playlist_entry = playlist_len - 1; pcd->retval = 1; pcd->size = 0; mutex_unlock(pcd->mutex); @@ -279,25 +268,27 @@ static void pls_update_audio_file(char *audio_file) /** * the init function for the playlist selector * - * Init all function pointers of \a db + * \param afs pointer to the struct to initialize + * + * Init all function pointers of \a afs * * \sa struct audio_file_selector, misc_meta_data::selector_info, mysql.c * random_selector.c. */ -int playlist_selector_init(struct audio_file_selector *db) +int playlist_selector_init(struct audio_file_selector *afs) { int ret; struct private_pls_data *ppd = NULL; void *shm = NULL; - self = db; - db->cmd_list = playlist_selector_cmds; - db->get_audio_file_list = pls_get_audio_file_list; - db->shutdown = pls_shutdown; - db->post_select = pls_post_select; - db->update_audio_file = pls_update_audio_file; + self = afs; + afs->cmd_list = playlist_selector_cmds; + afs->get_audio_file_list = pls_get_audio_file_list; + afs->shutdown = pls_shutdown; + afs->post_select = pls_post_select; + afs->update_audio_file = pls_update_audio_file; ppd = para_calloc(sizeof(struct private_pls_data)); - db->private_data = ppd; + afs->private_data = ppd; ppd->client_mutex = -1; ppd->server_mutex = -1;