Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Dec 2012 19:03:19 -0500 (EST)
From:      "Mikhail T." <mi@aldan.algebra.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/174624: [patch] Improving audio/flite
Message-ID:  <201212220003.qBM03Jmi072823@narawntapu.narawntapu>
Resent-Message-ID: <201212220010.qBM0A0l6081794@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         174624
>Category:       ports
>Synopsis:       [patch] Improving audio/flite
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 22 00:10:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Mikhail T.
>Release:        FreeBSD 9.1-PRERELEASE amd64
>Organization:
Virtual Estates, Inc.	http://sybpipe.com/
>Environment:
System: FreeBSD narawntapu 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #6 r244476: Wed Dec 19 23:40:59 EST 2012 root@narawntapu:/usr/obj/cache/src/sys/POWEREDGE2900 amd64


>Description:

	1. The port currently compiles with optimization explicitly set to
	   -O0 (this was added in 2004, when the software was at version
	   1.2 and never revisited even though it is now at 1.4).
	2. One of the patches triggers an obscene amount of const-related
	   warnings. The patch is no longer necessary.

The proposed patch-warnings allows the entire code to compile cleanly
with -Wall -Werror (tested with FreeBSD-9.1/amd64 with both gcc and
clang, as well as FreeBSD-8.3/i386 with gcc).

Hopefully, the original reason for disabling optimization is gone now.
The fixes for warnings (and some of them are, potentially, errors) makes
it even more likely, optimized code will work just fine.

The patch-tests below fixes the sources under testsuite/. These aren't
currently in use, but someone else may some day decide to add the
regression-test target to the port and may benefit from these hunks.

>How-To-Repeat:
>Fix:

Index: files/patch-tests
===================================================================
--- files/patch-tests	(revision 0)
+++ files/patch-tests	(revision 0)
@@ -0,0 +1,32 @@
+I wonder, whether the developers have used their own testsuit before
+making this release...
+
+	-mi
+
+--- testsuite/token_test_main.c	2009-04-08 09:18:42.000000000 -0400
++++ testsuite/token_test_main.c	2012-12-21 18:08:31.000000000 -0500
+@@ -47,5 +47,5 @@
+     const char *token;
+ 
+-    fd = ts_open("data.one");
++    fd = ts_open("data.one", NULL, NULL, NULL, NULL);
+ 
+     while (!ts_eof(fd))
+--- testsuite/utt_test_main.c	2009-04-08 09:18:42.000000000 -0400
++++ testsuite/utt_test_main.c	2012-12-21 18:09:41.000000000 -0500
+@@ -123,5 +123,5 @@
+     cst_tokenstream *fd;
+ 
+-    fd = ts_open(filename);
++    fd = ts_open(filename, NULL, NULL, NULL, NULL);
+     if (fd == 0)
+ 	return 0;
+--- testsuite/combine_waves_main.c	2009-04-08 09:18:42.000000000 -0400
++++ testsuite/combine_waves_main.c	2012-12-21 18:10:47.000000000 -0500
+@@ -56,5 +56,5 @@
+     int i=0;
+ 
+-    ts = ts_open(wavelistfile);
++    ts = ts_open(wavelistfile, NULL, NULL, NULL, NULL);
+     if (!ts)
+     {
Index: files/patch-warnings
===================================================================
--- files/patch-warnings	(revision 0)
+++ files/patch-warnings	(revision 0)
@@ -0,0 +1,170 @@
+--- src/audio/au_oss.c	2009-04-08 09:18:42.000000000 -0400
++++ src/audio/au_oss.c	2012-12-21 17:29:35.000000000 -0500
+@@ -84,5 +84,5 @@
+     ad->channels = channels;
+     ad->fmt = fmt;
+-    ad->platform_data = (void *)afd;
++    ad->platform_data = (void *)(intptr_t)afd;
+ 
+     if (ad->channels == 0)
+@@ -179,6 +179,6 @@
+ 	return 0;
+ 
+-    ioctl((int)ad->platform_data, SNDCTL_DSP_SYNC, NULL);
+-    rv = close((int)ad->platform_data);
++    ioctl((intptr_t)ad->platform_data, SNDCTL_DSP_SYNC, NULL);
++    rv = close((intptr_t)ad->platform_data);
+     cst_free(ad);
+     return rv;
+@@ -187,14 +187,14 @@
+ int audio_write_oss(cst_audiodev *ad, void *samples, int num_bytes)
+ {
+-    return write((int)ad->platform_data,samples,num_bytes);
++    return write((intptr_t)ad->platform_data,samples,num_bytes);
+ }
+ 
+ int audio_flush_oss(cst_audiodev *ad)
+ {
+-    return ioctl((int)ad->platform_data, SNDCTL_DSP_SYNC, NULL);
++    return ioctl((intptr_t)ad->platform_data, SNDCTL_DSP_SYNC, NULL);
+ }
+ 
+ int audio_drain_oss(cst_audiodev *ad)
+ {
+-    return ioctl((int)ad->platform_data, SNDCTL_DSP_RESET, NULL);
++    return ioctl((intptr_t)ad->platform_data, SNDCTL_DSP_RESET, NULL);
+ }
+--- src/synth/cst_ssml.c	2009-05-01 10:52:13.000000000 -0400
++++ src/synth/cst_ssml.c	2012-12-21 17:31:41.000000000 -0500
+@@ -57,41 +57,7 @@
+ #include "cst_tokenstream.h"
+ 
+-static const char *ssml_whitespacesymbols;
+ static const char *ssml_singlecharsymbols_general = "<>&/\";";
+ static const char *ssml_singlecharsymbols_inattr = "=>;/\"";
+ 
+-static void add_raw_data(cst_utterance *u, const char *raw_data,
+-			 cst_features *attributes)
+-{
+-    /* Add all tokens in raw _data to u */
+-    cst_tokenstream *ts;
+-    cst_relation *r;
+-    cst_item *t;
+-    const char *token;
+-
+-    r = utt_relation_create(u,"Token");
+-    ts = 
+-     ts_open_string(raw_data,
+-                    get_param_string(u->features,"text_whitespace",NULL),
+-                    get_param_string(u->features,"text_singlecharsymbols",NULL),
+-                    get_param_string(u->features,"text_prepunctuation",NULL),
+-                    get_param_string(u->features,"text_pospunctuation",NULL));
+-    while (!(ts_eof(ts)))
+-    {
+-	t = relation_append(r,NULL);
+-	feat_copy_into(item_feats(t),attributes);
+-	token = ts_get(ts);
+-	if (cst_strlen(token) > 0)
+-	{
+-	    t = relation_append(r,NULL);
+-	    item_set_string(t,"name",token);
+-	    item_set_string(t,"whitespace",ts->whitespace);
+-	    item_set_string(t,"prepunctuation",ts->prepunctuation);
+-	    item_set_string(t,"punc",ts->postpunctuation);
+-	}
+-    }
+-
+-}
+-
+ static const char *ts_get_quoted_remainder(cst_tokenstream *ts)
+ {
+@@ -169,14 +135,4 @@
+ }
+ 			       
+-static void extend_buffer(char **buffer,int *buffer_max,int at_least)
+-{
+-    int new_max;
+-
+-    new_max = (*buffer_max)+at_least;
+-    cst_free(*buffer);
+-    *buffer = cst_alloc(char,new_max);
+-    *buffer_max = new_max;
+-}			  
+-
+ static float flite_ssml_to_speech_ts(cst_tokenstream *ts,
+                                      cst_voice *voice,
+--- src/wavesynth/cst_units.c	2009-10-15 18:00:24.000000000 -0400
++++ src/wavesynth/cst_units.c	2012-12-21 17:39:02.000000000 -0500
+@@ -39,4 +39,6 @@
+ /*************************************************************************/
+ 
++#include <stdint.h>
++
+ #include "cst_math.h"
+ #include "cst_hrg.h"
+@@ -430,10 +432,11 @@
+ 			int unit_size, const unsigned char *unit_residual)
+ {
+-    int p,i,m;
++    int i,m;
++    intptr_t p;
+     /* Unit residual isn't a pointed its a number, the power for the 
+        the sts, yes this is hackily casting the address to a number */
+ 
+     /* Need voiced and unvoiced model */
+-    p = (int)unit_residual;
++    p = (intptr_t)unit_residual;
+ 
+     if (p > 7000)  /* voiced */
+--- include/cst_lexicon.h	2009-06-09 14:07:34.000000000 -0400
++++ include/cst_lexicon.h	2012-12-21 17:42:25.000000000 -0500
+@@ -45,5 +45,5 @@
+ 
+ typedef struct lexicon_struct {
+-    char *name;
++    const char *name;
+     int num_entries;
+     /* Entries are centered around bytes with value 255 */
+@@ -51,5 +51,5 @@
+     /* each are terminated (preceeded in pron case) by 0 */
+     /* This saves 4 bytes per entry for an index */
+-    unsigned char *data; /* the entries and phone strings */
++    const unsigned char *data; /* the entries and phone strings */
+     int num_bytes;       /* the number of bytes in the data */
+-    char **phone_table;
++    const char * const *phone_table;
+ 
+     cst_lts_rules *lts_rule_set;
+--- src/lexicon/cst_lexicon.c	2009-08-24 12:35:51.000000000 -0400
++++ src/lexicon/cst_lexicon.c	2012-12-21 17:49:13.000000000 -0500
+@@ -68,5 +68,4 @@
+     if (lex)
+     {
+-	cst_free(lex->data);
+ 	cst_free(lex);
+     }
+@@ -331,5 +330,5 @@
+ {
+     int i,j=0,length;
+-    unsigned char *cword;
++    const unsigned char *cword;
+ 
+     if (l->entry_hufftable == 0)
+--- lang/cmulex/cmu_lex.c	2009-08-14 12:30:10.000000000 -0400
++++ lang/cmulex/cmu_lex.c	2012-12-21 17:53:59.000000000 -0500
+@@ -360,5 +360,5 @@
+ #endif
+     cmu_lex.num_bytes = cmu_lex_num_bytes;
+-    cmu_lex.phone_table = (char **) cmu_lex_phone_table;
++    cmu_lex.phone_table = cmu_lex_phone_table;
+     cmu_lex.syl_boundary = cmu_syl_boundary_mo;
+     cmu_lex.addenda = (char ***) addenda;
+--- main/compile_regexes.c	2009-04-08 09:18:42.000000000 -0400
++++ main/compile_regexes.c	2012-12-21 18:01:44.000000000 -0500
+@@ -75,5 +75,5 @@
+         printf("NULL, ");
+     else
+-        printf("%s_rxprog + %d, ", name, rgx->regmust - rgx->program);
++        printf("%s_rxprog + %td, ", name, rgx->regmust - rgx->program);
+     printf("%d, ",rgx->regmlen);
+     printf("%d,\n   ",rgx->regsize);
Index: files/patch-include::cst_sts.h
===================================================================
--- files/patch-include::cst_sts.h	(revision 309313)
+++ files/patch-include::cst_sts.h	(working copy)
@@ -1,18 +0,0 @@
-
-$FreeBSD$
-
---- include/cst_sts.h
-+++ include/cst_sts.h
-@@ -47,9 +47,9 @@
- /* else where, this information plus the indexes in the Unit relation */
- /* allow reconstruction of the signal itself                          */
- struct cst_sts_struct {
--    const unsigned short *frame;  
--    const int size;      /* in samples */
--    const unsigned char *residual;
-+    unsigned short *frame;  
-+    int size;      /* in samples */
-+    unsigned char *residual;
- };
- typedef struct cst_sts_struct cst_sts;
- 
Index: Makefile
===================================================================
--- Makefile	(revision 309313)
+++ Makefile	(working copy)
@@ -22,7 +22,7 @@
 
 MAKE_JOBS_UNSAFE=	yes
 
-CFLAGS:=	${CFLAGS:N-O:N-O[0123456789]} -O0
+CFLAGS+=	-Werror
 
 post-patch:
 	@${REINPLACE_CMD} -e 's|-pd|-p|g' ${WRKSRC}/main/Makefile
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212220003.qBM03Jmi072823>