X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mysql_selector.c;h=b2a925e09311a6cc71bf45c488c73eca8a163e99;hb=095fc31c48324112a71602ba6975d9d33cf4378e;hp=d7d4ee104f80e6fd6d419ecd2a068073d594cbfe;hpb=64dd27ad50e4440b0ba32565ba9cd98a3db66993;p=paraslash.git diff --git a/mysql_selector.c b/mysql_selector.c index d7d4ee10..b2a925e0 100644 --- a/mysql_selector.c +++ b/mysql_selector.c @@ -900,7 +900,6 @@ write: return info; } - /* might return NULL */ static char *get_current_audio_file(void) { @@ -911,6 +910,29 @@ static char *get_current_audio_file(void) 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[]) { @@ -1186,7 +1208,10 @@ int com_picass(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; } -/* 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; @@ -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); + if (ret >= 0) + refresh_selector_info(); 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[]) {