Change dbinfo1 stat item and use it from afs.
authorAndre Noll <maan@systemlinux.org>
Tue, 23 Oct 2007 15:53:04 +0000 (17:53 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 23 Oct 2007 15:53:04 +0000 (17:53 +0200)
afs.c
command.c
gui_theme.c
para.h
sdl_gui.c
server.c
server.h
stat.c
vss.c

diff --git a/afs.c b/afs.c
index 48faeb1..c410854 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -75,6 +75,8 @@ struct command_task {
        struct task task;
 };
 
        struct task task;
 };
 
+extern struct misc_meta_data *mmd;
+
 static int server_socket;
 static struct command_task command_task_struct;
 static struct signal_task signal_task_struct;
 static int server_socket;
 static struct command_task command_task_struct;
 static struct signal_task signal_task_struct;
@@ -536,10 +538,17 @@ static int activate_mood_or_playlist(char *arg, int *num_admissible)
        current_play_mode = mode;
        if (arg != current_mop) {
                free(current_mop);
        current_play_mode = mode;
        if (arg != current_mop) {
                free(current_mop);
-               if (arg)
+               if (arg) {
                        current_mop = para_strdup(arg);
                        current_mop = para_strdup(arg);
-               else
+                       mmd_lock();
+                       strcpy(mmd->afs_mode_string, arg); /* FIXME: check length */
+                       mmd_unlock();
+               } else {
+                       mmd_lock();
+                       strcpy(mmd->afs_mode_string, "dummy");
+                       mmd_unlock();
                        current_mop = NULL;
                        current_mop = NULL;
+               }
        }
        return 1;
 }
        }
        return 1;
 }
index 8940a0d..441f4d7 100644 (file)
--- a/command.c
+++ b/command.c
@@ -148,7 +148,7 @@ static char *get_status(struct misc_meta_data *nmmd)
        ret = make_message(
                "%s:%zu\n"      "%s:%s\n"               "%s:%lu\n"      "%s:%u\n"
                "%s:%s\n"       "%s:%s\n"       "%s:%s\n"       "%s:%s\n"
        ret = make_message(
                "%s:%zu\n"      "%s:%s\n"               "%s:%lu\n"      "%s:%u\n"
                "%s:%s\n"       "%s:%s\n"       "%s:%s\n"       "%s:%s\n"
-               "%s:%li\n"      "%s:%s\n"       "%s"
+               "%s:%li\n"      "%s:%s\n"       "%s:%s\n" "%s"
                "%s:%s\n"       "%s:%lu.%lu\n"  "%s:%lu.%lu\n",
                status_item_list[SI_FILE_SIZE], nmmd->size / 1024,
                status_item_list[SI_MTIME], mtime,
                "%s:%s\n"       "%s:%lu.%lu\n"  "%s:%lu.%lu\n",
                status_item_list[SI_FILE_SIZE], nmmd->size / 1024,
                status_item_list[SI_MTIME], mtime,
@@ -162,6 +162,7 @@ static char *get_status(struct misc_meta_data *nmmd)
 
                status_item_list[SI_OFFSET], offset,
                status_item_list[SI_FORMAT], audio_format_name(nmmd->audio_format),
 
                status_item_list[SI_OFFSET], offset,
                status_item_list[SI_FORMAT], audio_format_name(nmmd->audio_format),
+               status_item_list[SI_AFS_MODE], mmd->afs_mode_string,
                nmmd->afi.info_string,
 
                status_item_list[SI_UPTIME], ut,
                nmmd->afi.info_string,
 
                status_item_list[SI_UPTIME], ut,
index 7844e60..98830c2 100644 (file)
@@ -247,14 +247,14 @@ static void init_theme_colorful_blackness(struct gui_theme *t)
        d[SI_AUDIO_INFO3].y = 63;
        d[SI_AUDIO_INFO3].len = 100;
 
        d[SI_AUDIO_INFO3].y = 63;
        d[SI_AUDIO_INFO3].len = 100;
 
-       d[SI_DBINFO1].prefix = "";
-       d[SI_DBINFO1].postfix = "";
-       d[SI_DBINFO1].fg = COLOR_YELLOW;
-       d[SI_DBINFO1].bg = COLOR_BLACK;
-       d[SI_DBINFO1].align = CENTER;
-       d[SI_DBINFO1].x = 0;
-       d[SI_DBINFO1].y = 77;
-       d[SI_DBINFO1].len = 100;
+       d[SI_AFS_MODE].prefix = "";
+       d[SI_AFS_MODE].postfix = "";
+       d[SI_AFS_MODE].fg = COLOR_YELLOW;
+       d[SI_AFS_MODE].bg = COLOR_BLACK;
+       d[SI_AFS_MODE].align = CENTER;
+       d[SI_AFS_MODE].x = 0;
+       d[SI_AFS_MODE].y = 77;
+       d[SI_AFS_MODE].len = 100;
 
        d[SI_DBINFO2].prefix = "";
        d[SI_DBINFO2].postfix = "";
 
        d[SI_DBINFO2].prefix = "";
        d[SI_DBINFO2].postfix = "";
diff --git a/para.h b/para.h
index dea9291..a23c440 100644 (file)
--- a/para.h
+++ b/para.h
@@ -164,7 +164,7 @@ enum {
        SI_MTIME,               SI_LENGTH_MIN,          SI_LENGTH_SEC,
        SI_FILE_SIZE,           SI_STATUS_FLAGS,        SI_FORMAT,
        SI_SCORE,               SI_AUDIO_INFO1,         SI_AUDIO_INFO2,
        SI_MTIME,               SI_LENGTH_MIN,          SI_LENGTH_SEC,
        SI_FILE_SIZE,           SI_STATUS_FLAGS,        SI_FORMAT,
        SI_SCORE,               SI_AUDIO_INFO1,         SI_AUDIO_INFO2,
-       SI_AUDIO_INFO3,         SI_DBINFO1,             SI_DBINFO2,
+       SI_AUDIO_INFO3,         SI_AFS_MODE,            SI_DBINFO2,
        SI_DBINFO3,             SI_DECODER_FLAGS,       SI_AUDIOD_STATUS,
        SI_PLAY_TIME,           SI_UPTIME,              SI_OFFSET,
        SI_LENGTH,              SI_STREAM_START,        SI_CURRENT_TIME,
        SI_DBINFO3,             SI_DECODER_FLAGS,       SI_AUDIOD_STATUS,
        SI_PLAY_TIME,           SI_UPTIME,              SI_OFFSET,
        SI_LENGTH,              SI_STREAM_START,        SI_CURRENT_TIME,
index c63f9b8..9668fad 100644 (file)
--- a/sdl_gui.c
+++ b/sdl_gui.c
@@ -281,18 +281,18 @@ static void init_stat_items(void)
        s[SI_AUDIO_INFO3].font = N_YELLOW;
        s[SI_AUDIO_INFO3].align = CENTER;
 
        s[SI_AUDIO_INFO3].font = N_YELLOW;
        s[SI_AUDIO_INFO3].align = CENTER;
 
-       s[SI_DBINFO1].name = "dbinfo1:";
-       s[SI_DBINFO1].prefix = "";
-       s[SI_DBINFO1].postfix = "";
-       s[SI_DBINFO1].x = 0;
-       s[SI_DBINFO1].y = 83;
-       s[SI_DBINFO1].w = 100;
-       s[SI_DBINFO1].h = FONT_HEIGHT;
-       s[SI_DBINFO1].r = 0;
-       s[SI_DBINFO1].g = 0;
-       s[SI_DBINFO1].b = 0;
-       s[SI_DBINFO1].font = N_YELLOW;
-       s[SI_DBINFO1].align = CENTER;
+       s[SI_AFS_MODE].name = "afs_mode:";
+       s[SI_AFS_MODE].prefix = "";
+       s[SI_AFS_MODE].postfix = "";
+       s[SI_AFS_MODE].x = 0;
+       s[SI_AFS_MODE].y = 83;
+       s[SI_AFS_MODE].w = 100;
+       s[SI_AFS_MODE].h = FONT_HEIGHT;
+       s[SI_AFS_MODE].r = 0;
+       s[SI_AFS_MODE].g = 0;
+       s[SI_AFS_MODE].b = 0;
+       s[SI_AFS_MODE].font = N_YELLOW;
+       s[SI_AFS_MODE].align = CENTER;
 
        s[SI_DBINFO2].prefix = "";
        s[SI_DBINFO2].postfix = "";
 
        s[SI_DBINFO2].prefix = "";
        s[SI_DBINFO2].postfix = "";
index bf4ed37..6703fab 100644 (file)
--- a/server.c
+++ b/server.c
@@ -147,7 +147,6 @@ static void shm_init(void)
                goto err_out;
        mmd_mutex = ret;
 
                goto err_out;
        mmd_mutex = ret;
 
-       mmd->selector_num = 0;
        mmd->num_played = 0;
        mmd->num_commands = 0;
        mmd->events = 0;
        mmd->num_played = 0;
        mmd->num_commands = 0;
        mmd->events = 0;
@@ -344,8 +343,6 @@ static unsigned do_inits(int argc, char **argv)
        /* become daemon */
        if (conf.daemon_given)
                daemon_init();
        /* become daemon */
        if (conf.daemon_given)
                daemon_init();
-//     init_selector();
-//     PARA_ERROR_LOG("num: %d\n", mmd->selector_num);
        PARA_NOTICE_LOG("%s", "initializing virtual streaming system\n");
        afh_init();
        vss_init();
        PARA_NOTICE_LOG("%s", "initializing virtual streaming system\n");
        afh_init();
        vss_init();
index 86d4f17..cb7a716 100644 (file)
--- a/server.h
+++ b/server.h
@@ -101,9 +101,7 @@ struct misc_meta_data {
        /** the process id of para_server */
        pid_t server_pid;
        /** a string that gets filled in by the current audio file selector */
        /** the process id of para_server */
        pid_t server_pid;
        /** a string that gets filled in by the current audio file selector */
-       char selector_info[MMD_INFO_SIZE];
-       /** The number of the current audio file selector. */
-       int selector_num;
+       char afs_mode_string[MAXLINE];
        /** commands set this to non-zero to change the current selector */
        int selector_change;
        /** used by the sender command */
        /** commands set this to non-zero to change the current selector */
        int selector_change;
        /** used by the sender command */
diff --git a/stat.c b/stat.c
index ce6aded..adff3b7 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -65,7 +65,7 @@ const char *status_item_list[NUM_STAT_ITEMS] = {
        [SI_AUDIO_INFO2] = "audio_file_info2",
 
        [SI_AUDIO_INFO3] = "audio_file_info3",
        [SI_AUDIO_INFO2] = "audio_file_info2",
 
        [SI_AUDIO_INFO3] = "audio_file_info3",
-       [SI_DBINFO1] = "dbinfo1",
+       [SI_AFS_MODE] = "afs_mode",
        [SI_DBINFO2] = "dbinfo2",
 
        [SI_DBINFO3] = "dbinfo3",
        [SI_DBINFO2] = "dbinfo2",
 
        [SI_DBINFO3] = "dbinfo3",
@@ -171,7 +171,6 @@ void stat_client_write(const char *msg, int itemnum)
        PARA_DEBUG_LOG("%d client(s)\n", num_clients);
 }
 
        PARA_DEBUG_LOG("%d client(s)\n", num_clients);
 }
 
-
 /**
  * check if string is a known status item.
  *
 /**
  * check if string is a known status item.
  *
@@ -184,12 +183,13 @@ int stat_item_valid(const char *item)
 {
        int i;
        if (!item || !*item) {
 {
        int i;
        if (!item || !*item) {
-       PARA_ERROR_LOG("%s\n", "no item");
+               PARA_ERROR_LOG("%s\n", "no item");
                return -E_UNKNOWN_STAT_ITEM;
        }
        FOR_EACH_STAT_ITEM(i)
                if (!strcmp(status_item_list[i], item))
                        return i;
                return -E_UNKNOWN_STAT_ITEM;
        }
        FOR_EACH_STAT_ITEM(i)
                if (!strcmp(status_item_list[i], item))
                        return i;
+       PARA_ERROR_LOG("invalid stat item: %s\n", item);
        return -E_UNKNOWN_STAT_ITEM;
 }
 
        return -E_UNKNOWN_STAT_ITEM;
 }
 
diff --git a/vss.c b/vss.c
index 3db8bb4..93ee76d 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -202,10 +202,6 @@ static void vss_eof(void)
                status_item_list[SI_AUDIO_INFO2], status_item_list[SI_AUDIO_INFO3]);
        strcpy(mmd->afi.info_string, tmp);
        free(tmp);
                status_item_list[SI_AUDIO_INFO2], status_item_list[SI_AUDIO_INFO3]);
        strcpy(mmd->afi.info_string, tmp);
        free(tmp);
-       tmp  = make_message("%s:\n%s:\n%s:\n", status_item_list[SI_DBINFO1],
-               status_item_list[SI_DBINFO2], status_item_list[SI_DBINFO3]);
-       strcpy(mmd->selector_info, tmp);
-       free(tmp);
        mmd->filename[0] = '\0';
        mmd->size = 0;
        mmd->events++;
        mmd->filename[0] = '\0';
        mmd->size = 0;
        mmd->events++;