speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/1] remove SPDVoice **voices from OutputModule


From: Andrei Kholodnyi
Subject: [PATCH 1/1] remove SPDVoice **voices from OutputModule
Date: Fri, 3 Dec 2010 19:04:06 +0100

there is no need to keep list of the voice in OutputModule
we can retrieve it at any time from synth

we also do not retrieve voices while loading module
---
 src/server/module.c |    3 ---
 src/server/module.h |    1 -
 src/server/output.c |   15 ++++++---------
 src/server/output.h |    1 -
 src/server/parse.c  |    5 +++++
 5 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/server/module.c b/src/server/module.c
index a1e2e42..2f0fe4d 100644
--- a/src/server/module.c
+++ b/src/server/module.c
@@ -318,9 +318,6 @@ load_output_module(char* mod_name, char* mod_prog, char* 
mod_cfgfile, char* mod_
        return NULL;
     }
 
-    /* Get a list of supported voices */
-    _output_get_voices(module);
-
     return module;
 }
 
diff --git a/src/server/module.h b/src/server/module.h
index 5bbed2a..edb7254 100644
--- a/src/server/module.h
+++ b/src/server/module.h
@@ -39,7 +39,6 @@ typedef struct{
     int stderr_redirect;
     pid_t pid;
     int working;
-    SPDVoice **voices;
 }OutputModule;
 
 GList *detect_output_modules(char *dirname);
diff --git a/src/server/output.c b/src/server/output.c
index caf5403..b38ccd1 100644
--- a/src/server/output.c
+++ b/src/server/output.c
@@ -282,8 +282,8 @@ output_send_data(char* cmd, OutputModule *output, int wfr)
     return 0;
 }
 
-int
-_output_get_voices(OutputModule *module)
+static SPDVoice**
+output_get_voices(OutputModule *module)
 {
   SPDVoice** voice_dscr;
   GString *reply;
@@ -297,15 +297,14 @@ _output_get_voices(OutputModule *module)
 
   if (module == NULL){
     MSG(1, "ERROR: Can't list voices for broken output module");
-    OL_RET(-1);
+    OL_RET(NULL);
   }
   output_send_data("LIST VOICES\n", module, 0);
   reply = output_read_reply(module);
 
   if (reply == NULL){
       output_unlock();
-      voice_dscr = NULL;
-      return -1;
+      return NULL;
   }
 
   //TODO: only 256 voices supported here
@@ -343,10 +342,8 @@ _output_get_voices(OutputModule *module)
   voice_dscr[i] = NULL;
   g_strfreev(lines);
 
-  module->voices=voice_dscr;
-
   output_unlock();
-  return ret;
+  return voice_dscr;
 }
 
 SPDVoice**
@@ -359,7 +356,7 @@ output_list_voices(char* module_name)
     MSG(1, "ERROR: Can't list voices for module %s", module_name);
     return NULL;
   }
-  return module->voices;
+  return output_get_voices(module);
 }
 
 #define SEND_CMD_N(cmd) \
diff --git a/src/server/output.h b/src/server/output.h
index 8d5c44f..9a0e9a9 100644
--- a/src/server/output.h
+++ b/src/server/output.h
@@ -48,4 +48,3 @@ int output_module_is_speaking(OutputModule *output, char 
**index_mark);
 int waitpid_with_timeout(pid_t pid, int *status_ptr, int options, size_t 
timeout);
 int output_close(OutputModule *module);
 SPDVoice** output_list_voices(char* module_name);
-int _output_get_voices(OutputModule *module);
diff --git a/src/server/parse.c b/src/server/parse.c
index 730a5c7..e8317e1 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -870,10 +870,15 @@ parse_list(const char* buf, const int bytes, const int 
fd, const TSpeechDSock *s
        if (voices[i] == NULL) break;
        g_string_append_printf(result, C_OK_VOICES"-%s %s %s\r\n",
                               voices[i]->name, voices[i]->language, 
voices[i]->variant);
+        g_free(voices[i]->name);
+        g_free(voices[i]->language);
+        g_free(voices[i]->variant);
+        g_free(voices[i]);
       }
       g_string_append(result, OK_VOICE_LIST_SENT);
       helper = result->str;
       g_string_free(result, 0);        
+      g_free(voices);
       return helper;      
     }else{
       g_free(list_type);
-- 
1.6.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]