mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-13 01:07:47 +00:00
Ensure that the old translator is not used after calling espeak_Terminate.
This commit is contained in:
@@ -899,6 +899,7 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_Terminate(void)
|
||||
outbuf = NULL;
|
||||
FreePhData();
|
||||
FreeVoiceList();
|
||||
translator = NULL;
|
||||
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
+12
@@ -37,9 +37,11 @@ test_espeak_terminate_without_initialize()
|
||||
printf("testing espeak_Terminate without espeak_Initialize\n");
|
||||
|
||||
assert(event_list == NULL);
|
||||
assert(translator == NULL);
|
||||
|
||||
assert(espeak_Terminate() == EE_OK);
|
||||
assert(event_list == NULL);
|
||||
assert(translator == NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -48,12 +50,15 @@ test_espeak_initialize()
|
||||
printf("testing espeak_Initialize\n");
|
||||
|
||||
assert(event_list == NULL);
|
||||
assert(translator == NULL);
|
||||
|
||||
assert(espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, NULL, 0) == 22050);
|
||||
assert(event_list != NULL);
|
||||
assert(translator == NULL);
|
||||
|
||||
assert(espeak_Terminate() == EE_OK);
|
||||
assert(event_list == NULL);
|
||||
assert(translator == NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -62,16 +67,22 @@ test_espeak_synth()
|
||||
printf("testing espeak_Synth\n");
|
||||
|
||||
assert(event_list == NULL);
|
||||
assert(translator == NULL);
|
||||
|
||||
assert(espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 0, NULL, 0) == 22050);
|
||||
assert(event_list != NULL);
|
||||
assert(translator == NULL);
|
||||
|
||||
const char *test = "One two three.";
|
||||
assert(espeak_Synth(test, strlen(test)+1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL) == EE_OK);
|
||||
assert(translator != NULL);
|
||||
|
||||
assert(espeak_Synchronize() == EE_OK);
|
||||
assert(translator != NULL);
|
||||
|
||||
assert(espeak_Terminate() == EE_OK);
|
||||
assert(event_list == NULL);
|
||||
assert(translator == NULL);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -81,6 +92,7 @@ main(int argc, char **argv)
|
||||
test_espeak_initialize();
|
||||
|
||||
test_espeak_synth();
|
||||
test_espeak_synth(); // Check that this does not crash when run a second time.
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user