view src/xs_support.h @ 957:0e60e5d56fdd

Change how the backend emulator library is initialized for libSIDPlay2 and FP, as it seems the engine configuration has some persistence despite reconfiguration between loaded files if same engine object is retained. This caused, for example, 2SID stereo tunes being played "mono" if played after a normal 1-SID tune. Duh.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 20 Nov 2012 22:13:48 +0200
parents 3c2efa18c422
children 0233c5fd7d5e
line wrap: on
line source

#ifndef XS_SUPPORT_H
#define XS_SUPPORT_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib.h>
#include <stdio.h>
#include <ctype.h>
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifdef AUDACIOUS_PLUGIN
#include <audacious/plugin.h>
#include <audacious/output.h>
#else
#include <xmms/plugin.h>
#include <xmms/util.h>
#include <xmms/titlestring.h>
#endif

#ifdef HAVE_ASSERT_H
#include <assert.h>
#else
#define assert(x) /* stub */
#endif

#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#endif

#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif


/* Standard gettext macros
 */
#ifdef ENABLE_NLS
#  include <libintl.h>
#  undef _
#  define _(String) dgettext (PACKAGE, String)
#  ifdef gettext_noop
#    define N_(String) gettext_noop (String)
#  else
#    define N_(String) (String)
#  endif
#else
#  define _LIBINTL_H
#  define textdomain(String) (String)
#  define gettext(String) (String)
#  define dgettext(Domain,Message) (Message)
#  define dcgettext(Domain,Message,Type) (Message)
#  define bindtextdomain(Domain,Directory) (Domain)
#  define _(String) (String)
#  define N_(String) (String)
#endif


/* Typedefs
 */
#ifdef AUDACIOUS_PLUGIN
#include <audacious/audutil.h>
#define XS_MD5HASH_LENGTH      AUD_MD5HASH_LENGTH
#define XS_MD5HASH_LENGTH_CH   AUD_MD5HASH_LENGTH_CH
#define xs_md5hash_t           aud_md5hash_t
#define xs_md5state_t          aud_md5state_t
#define xs_md5_init            aud_md5_init
#define xs_md5_append          aud_md5_append
#define xs_md5_finish          aud_md5_finish
#else

typedef struct md5_state_s {
    guint32 bits[2];    /* message length in bits, lsw first */
    guint32 buf[4];     /* digest buffer */
    guint8 in[64];      /* accumulate block */
} xs_md5state_t;

#define XS_MD5HASH_LENGTH       (16)
#define XS_MD5HASH_LENGTH_CH    (XS_MD5HASH_LENGTH * 2)

typedef guint8 xs_md5hash_t[XS_MD5HASH_LENGTH];

#endif /* AUDACIOUS_PLUGIN */


/* VFS replacement functions
 */
#ifdef __AUDACIOUS_NEWVFS__
#define XSFile VFSFile
#define xs_fopen(a,b) aud_vfs_fopen(a,b)
#define xs_fclose(a) aud_vfs_fclose(a)
#define xs_fgetc(a) aud_vfs_getc(a)
#define xs_fread(a,b,c,d) aud_vfs_fread(a,b,c,d)
#define xs_feof(a) aud_vfs_feof(a)
#define xs_ferror(a) (0)
#define xs_ftell(a) aud_vfs_ftell(a)
#define xs_fseek(a,b,c) aud_vfs_fseek(a,b,c)
#define xs_fsize(a) aud_vfs_fsize(a)
#else
#define XSFile FILE
#define xs_fopen(a,b) fopen(a,b)
#define xs_fclose(a) fclose(a)
#define xs_fgetc(a) fgetc(a)
#define xs_fread(a,b,c,d) fread(a,b,c,d)
#define xs_feof(a) feof(a)
#define xs_ferror(a) ferror(a)
#define xs_ftell(a) ftell(a)
#define xs_fseek(a,b,c) fseek(a,b,c)
off_t   xs_fsize(XSFile *f);
#endif

gboolean xs_fread_str(XSFile *, void *, const size_t);
gboolean xs_fread_byte(XSFile *, guint8 *);
gboolean xs_fread_be16(XSFile *, guint16 *);
gboolean xs_fread_be32(XSFile *, guint32 *);

gboolean xs_fload_buffer(const gchar *filename,
    guint8 **pbuf, size_t *bufSize, const size_t maxSize, gboolean failMaxSize);
gboolean xs_fload_buffer_path(const gchar *ppath, const gchar *pfilename,
    guint8 **pbuf, size_t *bufSize, const size_t maxSize, gboolean failMaxSize);

gboolean xs_is_dir_path(const gchar *path);
gchar *  xs_get_dir_path(const gchar *path);


/* Error messages and debugging
 */
void    xs_error(const char *, ...);


/* Misc functions
 */
gint    xs_pstrcpy(gchar **, const gchar *);
gint    xs_pstrcat(gchar **, const gchar *);
void    xs_pnstrcat(gchar *, size_t, const gchar *);
void    xs_findnext(const gchar *, size_t *);
void    xs_findeol(const gchar *, size_t *);
void    xs_findnum(const gchar *, size_t *);


#ifndef AUDACIOUS_PLUGIN
void    xs_md5_init(xs_md5state_t *ctx);
void    xs_md5_append(xs_md5state_t *ctx, const guint8 *buf, guint len);
void    xs_md5_finish(xs_md5state_t *ctx, xs_md5hash_t digest);
#endif

#ifdef __cplusplus
}
#endif
#endif /* XS_SUPPORT_H */