Browse Source

code cleanup: reduce global externs (#1536)

Contribute to #68

Reduce count of globals / externs that could be a file-local static
variables
master
Juho Hiltunen 2 years ago
parent
commit
0f3fb42b62
No account linked to committer's email address

+ 1
- 1
src/libespeak-ng/dictionary.c View File

int ix; int ix;
unsigned int digit_count = 0; unsigned int digit_count = 0;
char *p; char *p;
ALPHABET *alphabet;
const ALPHABET *alphabet;
int dict_flags0 = 0; int dict_flags0 = 0;
MatchRecord match1 = { 0 }; MatchRecord match1 = { 0 };
MatchRecord match2 = { 0 }; MatchRecord match2 = { 0 };

+ 8
- 8
src/libespeak-ng/speech.c View File

#include "voice.h" // for FreeVoiceList, VoiceReset, current_... #include "voice.h" // for FreeVoiceList, VoiceReset, current_...
#include "wavegen.h" // for WavegenFill, WavegenInit, WcmdqUsed #include "wavegen.h" // for WavegenFill, WavegenInit, WcmdqUsed


unsigned char *outbuf = NULL;
int outbuf_size = 0;
unsigned char *out_start;
static unsigned char *outbuf = NULL;
static int outbuf_size = 0;
static unsigned char *out_start;


espeak_EVENT *event_list = NULL; espeak_EVENT *event_list = NULL;
int event_list_ix = 0;
int n_event_list;
long count_samples;
static int event_list_ix = 0;
static int n_event_list;
static long count_samples;
#ifdef HAVE_PCAUDIOLIB_AUDIO_H #ifdef HAVE_PCAUDIOLIB_AUDIO_H
struct audio_object *my_audio = NULL;
static struct audio_object *my_audio = NULL;
#endif #endif


static unsigned int my_unique_identifier = 0; static unsigned int my_unique_identifier = 0;
static int min_buffer_length = 60; // minimum buffer length in ms static int min_buffer_length = 60; // minimum buffer length in ms
static espeak_ng_STATUS err = ENS_OK; static espeak_ng_STATUS err = ENS_OK;


t_espeak_callback *synth_callback = NULL;
static t_espeak_callback *synth_callback = NULL;
int (*uri_callback)(int, const char *, const char *) = NULL; int (*uri_callback)(int, const char *, const char *) = NULL;
int (*phoneme_callback)(const char *) = NULL; int (*phoneme_callback)(const char *) = NULL;



+ 3
- 3
src/libespeak-ng/synthdata.c View File

int current_phoneme_table; int current_phoneme_table;
PHONEME_TAB *phoneme_tab[N_PHONEME_TAB]; PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];


unsigned short *phoneme_index = NULL;
char *phondata_ptr = NULL;
static unsigned short *phoneme_index = NULL;
static char *phondata_ptr = NULL;
unsigned char *wavefile_data = NULL; unsigned char *wavefile_data = NULL;
static unsigned char *phoneme_tab_data = NULL; static unsigned char *phoneme_tab_data = NULL;


int n_phoneme_tables;
static int n_phoneme_tables;
PHONEME_TAB_LIST phoneme_tab_list[N_PHONEME_TABS]; PHONEME_TAB_LIST phoneme_tab_list[N_PHONEME_TABS];
int phoneme_tab_number = 0; int phoneme_tab_number = 0;



+ 0
- 1
src/libespeak-ng/synthesize.h View File

extern unsigned char *out_ptr; extern unsigned char *out_ptr;
extern unsigned char *out_end; extern unsigned char *out_end;
extern espeak_EVENT *event_list; extern espeak_EVENT *event_list;
extern t_espeak_callback *synth_callback;
extern const int version_phdata; extern const int version_phdata;


void DoEmbedded(int *embix, int sourceix); void DoEmbedded(int *embix, int sourceix);

+ 3
- 3
src/libespeak-ng/tr_languages.c View File

#define OFFSET_ETHIOPIC 0x1200 #define OFFSET_ETHIOPIC 0x1200


// character ranges must be listed in ascending unicode order // character ranges must be listed in ascending unicode order
ALPHABET alphabets[] = {
const ALPHABET alphabets[] = {
{ "_el", OFFSET_GREEK, 0x380, 0x3ff, L('e', 'l'), AL_DONT_NAME | AL_NOT_LETTERS | AL_WORDS }, { "_el", OFFSET_GREEK, 0x380, 0x3ff, L('e', 'l'), AL_DONT_NAME | AL_NOT_LETTERS | AL_WORDS },
{ "_cyr", OFFSET_CYRILLIC, 0x400, 0x52f, 0, 0 }, { "_cyr", OFFSET_CYRILLIC, 0x400, 0x52f, 0, 0 },
{ "_hy", OFFSET_ARMENIAN, 0x530, 0x58f, L('h', 'y'), AL_WORDS }, { "_hy", OFFSET_ARMENIAN, 0x530, 0x58f, L('h', 'y'), AL_WORDS },
{ NULL, 0, 0, 0, 0, 0 } { NULL, 0, 0, 0, 0, 0 }
}; };


ALPHABET *AlphabetFromChar(int c)
const ALPHABET *AlphabetFromChar(int c)
{ {
// Find the alphabet from a character. // Find the alphabet from a character.
ALPHABET *alphabet = alphabets;
const ALPHABET *alphabet = alphabets;


while (alphabet->name != NULL) { while (alphabet->name != NULL) {
if (c <= alphabet->range_max) { if (c <= alphabet->range_max) {

+ 3
- 3
src/libespeak-ng/translate.c View File

bool skipping_text; // waiting until word count, sentence count, or named marker is reached bool skipping_text; // waiting until word count, sentence count, or named marker is reached
int end_character_position; int end_character_position;
int count_sentences; int count_sentences;
int count_words;
static int count_words;
int clause_start_char; int clause_start_char;
int clause_start_word; int clause_start_word;
bool new_sentence;
static bool new_sentence;
static int word_emphasis = 0; // set if emphasis level 3 or 4 static int word_emphasis = 0; // set if emphasis level 3 or 4
static int embedded_flag = 0; // there are embedded commands to be applied to the next phoneme, used in TranslateWord2() static int embedded_flag = 0; // there are embedded commands to be applied to the next phoneme, used in TranslateWord2()


static int max_clause_pause = 0; static int max_clause_pause = 0;
static bool any_stressed_words; static bool any_stressed_words;
int pre_pause; int pre_pause;
ALPHABET *current_alphabet;
static ALPHABET *current_alphabet;


char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
int n_ph_list2; int n_ph_list2;

+ 1
- 1
src/libespeak-ng/translate.h View File

void InitNamedata(void); void InitNamedata(void);
void InitText(int flags); void InitText(int flags);
void InitText2(void); void InitText2(void);
ALPHABET *AlphabetFromChar(int c);
const ALPHABET *AlphabetFromChar(int c);


Translator *SelectTranslator(const char *name); Translator *SelectTranslator(const char *name);
int SetTranslator2(const char *name); int SetTranslator2(const char *name);

+ 6
- 6
src/libespeak-ng/translateword.c View File

static void ChangeWordStress(Translator *tr, char *word, int new_stress); static void ChangeWordStress(Translator *tr, char *word, int new_stress);
static int CheckDottedAbbrev(char *word1); static int CheckDottedAbbrev(char *word1);
static int NonAsciiNumber(int letter); static int NonAsciiNumber(int letter);
static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word, ALPHABET *current_alphabet, char word_phonemes[]);
static int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, ALPHABET *current_alphabet);
static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word, const ALPHABET *current_alphabet, char word_phonemes[]);
static int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, const ALPHABET *current_alphabet);
static int Unpronouncable(Translator *tr, char *word, int posn); static int Unpronouncable(Translator *tr, char *word, int posn);
static int Unpronouncable2(Translator *tr, char *word); static int Unpronouncable2(Translator *tr, char *word);


*word = 0; *word = 0;
} }


static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word, ALPHABET *current_alphabet, char word_phonemes[])
static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word, const ALPHABET *current_alphabet, char word_phonemes[])
{ {
int posn = 0; int posn = 0;
int capitals = 0; int capitals = 0;
}; };




static int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, ALPHABET *current_alphabet)
static int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, const ALPHABET *current_alphabet)
{ {
// get pronunciation for an isolated letter // get pronunciation for an isolated letter
// return number of bytes used by the letter // return number of bytes used by the letter
int n_bytes; int n_bytes;
int letter; int letter;
int len; int len;
ALPHABET *alphabet;
const ALPHABET *alphabet;
int al_offset; int al_offset;
int al_flags; int al_flags;
int number; int number;
int vowel_posn = 9; int vowel_posn = 9;
int index; int index;
int count; int count;
ALPHABET *alphabet;
const ALPHABET *alphabet;


utf8_in(&c, word); utf8_in(&c, word);
if ((tr->letter_bits_offset > 0) && (c < 0x241)) { if ((tr->letter_bits_offset > 0) && (c < 0x241)) {

+ 3
- 7
src/libespeak-ng/wavegen.c View File



static void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v); static void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v);


voice_t *wvoice = NULL;
static voice_t *wvoice = NULL;


static int option_harmonic1 = 10; static int option_harmonic1 = 10;
static int flutter_amp = 64; static int flutter_amp = 64;
static int glottal_flag = 0; static int glottal_flag = 0;
static int glottal_reduce = 0; static int glottal_reduce = 0;


WGEN_DATA wdata;
static WGEN_DATA wdata;


static int amp_ix; static int amp_ix;
static int amp_inc; static int amp_inc;
unsigned char *out_end; unsigned char *out_end;


espeak_ng_OUTPUT_HOOKS* output_hooks = NULL; espeak_ng_OUTPUT_HOOKS* output_hooks = NULL;
int const_f0 = 0;
static int const_f0 = 0;


// the queue of operations passed to wavegen from sythesize // the queue of operations passed to wavegen from sythesize
intptr_t wcmdq[N_WCMDQ][4]; intptr_t wcmdq[N_WCMDQ][4];
int embedded_default[N_EMBEDDED_VALUES] = { 0, 50, espeakRATE_NORMAL, 100, 50, 0, 0, 0, espeakRATE_NORMAL, 0, 0, 0, 0, 0, 0 }; int embedded_default[N_EMBEDDED_VALUES] = { 0, 50, espeakRATE_NORMAL, 100, 50, 0, 0, 0, espeakRATE_NORMAL, 0, 0, 0, 0, 0, 0 };
static int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 }; static int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 };


int current_source_index = 0;

#if HAVE_SONIC_H #if HAVE_SONIC_H
static sonicStream sonicSpeedupStream = NULL; static sonicStream sonicSpeedupStream = NULL;
double sonicSpeed = 1.0; double sonicSpeed = 1.0;
case WCMD_MARKER: case WCMD_MARKER:
marker_type = q[0] >> 8; marker_type = q[0] >> 8;
MarkerEvent(marker_type, q[1], q[2], q[3], out_ptr); MarkerEvent(marker_type, q[1], q[2], q[3], out_ptr);
if (marker_type == 1) // word marker
current_source_index = q[1] & 0xffffff;
break; break;
case WCMD_AMPLITUDE: case WCMD_AMPLITUDE:
SetAmplitude(length, (unsigned char *)q[2], q[3]); SetAmplitude(length, (unsigned char *)q[2], q[3]);

Loading…
Cancel
Save