Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
Hide implementation details for Android
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.code.sf.net/p/cmusphinx/code/trunk/sphinxbase@12039 94700074-3cef-4d97-a70e-9c8c206c02f5
  • Loading branch information
nshmyrev committed Nov 8, 2013
1 parent efa9c89 commit 6b52f60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
22 changes: 0 additions & 22 deletions include/sphinxbase/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
/* Win32/WinCE DLL gunk */
#include <sphinxbase/sphinxbase_export.h>

#ifdef __ANDROID__
#include <android/log.h>
#endif

/**
* @file err.h
* @brief Implementation of logging routines.
Expand Down Expand Up @@ -164,38 +160,20 @@ extern "C" {
#endif

typedef enum err_e {
#ifdef __ANDROID__
ERR_DEBUG = ANDROID_LOG_DEBUG,
ERR_INFOCONT = ANDROID_LOG_INFO,
ERR_INFO = ANDROID_LOG_INFO,
ERR_WARN = ANDROID_LOG_WARN,
ERR_ERROR = ANDROID_LOG_ERROR,
ERR_FATAL = ANDROID_LOG_ERROR
#else
ERR_DEBUG,
ERR_INFO,
ERR_INFOCONT,
ERR_WARN,
ERR_ERROR,
ERR_FATAL,
ERR_MAX
#endif
} err_lvl_t;

SPHINXBASE_EXPORT void
err_msg(err_lvl_t lvl, const char *path, long ln, const char *fmt, ...);

#if defined __ANDROID__
SPHINXBASE_EXPORT void
err_logcat_cb(void* user_data, err_lvl_t level, const char *fmt, ...);
#elif defined _WIN32_WCE
SPHINXBASE_EXPORT void
err_wince_cb(void* user_data, err_lvl_t level, const char *fmt, ...);
#else
SPHINXBASE_EXPORT void
err_logfp_cb(void * user_data, err_lvl_t level, const char *fmt, ...);
#endif


typedef void (*err_cb_f)(void* user_data, err_lvl_t, const char *, ...);

Expand Down
22 changes: 19 additions & 3 deletions src/libsphinxbase/util/err.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ static int logfp_disabled = FALSE;
static int sphinx_debug_level;

#if defined __ANDROID__

#ifdef __ANDROID__
#include <android/log.h>
#endif

#if defined __ANDROID__
static void
err_logcat_cb(void* user_data, err_lvl_t level, const char *fmt, ...);
#elif defined _WIN32_WCE
static void
err_wince_cb(void* user_data, err_lvl_t level, const char *fmt, ...);
#endif

static err_cb_f err_cb = err_logcat_cb;
#elif defined _WIN32_WCE
static err_cb_f err_cb = err_wince_cb;
Expand Down Expand Up @@ -98,16 +111,19 @@ err_msg(err_lvl_t lvl, const char *path, long ln, const char *fmt, ...)
}

#if defined __ANDROID__
void
static void
err_logcat_cb(void *user_data, err_lvl_t lvl, const char *fmt, ...)
{
static const int android_level[ERR_MAX] = {ANDROID_LOG_DEBUG, ANDROID_LOG_INFO,
ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_ERROR};

va_list ap;
va_start(ap, fmt);
__android_log_vprint(lvl, "cmusphinx", fmt, ap);
__android_log_vprint(android_level[lvl], "cmusphinx", fmt, ap);
va_end(ap);
}
#elif defined _WIN32_WCE
void
static void
err_wince_cb(void *user_data, err_lvl_t lvl, const char *fmt, ...)
{
char msg[1024];
Expand Down

0 comments on commit 6b52f60

Please sign in to comment.