# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-#INPUT = net.c signal.c db.h db.c ringbuffer.c ringbuffer.h stat.c afs.c afs.h string.c net.h filter.h filter_chain.c error.h recv.h http_recv.c ortp_recv.c recv_common.c http.h mp3dec.c oggdec.c ortp.h wav.c compress.c daemon.c daemon.h grab_client.c grab_client.h close_on_fork.c close_on_fork.h audiod.c audiod.h time.c mysql.c server.h command.c server.c send.h http_send.c ortp_send.c http.h ortp.h mp3.c ogg.c dopey.c string.h exec.c
-
INPUT = .
# If the value of the INPUT tag contains directories, you can use the
small memory footprint:
~~~~~~~~~~~~~~~~~~~~~~~
paraslash is lightweight. The stripped binary of para_server
- with all its features compiled in (mysql/dopey dbtool,
+ with all its features compiled in (mysql/random dbtool,
mp3/ogg support, http/ortp support) is about 100K on i386
under Linux. para_audiod is even smaller.
various user interfaces and utilities:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o para_gui. Curses based interface, displays information in a
- curses window and can be used to easily control para_server
+ curses window and can be used to easily control para_server
and para_audiod.
o para_sdl_gui. Shows pictures (on a per song basis) and
Choose your database tool (dbtool)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-You have three options:
+You have two options:
1. Use the mysql dbtool which comes with paraslash and requires
- mysql. This is recommended.
+ mysql.
- 2. Use your own database tool. If you have that already,
- skip this step.
-
- 3. If you can not use the mysql dbtool and you just want
- to quickly make paraslash working, use the dopey dbtool.
+ 2. If you can not use the mysql dbtool and you just want
+ to quickly make paraslash working, use the random dbtool.
The directory which is searched for audio files can be given
- via the server option --dopey_dir.
-
- Note, however, that dopey is _really_ dopey. It scans
- $dopey_dir on every audio file change and chooses one
- randomly. You get the idea. Have a look at its source code
- and feel free to modify.
+ via the server option --random_dbtool_dir.
+ Note, however, that this database tool is really dopey. It
+ scans the given directory on every audio file change and
+ chooses one randomly. There is no further functionality.
The current database tool can be changed at runtime via
para_server needs a database tool to work, mainly to determine
which song to stream next. There are two database tools
- available: mysql and dopey. The former is recommended as dopey
- is only meant as a fallback and as a starting point for people
- that want to write their own database tool for paraslash.
+ available: mysql and random. The former is recommended as
+ the random database tool is only meant as a fallback and
+ as a starting point for people that want to write their own
+ database tool for paraslash.
The mysql database tool connects to a mysql server which
holds information on your audio files. It has several unusual
para_client cdt
-which prints the name of the current database tool. If the dopey
-dbtool is still selected, try
+which prints the name of the current database tool. If the mysql
+dbtool is not selected, try
para_client cdt mysql
audiod_ldflags=""
server_cmdline_objs="server.cmdline"
-server_errlist_objs="server mp3 afs command net string signal dopey time daemon stat
+server_errlist_objs="server mp3 afs command net string signal random_dbtool time daemon stat
crypt http_send db close_on_fork"
server_ldflags=""
};
int mysql_dbtool_init(struct dbtool*);
-int dopey_dbtool_init(struct dbtool*);
+int random_dbtool_init(struct dbtool*);
+++ /dev/null
-/*
- * Copyright (C) 2004-2006 Andre Noll <maan@systemlinux.org>
- *
- * 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.
- */
-
-/** \file dopey.c Simple database tool implementation. Feel free to modify. */
-
-#include <sys/time.h> /* gettimeofday */
-#include "server.cmdline.h"
-#include "server.h"
-#include "db.h"
-#include "error.h"
-#include "net.h"
-#include "string.h"
-
-static int com_dopey(int, int, char **);
-extern struct gengetopt_args_info conf;
-extern struct misc_meta_data *mmd;
-
-static unsigned int num_audio_files, audio_file_count;
-static char **audio_file_list;
-
-static int count_audio_files(__unused const char *dir, __unused const char *name)
-{
- num_audio_files++;
- return 1;
-}
-
-static int remember_file(const char *dir, const char *name)
-{
- if (audio_file_count >= num_audio_files)
- return -E_FILE_COUNT;
- audio_file_list[audio_file_count] = make_message("%s/%s", dir, name);
- audio_file_count++;
- return 1;
-}
-
-/* array of commands that are supported by this database tool */
-static struct server_command cmds[] = {
-{
-.name = "dopey",
-.handler = com_dopey,
-.perms = 0,
-.description = "about the dopey database tool",
-.synopsis = "dopey",
-.help =
-
-"It's so dumb. It hurts. Don't use it; switch to the mysql database\n"
-"tool instead. OTOH: You typed 'help dopey', so if you serious about\n"
-"that and you really intend to help the dopey database tool, look at\n"
-"my source code, dopey.c, and modify it to make it something useful.\n"
-
-}, {
-.name = NULL,
-}
-};
-
-static int com_dopey(int fd, __unused int argc, __unused char *argv[])
-{
- return send_buffer(fd, "Please do not use me. I'm too sick to do "
- "anything for you. Switch me off. Now!\n");
-}
-
-/*
- * Load a list of all audio files into memory and chose num of them randomly.
- * Called by server to determine next audio file to be streamed.
- */
-static char **dopey_get_audio_file_list(unsigned int num)
-{
- int i, ret;
- unsigned int len;
- char **ret_list = NULL; /* what we are going to return */
-
- audio_file_list = NULL;
- num_audio_files = 0;
- /* first run, just count all audio files. dopey */
- ret = find_audio_files(conf.dopey_dir_arg, count_audio_files);
- if (ret < 0)
- goto out;
- ret = -E_NOTHING_FOUND;
- if (!num_audio_files)
- goto out;
- /* yeah, that doesn't scale, also dopey */
- audio_file_list = para_malloc(num_audio_files * sizeof(char *));
- audio_file_count = 0;
- /* second run (hot dentry cache, hopefully), fill audio_file_list */
- ret = find_audio_files(conf.dopey_dir_arg, remember_file);
- if (ret < 0)
- goto out;
- /* careful, files might got deleted underneath */
- num_audio_files = audio_file_count; /* can only decrease */
- len = MIN(num, num_audio_files);
- ret = -E_NOTHING_FOUND;
- if (!len) /* nothing found, return NULL */
- goto out;
- /* success, return NULL-terminated list */
- ret_list = para_calloc((len + 1) * sizeof(char *));
- for (i = 0; i < len; i++) { /* choose randomly */
- int r = (int) ((num_audio_files + 0.0) * (rand()
- / (RAND_MAX + 1.0)));
- ret_list[i] = para_strdup(audio_file_list[r]);
- }
-out:
- if (audio_file_list) {
- for (i = 0; i < num_audio_files; i++)
- free(audio_file_list[i]);
- free(audio_file_list);
- }
-// if (ret < 0)
-// PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
- return ret_list;
-}
-
-static void dopey_shutdown(void)
-{
- PARA_DEBUG_LOG("%s", "thanks for using another dbtool.\n");
-}
-
-/** dopey's (constant) database info text */
-#define DBINFO "dbinfo1:database info? You're kidding. I'm dopey!\ndbinfo2:\ndbinfo3:\n"
-
-/** the dopey init function
- *
- * Init all function pointers of \a db, init the dbinfo text and seed the
- * PRNG.
- *
- * \sa struct dbtool, misc_meta_data::dbinfo, mysql.c
- */
-int dopey_dbtool_init(struct dbtool *db)
-{
- struct timeval now;
-
- PARA_INFO_LOG("%s", "registering dopey handlers\n");
- sprintf(mmd->dbinfo, DBINFO);
- gettimeofday(&now, NULL);
- srand(now.tv_usec);
- db->cmd_list = cmds;
- db->get_audio_file_list = dopey_get_audio_file_list;
- db->shutdown = dopey_shutdown;
- return 1;
-}
SS_NET, SS_ORTP_RECV, SS_AUDIOD, SS_EXEC, SS_CLOSE_ON_FORK, SS_SIGNAL,
SS_STRING, SS_DAEMON, SS_STAT, SS_TIME, SS_GRAB_CLIENT, SS_HTTP_RECV,
SS_RECV_COMMON, SS_FILTER_CHAIN, SS_WAV, SS_COMPRESS, SS_OGGDEC, SS_FILTER,
- SS_COMMAND, SS_DOPEY, SS_CRYPT, SS_HTTP_SEND, SS_ORTP_SEND, SS_DB, SS_OGG,
+ SS_COMMAND, SS_RANDOM_DBTOOL, SS_CRYPT, SS_HTTP_SEND, SS_ORTP_SEND, SS_DB, SS_OGG,
SS_MP3, SS_MP3DEC, SS_SERVER, SS_AFS, SS_MYSQL, SS_RINGBUFFER};
#define NUM_SS (SS_RINGBUFFER + 1)
extern const char **para_errlist[];
PARA_ERROR(WRITE_OK, "can not check whether fd is writable"), \
-#define DOPEY_ERRORS \
+#define RANDOM_DBTOOL_ERRORS \
PARA_ERROR(FILE_COUNT, "audio file count exceeded"), \
PARA_ERROR(NOTHING_FOUND, "no audio files found"), \
SS_ENUM(SERVER);
SS_ENUM(AFS);
SS_ENUM(COMMAND);
-SS_ENUM(DOPEY);
+SS_ENUM(RANDOM_DBTOOL);
SS_ENUM(CRYPT);
SS_ENUM(HTTP_SEND);
SS_ENUM(ORTP_SEND);
* Check the command line options and initialize all function pointers of \a db.
* Connect to the mysql server and initialize the dbinfo string.
*
- * \sa struct dbtool, misc_meta_data::dbinfo, dopey.c
+ * \sa struct dbtool, misc_meta_data::dbinfo, random_dbtool.c
*/
int mysql_dbtool_init(struct dbtool *db)
{
--- /dev/null
+/*
+ * Copyright (C) 2004-2006 Andre Noll <maan@systemlinux.org>
+ *
+ * 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.
+ */
+
+/** \file random_dbtool. Simple database tool implementation. Feel free to modify. */
+
+#include <sys/time.h> /* gettimeofday */
+#include "server.cmdline.h"
+#include "server.h"
+#include "db.h"
+#include "error.h"
+#include "net.h"
+#include "string.h"
+
+static int com_random_info(int, int, char **);
+extern struct gengetopt_args_info conf;
+extern struct misc_meta_data *mmd;
+
+static unsigned int num_audio_files, audio_file_count;
+static char **audio_file_list;
+
+static int count_audio_files(__unused const char *dir, __unused const char *name)
+{
+ num_audio_files++;
+ return 1;
+}
+
+static int remember_file(const char *dir, const char *name)
+{
+ if (audio_file_count >= num_audio_files)
+ return -E_FILE_COUNT;
+ audio_file_list[audio_file_count] = make_message("%s/%s", dir, name);
+ audio_file_count++;
+ return 1;
+}
+
+/* array of commands that are supported by this database tool */
+static struct server_command cmds[] = {
+{
+.name = "random_info",
+.handler = com_random_info,
+.perms = 0,
+.description = "about the random database tool",
+.synopsis = "random_info",
+.help =
+
+"Select a random file under the given directory"
+}, {
+.name = NULL,
+}
+};
+
+static int com_random_info(int fd, __unused int argc, __unused char *argv[])
+{
+ return send_buffer(fd, "Don't use for huge directories as it is "
+ "very inefficient in this case.\n");
+}
+
+/*
+ * Load a list of all audio files into memory and chose num of them randomly.
+ * Called by server to determine next audio file to be streamed.
+ */
+static char **random_get_audio_file_list(unsigned int num)
+{
+ int i, ret;
+ unsigned int len;
+ char **ret_list = NULL; /* what we are going to return */
+
+ audio_file_list = NULL;
+ num_audio_files = 0;
+ /* first run, just count all audio files. dopey */
+ ret = find_audio_files(conf.random_dbtool_dir_arg, count_audio_files);
+ if (ret < 0)
+ goto out;
+ ret = -E_NOTHING_FOUND;
+ if (!num_audio_files)
+ goto out;
+ /* yeah, that doesn't scale, also dopey */
+ audio_file_list = para_malloc(num_audio_files * sizeof(char *));
+ audio_file_count = 0;
+ /* second run (hot dentry cache, hopefully), fill audio_file_list */
+ ret = find_audio_files(conf.random_dbtool_dir_arg, remember_file);
+ if (ret < 0)
+ goto out;
+ /* careful, files might got deleted underneath */
+ num_audio_files = audio_file_count; /* can only decrease */
+ len = MIN(num, num_audio_files);
+ ret = -E_NOTHING_FOUND;
+ if (!len) /* nothing found, return NULL */
+ goto out;
+ /* success, return NULL-terminated list */
+ ret_list = para_calloc((len + 1) * sizeof(char *));
+ for (i = 0; i < len; i++) { /* choose randomly */
+ int r = (int) ((num_audio_files + 0.0) * (rand()
+ / (RAND_MAX + 1.0)));
+ ret_list[i] = para_strdup(audio_file_list[r]);
+ }
+out:
+ if (audio_file_list) {
+ for (i = 0; i < num_audio_files; i++)
+ free(audio_file_list[i]);
+ free(audio_file_list);
+ }
+// if (ret < 0)
+// PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+ return ret_list;
+}
+
+static void random_shutdown(void)
+{
+ PARA_DEBUG_LOG("%s", "thanks for using another dbtool.\n");
+}
+
+/** random's (constant) database info text */
+#define DBINFO "dbinfo1:database info? You're kidding. I'm still dopey!\ndbinfo2:\ndbinfo3:\n"
+
+/**
+ * the init function for the random database tool
+ *
+ * Init all function pointers of \a db, init the dbinfo text and seed the
+ * PRNG.
+ *
+ * \sa struct dbtool, misc_meta_data::dbinfo, mysql.c
+ */
+int random_dbtool_init(struct dbtool *db)
+{
+ struct timeval now;
+
+ PARA_INFO_LOG("%s", "registering random handlers ;)\n");
+ sprintf(mmd->dbinfo, DBINFO);
+ gettimeofday(&now, NULL);
+ srand(now.tv_usec);
+ db->cmd_list = cmds;
+ db->get_audio_file_list = random_get_audio_file_list;
+ db->shutdown = random_shutdown;
+ return 1;
+}
/** the list of supported database tools */
struct dbtool dblist[] = {
{
- .name = "dopey",
- .init = dopey_dbtool_init,
+ .name = "random",
+ .init = random_dbtool_init,
.update_audio_file = NULL,
},
#ifdef HAVE_MYSQL
mmd->dbt_change = -1; /* no change nec., set to new dbt num by com_cdt */
if (!dblist[1].name)
- goto dopey;
+ goto random;
if (conf.dbtool_given) {
for (i = 0; dblist[i].name; i++) {
if (strcmp(dblist[i].name, conf.dbtool_arg))
if (dblist[i].init(&dblist[i]) < 0) {
PARA_WARNING_LOG("init %s failed",
dblist[i].name);
- goto dopey;
+ goto random;
}
mmd->dbt_num = i;
return;
}
- PARA_WARNING_LOG("%s", "no such dbtool, switching to dopey\n");
- goto dopey;
+ PARA_WARNING_LOG("%s", "no such dbtool, switching to random\n");
+ goto random;
}
/* use the first dbtool that works
- * (assuming that dopey always works)
+ * (assuming that random always works)
*/
for (i = 1; dblist[i].name; i++) {
int ret = dblist[i].init(&dblist[i]);
PARA_CRIT_LOG("%s init failed: %s\n", dblist[i].name,
PARA_STRERROR(-ret));
}
-dopey:
+random:
mmd->dbt_num = 0;
dblist[0].init(&dblist[0]); /* always successful */
}
return;
}
/* init failed */
- PARA_ERROR_LOG("%s -- switching to dopey\n", PARA_STRERROR(-ret));
+ PARA_ERROR_LOG("%s -- switching to the random dbtool\n", PARA_STRERROR(-ret));
dblist[0].init(&dblist[0]);
mmd->dbt_num = 0;
}
-section "Dopey database tool options"
-option "dopey_dir" - "dir to search for files to be streamed" string default="/home/music" no
+section "Random database tool options"
+option "random_dbtool_dir" - "dir to search for files to be streamed" string default="/home/music" no
section "Http sender options"
option "http_port" - "tcp port for http streaming" int typestr="portnumber" default="8000" no
option "ortp_no_autostart" - "do not start to send automatically" flag off
option "ortp_default_port" - "default udp port if not specified" int typestr="portnumber" default="1500" no
option "ortp_header_interval" H "time between extra header sends" int typestr="milliseconds" default="2000" no
-