Skip to content

Commit

Permalink
Minimal exports needed for Windows DLL build
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Sep 16, 2022
1 parent 3562090 commit c9b9640
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/bin_mdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern "C" {
#endif

#include <pocketsphinx.h>
#include <pocketsphinx/export.h>

#include "util/mmio.h"
#include "mdef.h"
Expand Down Expand Up @@ -166,21 +167,25 @@ struct bin_mdef_s {
/**
* Read a binary mdef from a file.
*/
POCKETSPHINX_EXPORT
bin_mdef_t *bin_mdef_read(ps_config_t *config, const char *filename);

/**
* Read a text mdef from a file (creating an in-memory binary mdef).
*/
POCKETSPHINX_EXPORT
bin_mdef_t *bin_mdef_read_text(ps_config_t *config, const char *filename);

/**
* Write a binary mdef to a file.
*/
POCKETSPHINX_EXPORT
int bin_mdef_write(bin_mdef_t *m, const char *filename);

/**
* Write a binary mdef to a text file.
*/
POCKETSPHINX_EXPORT
int bin_mdef_write_text(bin_mdef_t *m, const char *filename);

/**
Expand Down
2 changes: 2 additions & 0 deletions src/dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ dict_t *dict_init(ps_config_t *config, /**< Configuration (-dict, -fdict, -dictc
int dict_write(dict_t *dict, char const *filename, char const *format);

/** Return word id for given word string if present. Otherwise return BAD_S3WID */
POCKETSPHINX_EXPORT
s3wid_t dict_wordid(dict_t *d, const char *word);

/**
Expand All @@ -125,6 +126,7 @@ int dict_filler_word(dict_t *d, /**< The dictionary structure */
/**
* Test if w is a "real" word, i.e. neither a filler word nor START/FINISH.
*/
POCKETSPHINX_EXPORT
int dict_real_word(dict_t *d, /**< The dictionary structure */
s3wid_t w /**< The word ID */
);
Expand Down
7 changes: 7 additions & 0 deletions src/fe/yin.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern "C" {
#endif

#include <pocketsphinx/prim_type.h>
#include <pocketsphinx/export.h>

/**
* Frame-based moving-window pitch estimator.
Expand All @@ -59,22 +60,26 @@ typedef struct yin_s yin_t;
/**
* Initialize moving-window pitch estimation.
*/
POCKETSPHINX_EXPORT
yin_t *yin_init(int frame_size, float search_threshold,
float search_range, int smooth_window);

/**
* Free a moving-window pitch estimator.
*/
POCKETSPHINX_EXPORT
void yin_free(yin_t *pe);

/**
* Start processing an utterance.
*/
POCKETSPHINX_EXPORT
void yin_start(yin_t *pe);

/**
* Mark the end of an utterance.
*/
POCKETSPHINX_EXPORT
void yin_end(yin_t *pe);

/**
Expand All @@ -84,6 +89,7 @@ void yin_end(yin_t *pe);
* @param frame Frame of <code>frame_size</code> (see
* yin_init()) samples of audio data.
*/
POCKETSPHINX_EXPORT
void yin_write(yin_t *pe, int16 const *frame);

/**
Expand All @@ -99,6 +105,7 @@ void yin_write(yin_t *pe, int16 const *frame);
* @return Non-zero if enough data was avaliable to return a pitch
* estimate, zero otherwise.
*/
POCKETSPHINX_EXPORT
int yin_read(yin_t *pe, uint16 *out_period, uint16 *out_bestdiff);

#ifdef __cplusplus
Expand Down
10 changes: 10 additions & 0 deletions src/lm/fsg_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include <string.h>

#include <pocketsphinx.h>
#include <pocketsphinx/export.h>

#include "util/glist.h"
#include "util/bitvec.h"
#include "util/hash_table.h"
Expand Down Expand Up @@ -190,6 +192,7 @@ fsg_model_t *fsg_model_init(char const *name, logmath_t *lmath,
* Return value: a new fsg_model_t structure if the file is successfully
* read, NULL otherwise.
*/
POCKETSPHINX_EXPORT
fsg_model_t *fsg_model_readfile(const char *file, logmath_t *lmath, float32 lw);

/**
Expand Down Expand Up @@ -255,6 +258,7 @@ int32 fsg_model_tag_trans_add(fsg_model_t * fsg, int32 from, int32 to,
* @param nulls List of null transitions, or NULL to find them automatically.
* @return Updated list of null transitions.
*/
POCKETSPHINX_EXPORT
glist_t fsg_model_null_trans_closure(fsg_model_t * fsg, glist_t nulls);

/**
Expand Down Expand Up @@ -304,31 +308,37 @@ int fsg_model_add_alt(fsg_model_t * fsg, char const *baseword,
/**
* Write FSG to a file.
*/
POCKETSPHINX_EXPORT
void fsg_model_write(fsg_model_t *fsg, FILE *fp);

/**
* Write FSG to a file.
*/
POCKETSPHINX_EXPORT
void fsg_model_writefile(fsg_model_t *fsg, char const *file);

/**
* Write FSG to a file in AT&T FSM format.
*/
POCKETSPHINX_EXPORT
void fsg_model_write_fsm(fsg_model_t *fsg, FILE *fp);

/**
* Write FSG to a file in AT&T FSM format.
*/
POCKETSPHINX_EXPORT
void fsg_model_writefile_fsm(fsg_model_t *fsg, char const *file);

/**
* Write FSG symbol table to a file (for AT&T FSM)
*/
POCKETSPHINX_EXPORT
void fsg_model_write_symtab(fsg_model_t *fsg, FILE *file);

/**
* Write FSG symbol table to a file (for AT&T FSM)
*/
POCKETSPHINX_EXPORT
void fsg_model_writefile_symtab(fsg_model_t *fsg, char const *file);

#ifdef __cplusplus
Expand Down
6 changes: 6 additions & 0 deletions src/lm/jsgf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

/* Not much here anymore! */
#include <pocketsphinx/model.h>
#include <pocketsphinx/export.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -65,6 +66,11 @@ extern "C" {
*/
jsgf_t *jsgf_grammar_new(jsgf_t *parent);

POCKETSPHINX_EXPORT
fsg_model_t *jsgf_build_fsg_raw(jsgf_t * grammar, jsgf_rule_t * rule,
logmath_t * lmath, float32 lw);


#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 9 additions & 1 deletion src/util/ckd_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
#include <setjmp.h>

#include <pocketsphinx/prim_type.h>
#include <pocketsphinx/export.h>


/** \file ckd_alloc.h
*\brief Sphinx's memory allocation/deallocation routines.
Expand Down Expand Up @@ -136,27 +138,31 @@ void ckd_fail(char *format, ...);
* message if any error occurs, with any other behaviour determined by
* ckd_set_jump(), above.
*/

POCKETSPHINX_EXPORT
void *__ckd_calloc__(size_t n_elem, size_t elem_size,
const char *caller_file, int caller_line);

POCKETSPHINX_EXPORT
void *__ckd_malloc__(size_t size,
const char *caller_file, int caller_line);

POCKETSPHINX_EXPORT
void *__ckd_realloc__(void *ptr, size_t new_size,
const char *caller_file, int caller_line);

/**
* Like strdup, except that if an error occurs it prints a diagnostic message and
* exits. If origin in NULL the function also returns NULL.
*/
POCKETSPHINX_EXPORT
char *__ckd_salloc__(const char *origstr,
const char *caller_file, int caller_line);

/**
* Allocate a 2-D array and return ptr to it (ie, ptr to vector of ptrs).
* The data area is allocated in one block so it can also be treated as a 1-D array.
*/
POCKETSPHINX_EXPORT
void *__ckd_calloc_2d__(size_t d1, size_t d2, /* In: #elements in the 2 dimensions */
size_t elemsize, /* In: Size (#bytes) of each element */
const char *caller_file, int caller_line); /* In */
Expand Down Expand Up @@ -205,11 +211,13 @@ void *__ckd_alloc_2d_ptr(size_t d1,
/**
* Test and free a 1-D array
*/
POCKETSPHINX_EXPORT
void ckd_free(void *ptr);

/**
* Free a 2-D array (ptr) previously allocated by ckd_calloc_2d
*/
POCKETSPHINX_EXPORT
void ckd_free_2d(void *ptr);

/**
Expand Down
4 changes: 4 additions & 0 deletions src/util/cmd_ln.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include <stdarg.h>

#include <pocketsphinx.h>
#include <pocketsphinx/export.h>

#include "util/hash_table.h"

Expand Down Expand Up @@ -193,6 +194,7 @@ int cmd_ln_free_r(cmd_ln_t *cmdln);
* @return A cmd_ln_t containing the results of command line parsing,
* or NULL on failure.
**/
POCKETSPHINX_EXPORT
cmd_ln_t *cmd_ln_parse_r(cmd_ln_t *inout_cmdln, /**< In/Out: Previous command-line to update,
or NULL to create a new one. */
arg_t const *defn, /**< In: Array of argument name definitions */
Expand All @@ -211,6 +213,7 @@ cmd_ln_t *cmd_ln_parse_r(cmd_ln_t *inout_cmdln, /**< In/Out: Previous command-li
*
* @return A cmd_ln_t containing the results of command line parsing, or NULL on failure.
*/
POCKETSPHINX_EXPORT
cmd_ln_t *cmd_ln_parse_file_r(cmd_ln_t *inout_cmdln, /**< In/Out: Previous command-line to update,
or NULL to create a new one. */
arg_t const *defn, /**< In: Array of argument name definitions*/
Expand Down Expand Up @@ -256,6 +259,7 @@ void cmd_ln_set_str_extra_r(cmd_ln_t *cmdln, char const *name, char const *str);
* @param cmdln command-line object
* @param defn array of argument name definitions.
*/
POCKETSPHINX_EXPORT
void cmd_ln_log_help_r (cmd_ln_t *cmdln, const arg_t *defn);

/**
Expand Down
2 changes: 2 additions & 0 deletions src/util/filename.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#define _LIBUTIL_FILENAME_H_

#include <pocketsphinx/prim_type.h>
#include <pocketsphinx/export.h>

/**\file filename.h
*\brief File names related operation
Expand All @@ -83,6 +84,7 @@ const char *path2basename(const char *path);
* Strip off filename from the given path and copy the directory name into dir
* Caller must have allocated dir (hint: it's always shorter than path).
*/
POCKETSPHINX_EXPORT
void path2dirname(const char *path, char *dir);


Expand Down
5 changes: 5 additions & 0 deletions src/util/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#endif

#include <pocketsphinx/prim_type.h>
#include <pocketsphinx/export.h>

/** \file pio.h
* \brief file IO related operations.
Expand Down Expand Up @@ -161,6 +162,7 @@ int32 fread_retry(void *pointer, int32 size, int32 num_items, FILE *stream);
* @param out_len Output: if not NULL, length of the string read.
* @return allocated string containing the line, or NULL on error or EOF.
*/
POCKETSPHINX_EXPORT
char *fread_line(FILE *stream, size_t *out_len);

/**
Expand All @@ -178,6 +180,7 @@ typedef struct lineiter_t {
/**
* Start reading lines from a file.
*/
POCKETSPHINX_EXPORT
lineiter_t *lineiter_start(FILE *fh);

/**
Expand All @@ -188,6 +191,7 @@ lineiter_t *lineiter_start_clean(FILE *fh);
/**
* Move to the next line in the file.
*/
POCKETSPHINX_EXPORT
lineiter_t *lineiter_next(lineiter_t *li);

/**
Expand Down Expand Up @@ -277,6 +281,7 @@ int32 stat_mtime (const char *file);
*
* @return 0 on success, <0 on failure.
*/
POCKETSPHINX_EXPORT
int build_directory(const char *path);

#ifdef __cplusplus
Expand Down
5 changes: 5 additions & 0 deletions src/util/strfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <stdarg.h>

#include <pocketsphinx/prim_type.h>
#include <pocketsphinx/export.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -58,6 +59,7 @@ extern "C" {
* Concatenate a NULL-terminated argument list of strings, returning a
* newly allocated string.
**/
POCKETSPHINX_EXPORT
char *string_join(const char *base, ...);

/**
Expand All @@ -75,6 +77,7 @@ enum string_edge_e {
* @param string string to trim, contents will be modified.
* @param which one of STRING_START, STRING_END, or STRING_BOTH.
*/
POCKETSPHINX_EXPORT
char *string_trim(char *string, enum string_edge_e which);

/**
Expand All @@ -84,6 +87,7 @@ char *string_trim(char *string, enum string_edge_e which);
* locale in a threaded program is extremely uncool, therefore we need
* this since we pass floats as strings in 1000 different places.
*/
POCKETSPHINX_EXPORT
double atof_c(char const *str);

/* FIXME: Both of these string splitting functions basically suck. I
Expand All @@ -96,6 +100,7 @@ double atof_c(char const *str);
* every word in the line.
* Return value: No. of words found; -1 if no. of words in line exceeds n_wptr.
*/
POCKETSPHINX_EXPORT
int32 str2words (char *line, /**< In/Out: line to be parsed. This
string will be modified! (NUL
characters inserted at word
Expand Down

0 comments on commit c9b9640

Please sign in to comment.