static struct timeval eof_barrier;
extern struct misc_meta_data *mmd;
-extern struct audio_file_selector dblist[];
+extern struct audio_file_selector selectors[];
extern struct sender senders[];
extern struct gengetopt_args_info conf;
static void get_song(void)
{
- char **sl = dblist[mmd->selector_num].get_audio_file_list(10);
+ char **sl = selectors[mmd->selector_num].get_audio_file_list(10);
int i;
if (!sl)
continue;
}
mmd->num_played++;
- if (dblist[mmd->selector_num].update_audio_file)
- dblist[mmd->selector_num].update_audio_file(sl[i]);
+ if (selectors[mmd->selector_num].update_audio_file)
+ selectors[mmd->selector_num].update_audio_file(sl[i]);
PARA_DEBUG_LOG("%s", "success\n");
mmd->new_afs_status_flags &= (~AFS_NEXT);
gettimeofday(&now, NULL);
extern const char *status_item_list[NUM_STAT_ITEMS];
extern struct misc_meta_data *mmd;
extern struct gengetopt_args_info conf;
-extern struct audio_file_selector dblist[];
+extern struct audio_file_selector selectors[];
extern struct audio_format afl[];
extern struct sender senders[];
extern char *user_list;
status_item_list[SI_STATUS_BAR], bar ? bar : "(none)",
status_item_list[SI_STATUS], status,
status_item_list[SI_STATUS_FLAGS], flags,
- status_item_list[SI_SELECTOR], dblist[nmmd->selector_num].name,
+ status_item_list[SI_SELECTOR], selectors[nmmd->selector_num].name,
status_item_list[SI_OFFSET], offset,
status_item_list[SI_FORMAT], audio_format_name(nmmd->audio_format),
{
int i, ret;
char *ut;
- char *selectors = NULL, *sender_info = NULL, *sender_list = NULL;
+ char *selector_string = NULL, *sender_info = NULL, *sender_list = NULL;
struct mallinfo mi = mallinfo();
if (argc)
return -E_COMMAND_SYNTAX;
mmd_lock();
- for (i = 0; dblist[i].name; i++) {
- selectors = para_strcat(selectors, dblist[i].name);
- selectors = para_strcat(selectors, " ");
+ for (i = 0; selectors[i].name; i++) {
+ selector_string = para_strcat(selector_string, selectors[i].name);
+ selector_string = para_strcat(selector_string, " ");
}
for (i = 0; senders[i].name; i++) {
char *info = senders[i].info();
mmd->num_commands,
mmd->num_connects,
conf.loglevel_arg,
- selectors,
+ selector_string,
SUPPORTED_AUDIO_FORMATS,
sender_list,
sender_info
);
mmd_unlock();
free(ut);
- free(selectors);
+ free(selector_string);
free(sender_list);
free(sender_info);
return ret;
mmd_lock();
if (handler)
*handler = make_message("the %s selector",
- dblist[mmd->selector_num].name);
- cmd = dblist[mmd->selector_num].cmd_list;
+ selectors[mmd->selector_num].name);
+ cmd = selectors[mmd->selector_num].cmd_list;
mmd_unlock();
for (; cmd->name; cmd++)
if (!strcmp(cmd->name, name))
if ((ret = send_description(fd, cmd_struct, "server", 0)) < 0)
return ret;
mmd_lock();
- handler = para_strdup(dblist[mmd->selector_num].name);
- cmd = dblist[mmd->selector_num].cmd_list;
+ handler = para_strdup(selectors[mmd->selector_num].name);
+ cmd = selectors[mmd->selector_num].cmd_list;
mmd_unlock();
ret = send_description(fd, cmd, handler, 0);
free(handler);
if (!argc) {
char *selector;
mmd_lock();
- selector = para_strdup(dblist[mmd->selector_num].name);
+ selector = para_strdup(selectors[mmd->selector_num].name);
mmd_unlock();
ret = send_va_buffer(fd, "%s\n", selector);
free(selector);
return ret;
}
- for (i = 0; dblist[i].name; i++) {
- if (strcmp(dblist[i].name, argv[1]))
+ for (i = 0; selectors[i].name; i++) {
+ if (strcmp(selectors[i].name, argv[1]))
continue;
mmd_lock();
mmd->selector_change = i;
extern struct audio_format afl[];
/** the list of supported audio file selectors */
-struct audio_file_selector dblist[] = {
+struct audio_file_selector selectors[] = {
{
.name = "random",
.init = random_selector_init,
mmd->selector_change = -1; /* no change nec., set to new num by com_chs */
if (!conf.selector_given)
goto random;
- for (i = 0; dblist[i].name; i++) {
- if (strcmp(dblist[i].name, conf.selector_arg))
+ for (i = 0; selectors[i].name; i++) {
+ if (strcmp(selectors[i].name, conf.selector_arg))
continue;
PARA_NOTICE_LOG("initializing %s audio file selector\n",
- dblist[i].name);
- ret = dblist[i].init(&dblist[i]);
+ selectors[i].name);
+ ret = selectors[i].init(&selectors[i]);
if (ret < 0) {
PARA_WARNING_LOG("%s", PARA_STRERROR(-ret));
break;
PARA_WARNING_LOG("%s", "falling back to the random selector\n");
random:
mmd->selector_num = 0;
- dblist[0].init(&dblist[0]); /* always successful */
+ selectors[0].init(&selectors[0]); /* always successful */
}
static unsigned init_network(void)
{
int ret, old = mmd->selector_num, new = mmd->selector_change;
- dblist[old].shutdown();
- ret = dblist[new].init(&dblist[new]);
+ selectors[old].shutdown();
+ ret = selectors[new].init(&selectors[new]);
mmd->selector_change = -1; /* reset */
if (ret >= 0) {
mmd->selector_num = new;
}
/* init failed */
PARA_ERROR_LOG("%s -- switching to the random selector\n", PARA_STRERROR(-ret));
- dblist[0].init(&dblist[0]);
+ selectors[0].init(&selectors[0]);
mmd->selector_num = 0;
}
&max_fileno,
&rfds, &wfds);
}
- if (dblist[mmd->selector_num].pre_select) {
- ret = dblist[mmd->selector_num].pre_select(&rfds, &wfds);
+ if (selectors[mmd->selector_num].pre_select) {
+ ret = selectors[mmd->selector_num].pre_select(&rfds, &wfds);
max_fileno = MAX(max_fileno, ret);
}
mmd_unlock();
mmd_lock();
if (mmd->selector_change >= 0)
change_selector();
- if (dblist[mmd->selector_num].post_select)
- dblist[mmd->selector_num].post_select(&rfds, &wfds);
+ if (selectors[mmd->selector_num].post_select)
+ selectors[mmd->selector_num].post_select(&rfds, &wfds);
if (ret < 0 && err == EINTR)
goto repeat;
if (ret < 0) {
case SIGTERM:
PARA_EMERG_LOG("terminating on signal %d\n", sig);
kill(0, SIGTERM);
- dblist[mmd->selector_num].shutdown();
+ selectors[mmd->selector_num].shutdown();
mutex_destroy(mmd_mutex);
shm_detach(mmd);
shm_destroy(mmd_shm_id);