mysql_selector.c: refresh selector info on com_us and com_snp
authorAndre Noll <maan@systemlinux.org>
Thu, 15 Mar 2007 18:42:39 +0000 (19:42 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 15 Mar 2007 18:42:39 +0000 (19:42 +0100)
mysql_selector.c

index d7d4ee104f80e6fd6d419ecd2a068073d594cbfe..b2a925e09311a6cc71bf45c488c73eca8a163e99 100644 (file)
@@ -900,7 +900,6 @@ write:
        return info;
 }
 
        return info;
 }
 
-
 /* might return NULL */
 static char *get_current_audio_file(void)
 {
 /* might return NULL */
 static char *get_current_audio_file(void)
 {
@@ -911,6 +910,29 @@ static char *get_current_audio_file(void)
        return name;
 }
 
        return name;
 }
 
+/* If called as child, mmd_lock must be held */
+static void update_mmd(char *info)
+{
+       PARA_DEBUG_LOG("%s", "updating shared memory area\n");
+       strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
+       mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
+}
+
+static void refresh_selector_info(void)
+{
+       char *name = get_current_audio_file();
+       char *info;
+
+       if (!name)
+               return;
+       info = get_selector_info(name);
+       free(name);
+       mmd_lock();
+       update_mmd(info);
+       mmd_unlock();
+       free(info);
+}
+
 /* list attributes / print database info */
 static int com_la_info(int fd, int argc, char *argv[])
 {
 /* list attributes / print database info */
 static int com_la_info(int fd, int argc, char *argv[])
 {
@@ -1186,7 +1208,10 @@ int com_picass(int fd, int argc, char *argv[])
  */
 int com_snp(int fd, int argc, char *argv[])
 {
  */
 int com_snp(int fd, int argc, char *argv[])
 {
-       return com_set(fd, argc, argv);
+       int ret = com_set(fd, argc, argv);
+       if (ret >= 0)
+               refresh_selector_info();
+       return ret;
 }
 
 /*
 }
 
 /*
@@ -1463,14 +1488,6 @@ out:
        return ret;
 }
 
        return ret;
 }
 
-/* If called as child, mmd_lock must be held */
-static void update_mmd(char *info)
-{
-       PARA_DEBUG_LOG("%s", "updating shared memory area\n");
-       strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
-       mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
-}
-
 static void update_audio_file_server_handler(char *name)
 {
        char *info;
 static void update_audio_file_server_handler(char *name)
 {
        char *info;
@@ -1492,24 +1509,11 @@ int com_us(__a_unused int fd, int argc, char *argv[])
                return -E_ESCAPE;
        ret = update_audio_file(argv[1]);
        free(tmp);
                return -E_ESCAPE;
        ret = update_audio_file(argv[1]);
        free(tmp);
+       if (ret >= 0)
+               refresh_selector_info();
        return ret;
 }
 
        return ret;
 }
 
-static void refresh_selector_info(void)
-{
-       char *name = get_current_audio_file();
-       char *info;
-
-       if (!name)
-               return;
-       info = get_selector_info(name);
-       free(name);
-       mmd_lock();
-       update_mmd(info);
-       mmd_unlock();
-       free(info);
-}
-
 /* select previous / next stream */
 static int com_ps_ns(__a_unused int fd, int argc, char *argv[])
 {
 /* select previous / next stream */
 static int com_ps_ns(__a_unused int fd, int argc, char *argv[])
 {