Browse Source

Return an espeak_ng_STATUS code in LoadSpectSeq.

master
Reece H. Dunn 9 years ago
parent
commit
ccb409c600

+ 2
- 0
src/include/espeak-ng/espeak_ng.h View File

@@ -48,6 +48,8 @@ typedef enum {
ENS_MBROLA_VOICE_NOT_FOUND = 0x100008FF,
ENS_EVENT_BUFFER_FULL = 0x100009FF,
ENS_NOT_SUPPORTED = 0x10000AFF,
ENS_UNSUPPORTED_SPECT_FORMAT = 0x10000BFF,
ENS_NO_SPECT_FRAMES = 0x10000CFF,
} espeak_ng_STATUS;

typedef enum {

+ 2
- 4
src/libespeak-ng/compiledata.c View File

@@ -1093,10 +1093,8 @@ int LoadSpect(const char *path, int control)
}

snprintf(filename, sizeof(filename), "%s/../phsource/%s", path_home, path);
LoadSpectSeq(spectseq, filename);

if (spectseq->frames == NULL) {
error("Bad vowel file, no frames: '%s'", path);
if (LoadSpectSeq(spectseq, filename) != ENS_OK) {
error("Bad vowel file: '%s'", path);
SpectSeqDestroy(spectseq);
return 0;
}

+ 6
- 5
src/libespeak-ng/spect.c View File

@@ -19,6 +19,7 @@

#include "config.h"

#include <errno.h>
#include <stdio.h>
#if HAVE_STDINT_H
#include <stdint.h>
@@ -272,7 +273,7 @@ static float GetFrameLength(SpectSeq *spect, int frame)
return (spect->frames[ix]->time - spect->frames[frame]->time) * 1000.0 + adjust;
}

int LoadSpectSeq(SpectSeq *spect, const char *filename)
espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename)
{
short n, temp;
int ix;
@@ -283,7 +284,7 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)
FILE *stream = fopen(filename, "rb");
if (stream == NULL) {
fprintf(stderr, "Failed to open: '%s'", filename);
return 0;
return errno;
}

fread(&id1, sizeof(uint32_t), 1, stream);
@@ -298,7 +299,7 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)
else {
fprintf(stderr, "Unsupported spectral file format.\n");
fclose(stream);
return 1;
return ENS_UNSUPPORTED_SPECT_FORMAT;
}

fread(&name_len, sizeof(uint32_t), 1, stream);
@@ -315,7 +316,7 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)

if (n == 0) {
fclose(stream);
return 0;
return ENS_NO_SPECT_FRAMES;
}

if (spect->frames != NULL) {
@@ -371,5 +372,5 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)
spect->frames[ix]->length_adjust = spect->frames[ix]->length - GetFrameLength(spect, ix);
}
fclose(stream);
return 0;
return ENS_OK;
}

+ 2
- 2
src/libespeak-ng/spect.h View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005 to 2007 by Jonathan Duddington
* email: [email protected]
* Copyright (C) 2013-2015 Reece H. Dunn
* Copyright (C) 2013-2016 Reece H. Dunn
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -126,7 +126,7 @@ typedef struct {

SpectSeq *SpectSeqCreate();
void SpectSeqDestroy(SpectSeq *spect);
int LoadSpectSeq(SpectSeq *spect, const char *filename);
espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename);

#ifdef __cplusplus
}

Loading…
Cancel
Save