glib is now a dependency, lots of platform specific code moved to glib, implemented initial WIN32 TCP socket code (not tested).

This commit is contained in:
Josh Green 2009-04-27 19:13:49 +00:00
parent 7de961292b
commit 5fcedecdfd
18 changed files with 483 additions and 1015 deletions

View file

@ -1,3 +1,24 @@
2009-04-26 Josh Green <jgreen@users.sourceforge.net>
* configure.ac: Added glib 2.10 as a dependency, added notes in output
for LASH, LADCCA and READLINE that they are GPL.
* src/fluid_io.c: Moved code to fluid_sys.c and removed.
* src/config_win32.h: Added "typedef int socklen_t" definition.
* src/fluid_defsfont.h: Removed glib ripped code.
* src/fluid_oss.c: Fixed warnings where return value of write() was
being ignored.
* src/fluid_sys.c: Re-organized, implemented portable fluid_curtime() and
fluid_utime() using glib functions and removed old platform specific
code, implemented fluid_thread functionality using glib and removed
old platform specific code, fluid_istream_readline(), fluid_istream_gets()
and fluid_ostream_printf() should now work on WIN32 also, added code
for WIN32 for TCP sockets (not yet tested).
* src/fluid_sys.h: Added fluid_gerror_message() macro to extract message
safely from GError structures, replaced fluid_mutex macros with
portable implementations using glib, removed new_fluid_client_socket()
and delete_fluid_client_socket() which were never implemented or used.
* src/fluidsynth.c: Added call to g_thread_init().
* src/fluidsynth_priv.h: Integer types now use glib integer types.
2009-04-11 Josh Green <jgreen@users.sourceforge.net>
* FluidSynth release 1.0.9 "A Sound Future"
* configure.ac: Bumped version, no library interfaces added, removed or changed.

View file

@ -7,8 +7,8 @@ AC_INIT(src/fluidsynth.c)
dnl *** NOTE *** Don't forget to update library version below also
FLUIDSYNTH_VERSION_MAJOR=1
FLUIDSYNTH_VERSION_MINOR=0
FLUIDSYNTH_VERSION_MICRO=9
FLUIDSYNTH_VERSION_MINOR=1
FLUIDSYNTH_VERSION_MICRO=0
FLUIDSYNTH_VERSION=$FLUIDSYNTH_VERSION_MAJOR.$FLUIDSYNTH_VERSION_MINOR.$FLUIDSYNTH_VERSION_MICRO
AC_SUBST(FLUIDSYNTH_VERSION_MAJOR)
@ -145,6 +145,11 @@ else
AC_DEFINE(DEBUG, 0, [Define to activate debugging message])
fi
dnl Assert that glib and gthread are available
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.10 gthread-2.0 >= 2.10)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
dnl
dnl Check support for all the drivers
@ -466,13 +471,13 @@ else
fi
if test "${LASH_FOUND}" = "yes"; then
echo "LASH support: yes"
echo "LASH support: yes (NOTE: GPL library)"
else
echo "LASH support: no"
fi
if test "${LADCCA_FOUND}" = "yes"; then
echo "LADCCA support: yes"
echo "LADCCA support: yes (NOTE: GPL library)"
else
echo "LADCCA support: no"
fi
@ -490,7 +495,7 @@ dnl echo "Sound file: no"
dnl fi
if test "$WITH_READLINE" = "1"; then
echo "Readline: yes"
echo "Readline: yes (NOTE: GPL library)"
else
echo "Readline: no"
fi

View file

@ -10,13 +10,6 @@
attribute="Supported-Project-Types"
value="automake"/>
</plugin>
<plugin name="Symbol Browser"
url="http://anjuta.org/plugins/"
mandatory="yes">
<require group="Anjuta Plugin"
attribute="Location"
value="anjuta-symbol-browser:SymbolBrowserPlugin"/>
</plugin>
<plugin name="Make Build System"
url="http://anjuta.org/plugins/"
mandatory="yes">
@ -27,13 +20,6 @@
attribute="Supported-Build-Types"
value="make"/>
</plugin>
<plugin name="Task Manager"
url="http://anjuta.org/plugins/"
mandatory="no">
<require group="Anjuta Plugin"
attribute="Interfaces"
value="IAnjutaTodo"/>
</plugin>
<plugin name="Debug Manager"
url="http://anjuta.org/plugins/"
mandatory="no">

View file

@ -86,8 +86,6 @@ libfluidsynth_la_SOURCES = \
fluid_gen.h \
fluid_hash.c \
fluid_hash.h \
fluid_io.c \
fluid_io.h \
fluid_ladspa.c \
fluid_ladspa.h \
fluid_lash.h \
@ -126,11 +124,12 @@ libfluidsynth_la_SOURCES = \
INCLUDES = -I$(top_srcdir)/include $(LASH_CFLAGS) $(LADCCA_CFLAGS) \
$(READLINE_CFLAGS) $(JACK_CFLAGS) $(ALSA_CFLAGS) $(PULSE_CFLAGS) \
$(PORTAUDIO_CFLAGS) $(DART_CFLAGS)
$(PORTAUDIO_CFLAGS) $(DART_CFLAGS) $(GLIB_CFLAGS)
libfluidsynth_la_LIBADD = $(LIBFLUID_LIBS) $(LASH_LIBS) $(LADCCA_LIBS) \
$(READLINE_LIBS) $(COREAUDIO_LIBS) $(COREMIDI_LIBS) $(JACK_LIBS) \
$(ALSA_LIBS) $(PULSE_LIBS) $(PORTAUDIO_LIBS) $(DART_LIBS)
$(ALSA_LIBS) $(PULSE_LIBS) $(PORTAUDIO_LIBS) $(DART_LIBS) \
$(GLIB_LIBS)
libfluidsynth_la_LDFLAGS = \
-version-info @LT_VERSION_INFO@ \

View file

@ -1,5 +1,8 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Define to enable ALSA driver */
#undef ALSA_SUPPORT
@ -187,9 +190,17 @@
/* Define to use the readline library for line editing */
#undef WITH_READLINE
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */

View file

@ -38,3 +38,5 @@
#ifndef inline
#define inline __inline
#endif
typedef int socklen_t;

View file

@ -22,10 +22,8 @@
#include "fluid_cmd.h"
#include "fluid_synth.h"
#include "fluid_settings.h"
#include "fluid_io.h"
#include "fluid_hash.h"
#include "fluid_sys.h"
#include "fluid_io.h"
#include "fluid_midi_router.h"
#include "fluid_sfont.h"

View file

@ -22,7 +22,6 @@
#define _FLUID_CMD_H
#include "fluidsynth_priv.h"
#include "fluid_io.h"
void fluid_shell_settings(fluid_settings_t* settings);

View file

@ -325,88 +325,7 @@ SFData *sfload_file (const char * fname);
* Boston, MA 02111-1307, USA.
*/
/* Provide definitions for some commonly used macros.
* Some of them are only provided if they haven't already
* been defined. It is assumed that if they are already
* defined then the current definition is correct.
*/
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#define GPOINTER_TO_INT(p) ((int) (p))
#define GINT_TO_POINTER(i) ((void *) (i))
char* g_strdup (const char *str);
/* Provide simple macro statement wrappers (adapted from Perl):
* G_STMT_START { statements; } G_STMT_END;
* can be used as a single statement, as in
* if (x) G_STMT_START { ... } G_STMT_END; else ...
*
* For gcc we will wrap the statements within `({' and `})' braces.
* For SunOS they will be wrapped within `if (1)' and `else (void) 0',
* and otherwise within `do' and `while (0)'.
*/
#if !(defined (G_STMT_START) && defined (G_STMT_END))
# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
# define G_STMT_START (void)(
# define G_STMT_END )
# else
# if (defined (sun) || defined (__sun__))
# define G_STMT_START if (1)
# define G_STMT_END else (void)0
# else
# define G_STMT_START do
# define G_STMT_END while (0)
# endif
# endif
#endif
/* Basic bit swapping functions
*/
#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((unsigned short) ( \
(((unsigned short) (val) & (unsigned short) 0x00ffU) << 8) | \
(((unsigned short) (val) & (unsigned short) 0xff00U) >> 8)))
#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((unsigned int) ( \
(((unsigned int) (val) & (unsigned int) 0x000000ffU) << 24) | \
(((unsigned int) (val) & (unsigned int) 0x0000ff00U) << 8) | \
(((unsigned int) (val) & (unsigned int) 0x00ff0000U) >> 8) | \
(((unsigned int) (val) & (unsigned int) 0xff000000U) >> 24)))
#define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
#define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
#define GINT16_TO_LE(val) ((signed short) (val))
#define GUINT16_TO_LE(val) ((unsigned short) (val))
#define GINT16_TO_BE(val) ((signed short) GUINT16_SWAP_LE_BE (val))
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
#define GINT32_TO_LE(val) ((signed int) (val))
#define GUINT32_TO_LE(val) ((unsigned int) (val))
#define GINT32_TO_BE(val) ((signed int) GUINT32_SWAP_LE_BE (val))
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
/* The G*_TO_?E() macros are defined in glibconfig.h.
* The transformation is symmetric, so the FROM just maps to the TO.
*/
#define GINT16_FROM_LE(val) (GINT16_TO_LE (val))
#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val))
#define GINT16_FROM_BE(val) (GINT16_TO_BE (val))
#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val))
#define GINT32_FROM_LE(val) (GINT32_TO_LE (val))
#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val))
#define GINT32_FROM_BE(val) (GINT32_TO_BE (val))
#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val))
#include <glib.h>
/*-----------------------------------util.h----------------------------*/

View file

@ -1,121 +0,0 @@
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#include "fluidsynth_priv.h"
#include "fluid_io.h"
#if WITH_READLINE
#include <readline/readline.h>
#include <readline/history.h>
#endif
int fluid_istream_gets(fluid_istream_t in, char* buf, int len);
fluid_istream_t fluid_get_stdin()
{
#ifdef MACOS9
return 0; /* to be tested - Antoine 8/3/3 */
#else
return STDIN_FILENO;
#endif
}
fluid_ostream_t fluid_get_stdout()
{
#ifdef MACOS9
return 1; /* to be tested - Antoine 8/3/3 */
#else
return STDOUT_FILENO;
#endif
}
int fluid_istream_readline(fluid_istream_t in, char* prompt, char* buf, int len)
{
#if WITH_READLINE
if (in == fluid_get_stdin()) {
char* line;
line = readline(prompt);
if (line == NULL) {
return -1;
}
snprintf(buf, len, "%s", line);
buf[len - 1] = 0;
free(line);
return 1;
} else {
return fluid_istream_gets(in, buf, len);
}
#else
return fluid_istream_gets(in, buf, len);
#endif
}
/* FIXME */
int fluid_istream_gets(fluid_istream_t in, char* buf, int len)
{
char c;
int n;
buf[len - 1] = 0;
while (--len > 0) {
n = read(in, &c, 1);
if (n == 0) {
*buf++ = 0;
return 0;
}
if (n < 0) {
return n;
}
if ((c == '\n') || (c == '\r')) {
*buf++ = 0;
return 1;
}
*buf++ = c;
}
return -1;
}
int fluid_ostream_printf(fluid_ostream_t out, char* format, ...)
{
char buf[4096];
va_list args;
int len;
va_start(args, format);
len = vsnprintf(buf, 4095, format, args);
va_end(args);
if (len <= 0) {
printf("fluid_ostream_printf: buffer overflow");
return -1;
}
buf[4095] = 0;
/* return write(out, buf, len); */
return write(out, buf, strlen(buf));
}

View file

@ -1,42 +0,0 @@
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#ifndef _FLUID_IO_H
#define _FLUID_IO_H
/** Read a line from the input stream.
\returns 0 if end-of-stream, -1 if error, non zero otherwise
*/
int fluid_istream_readline(fluid_istream_t in, char* prompt, char* buf, int len);
/** Read a line from the input stream.
\returns The number of bytes written. If an error occured, -1 is
returned.
*/
int fluid_ostream_printf(fluid_ostream_t out, char* format, ...);
#endif /* _FLUID_IO_H */

View file

@ -34,7 +34,6 @@
#include "fluid_ladspa.h"
#include "fluid_synth.h"
#include "fluid_io.h"
/* Logging to stdout. */
//#define L(x) x;printf("\n");

View file

@ -24,7 +24,6 @@
#include "fluid_midi_router.h"
#include "fluid_midi.h"
#include "fluid_synth.h"
#include "fluid_io.h"
/**
* Create a new midi router.

View file

@ -593,7 +593,13 @@ fluid_oss_audio_run(void* d)
while (dev->cont)
{
dev->read (synth, len, buffer, 0, 2, buffer, 1, 2);
write (dev->dspfd, buffer, dev->buffer_byte_size);
if (write (dev->dspfd, buffer, dev->buffer_byte_size) < 0)
{
FLUID_LOG(FLUID_ERR, "Error writing to OSS sound device: %s",
g_strerror (errno));
break;
}
}
FLUID_LOG(FLUID_DBG, "Audio thread finished");
@ -629,7 +635,12 @@ fluid_oss_audio_run2(void* d)
fluid_synth_dither_s16 (&dither_index, buffer_size, left, right,
buffer, 0, 2, buffer, 1, 2);
write (dev->dspfd, buffer, dev->buffer_byte_size);
if (write (dev->dspfd, buffer, dev->buffer_byte_size) < 0)
{
FLUID_LOG(FLUID_ERR, "Error writing to OSS sound device: %s",
g_strerror (errno));
break;
}
}
FLUID_LOG(FLUID_DBG, "Audio thread finished");

File diff suppressed because it is too large Load diff

View file

@ -36,9 +36,19 @@
#ifndef _FLUID_SYS_H
#define _FLUID_SYS_H
#include <glib.h>
#include "fluidsynth_priv.h"
/**
* Macro used for safely accessing a message from a GError and using a default
* message if it is NULL.
* @param err Pointer to a GError to access the message field of.
* @return Message string
*/
#define fluid_gerror_message(err) ((err) ? err->message : "No error details")
void fluid_sys_config(void);
void fluid_log_config(void);
void fluid_time_config(void);
@ -72,40 +82,15 @@ int fluid_debug(int level, char * fmt, ...);
#endif
/** fluid_curtime() returns the current time in milliseconds. This time
should only be used in relative time measurements. */
/** fluid_utime() returns the time in micro seconds. this time should
only be used to measure duration (relative times). */
#if defined(WIN32)
#define fluid_curtime() GetTickCount()
double fluid_utime(void);
#elif defined(MACOS9)
#include <OSUtils.h>
#include <Timer.h>
unsigned int fluid_curtime();
#define fluid_utime() 0.0
#elif defined(__OS2__)
#if defined(__OS2__)
#define INCL_DOS
#include <os2.h>
typedef int socklen_t;
unsigned int fluid_curtime(void);
double fluid_utime(void);
#else
unsigned int fluid_curtime(void);
double fluid_utime(void);
#endif
unsigned int fluid_curtime(void);
double fluid_utime(void);
/**
@ -120,7 +105,7 @@ typedef int (*fluid_timer_callback_t)(void* data, unsigned int msec);
typedef struct _fluid_timer_t fluid_timer_t;
fluid_timer_t* new_fluid_timer(int msec, fluid_timer_callback_t callback,
void* data, int new_thread, int auto_destroy);
void* data, int new_thread, int auto_destroy);
int delete_fluid_timer(fluid_timer_t* timer);
int fluid_timer_join(fluid_timer_t* timer);
@ -132,34 +117,11 @@ int fluid_timer_stop(fluid_timer_t* timer);
*/
#if defined(MACOS9)
typedef int fluid_mutex_t;
#define fluid_mutex_init(_m) { (_m) = 0; }
#define fluid_mutex_destroy(_m)
#define fluid_mutex_lock(_m)
#define fluid_mutex_unlock(_m)
#elif defined(WIN32)
typedef HANDLE fluid_mutex_t;
#define fluid_mutex_init(_m) { (_m) = CreateMutex(NULL, 0, NULL); }
#define fluid_mutex_destroy(_m) if (_m) { CloseHandle(_m); }
#define fluid_mutex_lock(_m) WaitForSingleObject(_m, INFINITE)
#define fluid_mutex_unlock(_m) ReleaseMutex(_m)
#elif defined(__OS2__)
typedef HMTX fluid_mutex_t;
#define fluid_mutex_init(_m) { (_m) = 0; DosCreateMutexSem( NULL, &(_m), 0, FALSE ); }
#define fluid_mutex_destroy(_m) if (_m) { DosCloseMutexSem(_m); }
#define fluid_mutex_lock(_m) DosRequestMutexSem(_m, -1L)
#define fluid_mutex_unlock(_m) DosReleaseMutexSem(_m)
#else
typedef pthread_mutex_t fluid_mutex_t;
#define fluid_mutex_init(_m) pthread_mutex_init(&(_m), NULL)
#define fluid_mutex_destroy(_m) pthread_mutex_destroy(&(_m))
#define fluid_mutex_lock(_m) pthread_mutex_lock(&(_m))
#define fluid_mutex_unlock(_m) pthread_mutex_unlock(&(_m))
#endif
typedef GStaticMutex fluid_mutex_t;
#define fluid_mutex_init(_m) g_static_mutex_init(&(_m))
#define fluid_mutex_destroy(_m) g_static_mutex_free(&(_m))
#define fluid_mutex_lock(_m) g_static_mutex_lock(&(_m))
#define fluid_mutex_unlock(_m) g_static_mutex_unlock(&(_m))
/**
@ -167,7 +129,7 @@ typedef pthread_mutex_t fluid_mutex_t;
*/
typedef struct _fluid_thread_t fluid_thread_t;
typedef GThread fluid_thread_t;
typedef void (*fluid_thread_func_t)(void* data);
/** When detached, 'join' does not work and the thread destroys itself
@ -176,32 +138,24 @@ fluid_thread_t* new_fluid_thread(fluid_thread_func_t func, void* data, int detac
int delete_fluid_thread(fluid_thread_t* thread);
int fluid_thread_join(fluid_thread_t* thread);
/**
Sockets
Sockets and I/O
*/
fluid_istream_t fluid_get_stdin (void);
fluid_ostream_t fluid_get_stdout (void);
int fluid_istream_readline(fluid_istream_t in, char* prompt, char* buf, int len);
int fluid_ostream_printf (fluid_ostream_t out, char* format, ...);
/** The function should return 0 if no error occured, non-zero
otherwise. If the function return non-zero, the socket will be
closed by the server. */
typedef int (*fluid_server_func_t)(void* data, fluid_socket_t client_socket, char* addr);
fluid_server_socket_t* new_fluid_server_socket(int port, fluid_server_func_t func, void* data);
int delete_fluid_server_socket(fluid_server_socket_t* sock);
int fluid_server_socket_join(fluid_server_socket_t* sock);
/** Create a new client socket. */
fluid_socket_t new_fluid_client_socket(char* host, int port);
/** Delete the client socket. This function should only be called on
sockets create with 'new_fluid_client_socket'. */
void delete_fluid_client_socket(fluid_socket_t sock);
void fluid_socket_close(fluid_socket_t sock);
fluid_istream_t fluid_socket_get_istream(fluid_socket_t sock);
fluid_ostream_t fluid_socket_get_ostream(fluid_socket_t sock);

View file

@ -447,6 +447,8 @@ int main(int argc, char** argv)
exit (0);
}
g_thread_init (NULL);
#ifdef WIN32
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
#endif

View file

@ -22,6 +22,8 @@
#ifndef _FLUIDSYNTH_PRIV_H
#define _FLUIDSYNTH_PRIV_H
#include <glib.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
@ -168,57 +170,14 @@ typedef int fluid_socket_t;
/** Integer types */
#if defined(MINGW32)
/* Windows using MinGW32 */
typedef int8_t sint8;
typedef uint8_t uint8;
typedef int16_t sint16;
typedef uint16_t uint16;
typedef int32_t sint32;
typedef uint32_t uint32;
typedef int64_t sint64;
typedef uint64_t uint64;
#elif defined(_WIN32)
/* Windows */
typedef signed __int8 sint8;
typedef unsigned __int8 uint8;
typedef signed __int16 sint16;
typedef unsigned __int16 uint16;
typedef signed __int32 sint32;
typedef unsigned __int32 uint32;
typedef signed __int64 sint64;
typedef unsigned __int64 uint64;
#elif defined(MACOS9)
/* Macintosh */
typedef signed char sint8;
typedef unsigned char uint8;
typedef signed short sint16;
typedef unsigned short uint16;
typedef signed int sint32;
typedef unsigned int uint32;
/* FIXME: needs to be verified */
typedef long long sint64;
typedef unsigned long long uint64;
#else
/* Linux & Darwin */
typedef int8_t sint8;
typedef u_int8_t uint8;
typedef int16_t sint16;
typedef u_int16_t uint16;
typedef int32_t sint32;
typedef u_int32_t uint32;
typedef int64_t sint64;
typedef u_int64_t uint64;
#endif
typedef gint8 sint8;
typedef guint8 uint8;
typedef gint16 sint16;
typedef guint16 uint16;
typedef gint32 sint32;
typedef guint32 uint32;
typedef gint64 sint64;
typedef guint64 uint64;
/***************************************************************