This will allow the espeak-ng methods to provide more context information for the errors that can then be used in things like GUI applications.master
ENOUTPUT_MODE_SPEAK_AUDIO = 0x0002, | ENOUTPUT_MODE_SPEAK_AUDIO = 0x0002, | ||||
} espeak_ng_OUTPUT_MODE; | } espeak_ng_OUTPUT_MODE; | ||||
typedef struct espeak_ng_ERROR_CONTEXT_ *espeak_ng_ERROR_CONTEXT; | |||||
ESPEAK_NG_API void | |||||
espeak_ng_ClearErrorContext(espeak_ng_ERROR_CONTEXT *context); | |||||
ESPEAK_NG_API void | ESPEAK_NG_API void | ||||
espeak_ng_GetStatusCodeMessage(espeak_ng_STATUS status, | espeak_ng_GetStatusCodeMessage(espeak_ng_STATUS status, | ||||
char *buffer, | char *buffer, |
#include <stdint.h> | #include <stdint.h> | ||||
#endif | #endif | ||||
#include <string.h> | #include <string.h> | ||||
#include <malloc.h> | |||||
#include "espeak_ng.h" | #include "espeak_ng.h" | ||||
#include "error.h" | |||||
#include "speech.h" | #include "speech.h" | ||||
#include "phoneme.h" | #include "phoneme.h" | ||||
#include "synthesize.h" | #include "synthesize.h" | ||||
espeak_ng_STATUS create_file_error_context(espeak_ng_ERROR_CONTEXT *context, espeak_ng_STATUS status, const char *filename) | |||||
{ | |||||
if (context) { | |||||
if (*context) { | |||||
free((*context)->filename); | |||||
} else { | |||||
*context = malloc(sizeof(espeak_ng_ERROR_CONTEXT_)); | |||||
} | |||||
(*context)->filename = strdup(filename); | |||||
} | |||||
return status; | |||||
} | |||||
#pragma GCC visibility push(default) | #pragma GCC visibility push(default) | ||||
ESPEAK_NG_API void espeak_ng_ClearErrorContext(espeak_ng_ERROR_CONTEXT *context) | |||||
{ | |||||
if (context && *context) { | |||||
free((*context)->filename); | |||||
free(*context); | |||||
*context = NULL; | |||||
} | |||||
} | |||||
ESPEAK_NG_API void espeak_ng_GetStatusCodeMessage(espeak_ng_STATUS status, char *buffer, size_t length) | ESPEAK_NG_API void espeak_ng_GetStatusCodeMessage(espeak_ng_STATUS status, char *buffer, size_t length) | ||||
{ | { | ||||
switch (status) | switch (status) |
/* Internal error APIs. | |||||
* | |||||
* Copyright (C) 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 | |||||
* the Free Software Foundation; either version 3 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* This program is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with this program; if not, see: <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
#ifndef ESPEAK_NG_ERROR_API | |||||
#define ESPEAK_NG_ERROR_API | |||||
#ifdef __cplusplus | |||||
extern "C" | |||||
{ | |||||
#endif | |||||
typedef struct espeak_ng_ERROR_CONTEXT_ | |||||
{ | |||||
char *filename; | |||||
} espeak_ng_ERROR_CONTEXT_; | |||||
espeak_ng_STATUS | |||||
create_file_error_context(espeak_ng_ERROR_CONTEXT *context, | |||||
espeak_ng_STATUS status, | |||||
const char *filename); | |||||
#ifdef __cplusplus | |||||
} | |||||
#endif | |||||
#endif |